RS232 Help

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

Moderators: Benj, Mods

Post Reply
Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

RS232 Help

Post by Ondra »

Good day all.
I need some help with the RS232 Component. Couple of things.
1. When I check the radio button to select byte for my transmit or
receive in the RS232 Component, then I select "call component macro" I still only see SendRS232Char and RecRS232Char. When I select byte should I then see Send and RecRS232Byte?
2. When I run my program the RS232 simulation looks fine. I download to the PIC my characters look fine but if I select byte I get a lot of junk(winding)on the screen.
I have a sensor connected to an ADC, I want to capture the reading and store the information in a variable,(that part I can do) the part I need help with is: - I want to later read the value out of the variable and send the information out of the RS232 port along with some text, how do I do this. I have been playing with it all day, Readin every thing I could on the forum with no luck, when I send quoted text looks fine, but when ever I send int or byte all I see is garbage what am I missing.

Thanks in advance

Ondra

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

1. The "bytes/characters" option of the RS232 component affects the display only.

2. When using the "bytes" option, the display shows the ASCII values of the characters sent instead of the characters themselves.

For example, the icon <SendRS232Char("hello")> will display "hello" if the selected option is "characters" and "104,101,108,108,111" if the selected option is bytes.

When you send a variable, it sends the actual value of the variable. So if you send a variable with the value 88, this is what is sent (which is in fact the ASCII value of 'X', so you would see "X" displayed if set to display characters).

To do what you want, you would need to convert the number to a string (using a "string manipulation" icon with the "ToString" function). Then send the resulting string one character at a time. The basic program would be like this:

Code: Select all

//string manipulation
myString = ToString$(myVal)
len = Length$(myString)

//calculation
idx = 0

//loop
While idx < len

    //call component macro
    SendRS232Char(myString[idx])

    //calculation
    idx =idx + 1

//loop
End While

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Post by Ondra »

Thanks for your help Steve. Are you saying that at this point I need to dabble in C coding. If so I really don't know where to start. Is there a way to do all I need using flowcode objects? beside the c object that is.

Ondra

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

No C here - this is just my short-hand way of writing a Flowcode program without creating an image and then uploading it.

Each icon is spearated by a blank line and begins with a C-style comment describing the icon type (calculation, decision, etc).

I'll describe the probram a bit more thoroughly here:

The first icon is a "string manipulation" icon containing the following 2 lines:

Code: Select all

myString = ToString$(myVal) 
len = Length$(myString) 

Next is a calculation icon with a single line:

Code: Select all

idx = 0 
Then a loop icon with this as a decision:

Code: Select all

idx < len 
Within the loop is a call to the SendRS232Char macro with this as a parameter:

Code: Select all

myString[idx] 
And another calculation icon with this:

Code: Select all

idx =idx + 1 
I hope that explains things.

Ondra
Posts: 325
Joined: Wed Aug 29, 2007 7:33 pm
Been thanked: 2 times
Contact:

Post by Ondra »

Yes Thanks that does clear it up. While I'm at it, how do you delete a component I tried to delete the RS232 component and I couldn't.

Thanks again for your help

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Post by Steve »

To delete a component, make sure there are no macro calls to its functions and then click the down-arrow on the component and select "delete...".

The "x" in the corner hides the component, rather than deleting it.

Post Reply