RS232 Rx character and decision

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
IAB48
Posts: 13
Joined: Wed Feb 18, 2009 3:24 am
Contact:

RS232 Rx character and decision

Post by IAB48 »

sorry guys I guess I need some more direction with this one.

OK I'm looking for a particular sequence of characters in a RS232 input. As per my previous post the ssequence is Stopped.

So i looked at how to test for the sequence and thought a number of Yes/ No decisions would be the go.

The problem is that I can't figure out how to test for the character. It doesn't seem an iusse if I look for an integer EG a 1 or a 2 or a 3 etc, but I can't figure out how to test for a letter.

Would I use the ascii equivalent ?

I tried it with strings but it didn't work and no mater what i do with a letter ie in double quotes or not it doesn't work.

I've tried hunting for examples but there doesn't seem to be anything applicalbe written in flowcode 4.

any help would be appreciated

Cheers


Ian B

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: RS232 Rx character and decision

Post by medelec35 »

Hello IAB48
How about using the Compare$() function.
You can set RS232 to receive string.
Then drag a string manipulation box. Press Functions button.
Select Compare$()
Then you can compare the stored string with received string.

If you have a string array of 20 for example, and rs232 receives one letter.
You could use the Mid$() function to select one letter at a time then compare to received rs232 letter.

If you get stuck, give a typical example of letter/letters received e.g. how many. Then what you want the results to be if found a match.
Give as much detail as poss, e.g compare with a single letter or compare with a group of letters etc.
I will help you put something together.

The other way is to receive rs232 as a char. Then each char received is decimal equivalent of ASCII letter. E.g if h is sent then char received will be 104. then you can use a decision component since you know 104 will be a h etc.
Martin

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: RS232 Rx character and decision

Post by Dan81 »

Hello Ian

The system which sends characters is existing or you will have to make it too ?

What kind of characters are receiving : only letters and numbers or bytes from 0 to 255?


Daniel

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: RS232 Rx character and decision

Post by medelec35 »

Here is a flowchart that is set up to check for the words:
Stopped
Next Track
Repeat On
Repeat Off

If there is a problem with receiving e.g Xepeat Ofg
then the Receive Error will light until Repeat Off or other recognised word is received.

It is easy to change the words already stored or to add another set of words.
E.g you have got Next Track, and you want to change to add the word 'First Track' to your list of stored words.
Press F8 Function key once.
Click on + of RS232 on your control panel.
Enter letters:First Track
Keep pressing F8 until the variable called Sum no longer increases.
Enter the Value of Sum (should be 1053 Since Refering to ASCII: F=70, i=105, r=114, s=115, t=116, Space=32, T=84, r=114, a=97, c=99 & k=107. Tot=1053) as a new Case Value within switch Properties.
Add the required functions to thew case line e.g 1->A7 etc.

Note: I have set a timing function (1 second).
So when RS232 receives it 1st character, a timer will start.
During this time RS232 will wait for rest of the characters to form the word to be compared.
After timer has elapsed the value of Sum variable is compared with the stored values. (stored as a number within the Switch properties)
After processing, the whole process is repeated.
Hope this works the way you want it to.
String compare.jpg
String compare.jpg (47.01 KiB) Viewed 3792 times
If you want to speed up testing. With simulator running, press + of RS232, enter text.
Pause simulator, double click on Count Variable.
Change Value of count variable to 73.
Continue running simulator.
Or Change mod value in timer0 macro from 75 to something like 3. That way you can keep the simulator running all the time.
Just don't forget to chang it back to 75 (=1 second) :P
Or to a different value to change the time out before string is compaired
Attachments
RS232 String Compare.fcf
(14 KiB) Downloaded 365 times
Martin

Post Reply