Page 1 of 1

Problem to create a program

Posted: Wed Jan 31, 2007 9:07 am
by Fisher Benjamin
i will create a program to control a brake to powder with Flowcode. i've create an algorigramm but i 've to Convert a string of characters in a variable whole because I receives figure 1 by 1 avec the RS232.
Can you help me please because it's hard (it's my first use of flowcode )

Posted: Wed Jan 31, 2007 10:41 am
by Benj
Hello

I will try to break the problem down into blocks compatible with Flowcode.

Variables Window
byte index
byte max_index
byte char_in
Strinr word_in

Flowcode Main Program
Calculation
index = 0
max_index = 10

Loop(index < max_index)
{
Component Macro RS232 - read_byte - return value char_in
String Manipulation - word_in = word_in + char_in
Calculation index = index + 1
}

Posted: Thu Feb 01, 2007 3:22 pm
by Fisher Benjamin
Thanks

i'm don't understand

Posted: Thu Feb 01, 2007 3:33 pm
by Fisher Benjamin
I'm sorry but I don't understand the line :
"Component Macro RS232 - read_byte - return value char_in "
Can you explain me: what is the parameter timeout(byte) ?

problem with string of caracters

Posted: Thu Feb 01, 2007 4:42 pm
by Fisher Benjamin
Why i can use a number enregistred in a strinc of caracters :?:

Posted: Thu Feb 01, 2007 4:55 pm
by Fisher Benjamin
How i can use a number enregistred in a string of caracters

Posted: Thu Feb 01, 2007 5:24 pm
by Steve
If I understand your question correctly, you want to use a number that is received via RS232 as a string of numerals, e.g. "173".

To convert this to an actual number, you would need to perform the mathematics yourself.

The numbers "0" to "9" are ascii codes 0x30 to 0x39, or 48 to 57.

If you received the string "173", then the codes would be 0x31, 0x37 and 0x33. You would subtract 0x30 from each number, leaving you 1, 7, and 3.

You would then multiply each number by the appropriate power of 10 and add them up, i.e. 1x100 + 7x10 + 3 = 173.

Of course, you will need to ensure that the characters received are valid numbers (i.e. between 0x30 and 0x39).

Posted: Fri Feb 02, 2007 2:40 pm
by Fisher Benjamin
Thanks I think i've succeed