Page 1 of 1

Send Number over UART

Posted: Fri Apr 12, 2019 7:50 am
by QMESAR
Hi Team,
I am struggeling to understand what I am doing wrong,
I have the Voltage of AN0 in a Float variable example 3.338xxx then I load the value into a Long variable for the component macro SendNumber
in the debugger I see now iin the LoadSignal(the ANO Voltage) 3.338 but in the TestNumber Variable(Long) I only see the 3 the decimal part is missing
this is also to for the value received on the other end the 3 is received but the decimal part is missing.
What am I doing wrong ,I also tried to convert the 3.338 to a string and send the string that also clips the decimal part. :oops:
Not that I think this is relevant however just for the exception PIC18F26K80 .

Pleas help the old man :D
P1.jpg
P1.jpg (26.67 KiB) Viewed 2059 times
P2.jpg
P2.jpg (36.9 KiB) Viewed 2059 times
here for example the value was 2.9200 I only receive the 2
P3.jpg
P3.jpg (93.67 KiB) Viewed 2059 times

Re: Send Number over UART

Posted: Fri Apr 12, 2019 8:37 am
by LeighM
Hi,
Yes, transferring a float value into an integer variable you will lose the fractional part
try this ... where 3 is the precision

Code: Select all

LoadSignal = 3.338
Text = FloatToString$ (LoadSignal,3)

Re: Send Number over UART

Posted: Fri Apr 12, 2019 8:44 am
by QMESAR
Thanks a million Leigh
:D
I appreciate you pulling me out of the endless loop :D :D