rs 232 receive by pic

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
silviodanceclub
Posts: 12
Joined: Tue Oct 30, 2007 11:10 am

rs 232 receive by pic

Post by silviodanceclub »

Hello,

i want to receive some rs232 data with my pic. but i dont know how to do this.

i receive this strings.

BLAH TESTxxx.IMG

the TEST .IMG is always the same.

the blah is a text variable to activate some outputs on the pic the xxx are numbers to activate diffrent outputs also on the pic.

receive example:

BLAH TEST132.IMG
RORO TEST142.IMG

so the first 4 letters are changing and the 3 numbers are diffrent every time.

how can i readout this numbers ?

Thanx !

Silvio

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello

The best way would be to do the following.

1. Listen for incoming characters and wait until 'T' and 'E' and 'S' and 'T' have been received in order.

2. create an array of 3 bytes or just create 3 byte variables to hold the next three incoming characters.

input[3]

or

hundreds
tens
units

3. create an int variable and load in each of the data bytes.

total = input[2] - '0'
total = total + (10 * (input[1] - '0'))
total = total + (100 * (input[0] - '0'))

or

total = units - '0'
total = total + (10 * (tens - '0'))
total = total + (100 * (hundreds - '0'))

The total variable shold now hold your three digit number.

the - '0' ( - 48 ) is used to convert the ascii number into a numeric value between 0 - 9.

silviodanceclub
Posts: 12
Joined: Tue Oct 30, 2007 11:10 am

Post by silviodanceclub »

Hello,

I`m sorry but i dont get this working rigt. is there some one who can make me a small example ?

thanx ! silviodanceclub (a) hotmail. com

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello

I have posted an example online for you.

http://www.matrixmultimedia.com/softwar ... _Input.fcf

The example waits for the string TEST and then reads the next three characters and converts into a number. Every time the TEST is detected the number is refreshed.

silviodanceclub
Posts: 12
Joined: Tue Oct 30, 2007 11:10 am

Post by silviodanceclub »

Thanx ! i`ll check it out !

Post Reply