UART Serial Sending Numbers

For general Flowcode discussion that does not belong in the other sections.
Post Reply
jay_dee
Posts: 136
http://meble-kuchenne.info.pl
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 47 times
Been thanked: 31 times

UART Serial Sending Numbers

Post by jay_dee »

I think I've caught myself out!
I'm sending Byte values from a PIC using UART, values 0-255, These are recieved by Flowcode App Dev.
But should I be using the sendChar, Send Number or Send String macros?

If I sendChar 0 ( which I accept is ASCII Null) I dont seem to get anything at the other end?
I could convert each number to a test string, but then I have to send 3 bytes to represent a character from a single byte.

Im sure I had this issue a few years back buyt I've forgottn the solution! Any ideas? :)

medelec35
Matrix Staff
Posts: 1486
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 532 times
Been thanked: 483 times

Re: UART Serial Sending Numbers

Post by medelec35 »

Hi,
You can use SendNumber or SendString
Both will work as the SendNumber automatically sends the numbers as an ASCII string.
Therefore you can send any number including 0
When you had the issue , you could have been trying to send Char before the sendNumber was added to the components?
Martin

jay_dee
Posts: 136
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 47 times
Been thanked: 31 times

Re: UART Serial Sending Numbers

Post by jay_dee »

Thanks Martin,
To Clarify.. if I want to send a number over UART, I can only send it as a text based string. Thus for 255 send multiple bytes "2" "5" "5".
In terms of bandwodith cost, Instead of a single byte of data I need to send three bytes of data?

I cannot reliably send lower vlaue bytes as these may be interpreted as command characters, since all recieved data is compared to an ASCII lookup table and the first 16 items are command characters.

Are both of these statments rougly correct? Thanks, John.

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: UART Serial Sending Numbers

Post by p.erasmus »

jay_dee wrote:
Mon Jan 25, 2021 9:24 am
if I want to send a number over UART, I can only send it as a text based string. Thus for 255 send multiple bytes "2" "5" "5".
In terms of bandwodith cost, Instead of a single byte of data I need to send three bytes of data?
This is not totally true you can send numbers 0-255 as a byte and 0-65535 as 2 bytes however this depends more on the receiver than the sender as the receiver determines how it interprets the UART bytes received,

For example I send a Byte array of 20 bytes containing the number it self such as 1 or 555 (in this case 2 bytes) the receiver read this bate array and do the ASCII encoding and use the corresponding value so the actual processing power is done by the LABVIEW application not the small micro UART.

This all really depends on your receiver how it can and will interpret the bytes you send.
Sorry not to trying hijack the post just wanted to share a bit of my experience
Regards Peter - QME Electronics

jay_dee
Posts: 136
Joined: Sun Dec 20, 2020 6:06 pm
Has thanked: 47 times
Been thanked: 31 times

Re: UART Serial Sending Numbers

Post by jay_dee »

All input appreciated. Great, yes that totally make sense.
The UART transmitter does not determine how the bytes are interpreted, the Reciving device does. If it handles everything as ASCII then I must bend to its will and send character values rather than pure byte values.

As a non coder ( mechanical/electrical background) even after years of FC... so much of the basics are still missing!
J.

medelec35
Matrix Staff
Posts: 1486
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 532 times
Been thanked: 483 times

Re: UART Serial Sending Numbers

Post by medelec35 »

Suppose you use the SendNumber 1234
What that will do is break the numbers in to four lots of bytes.
The first byte sent is 41. That is ASCII for 1
then 42, 43 and finally 44 is sent.
That would be the same if SendString "1234" is used
Again 41, 42, 43 & 44 is sent
p.erasmus wrote:
Mon Jan 25, 2021 11:37 am
Sorry not trying hijack the post just wanted to share a bit of my experience
Not at all!
It's the opposite.
You are posting very useful contributions, so thank you.
Martin

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: UART Serial Sending Numbers

Post by p.erasmus »

jay_dee wrote:
Mon Jan 25, 2021 11:52 am
All input appreciated.
medelec35 wrote:
Mon Jan 25, 2021 12:03 pm
Not at all!
It's the opposite.
You are posting very useful contributions, so thank you.
Thanks guys appreciate :D I am also learning still from here in the forum

:D
Regards Peter - QME Electronics

Post Reply