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
RS232 Help
- Steve
- Matrix Staff
- Posts: 3433
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
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:
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
- Steve
- Matrix Staff
- Posts: 3433
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
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:
Next is a calculation icon with a single line:
Then a loop icon with this as a decision:
Within the loop is a call to the SendRS232Char macro with this as a parameter:
And another calculation icon with this:
I hope that explains things.
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
Code: Select all
idx < len
Code: Select all
myString[idx]
Code: Select all
idx =idx + 1