Hi,
I'm using PIC 18F2480 and I want to receive a floating point number from PC via RS232.
How can I do this?
Thanks!
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
Posted: Tue Feb 26, 2008 7:54 am
Data sent by RS232 is sent either as ASCII characters or binary bytes. For beginners it is probably easier to deal with ASCII. Read each digit, check it for validity, add it to the variable. If another digit comes in multiply the variable by 10 and repeat. If a decimal point comes in start dividing by 10 instead of multiplying. If you might get an exponent character you will have to deal with that too.
Start real simple like 1234, then get more complex like -12.34. eventually you can handle 1.234,5E-3 if need to go that far. _________________ The search for better is endless. Instead simply find very good and get the job done.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum