CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

floating number via RS232

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
spom



Joined: 12 Jul 2007
Posts: 32

View user's profile Send private message

floating number via RS232
PostPosted: Tue Feb 26, 2008 7:38 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 26, 2008 7:54 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group