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

Receiving on RS232 Question

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







Receiving on RS232 Question
PostPosted: Thu Feb 24, 2005 4:45 am     Reply with quote

Hi,

Does anyone know how I can receive a float from a PC down to my PIC (16f876). Does anyone have the code to do this by any chance???

Cheers,

Dave.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Thu Feb 24, 2005 7:28 am     Reply with quote

Well as far as the transmission a float on the pc is just a number encoded as a fixed number of bytes. If the bytes are transmitted one by one as they will be via RS232 the PIC will receive the bytes.
Now the fun begins
The number must be decoded to a valid float for the PIC. The PIC uses an
international standard....The CCS manual shows the sign mantissa exponent layout. a byte recieved can be big endian or little endian so you'll have to watch for it. Also watch out for the placement of the byte in the output stream ( is it part of the exponent or the mantissa) Next if the float is from some microsoft products it may have the first bit of the mantissa jazzed up. In floating point binary the first bit of the mantissa is always a one. Now the softees knowing this sometimes stuff the sign bit in there switching it to represent a neg or sometimes a pos ( when it comes to jazz there are no standards) so you need to look at the first bit of the mantissa to see if it is always one.

Also watch for the exponent offset.
Start by trying powers of two 2 4 8 16 in float and see how they are coded. they should all be sign bit,1,0...0 ( Ex 22 zeros for CCS float) for the mantissa with only the exponent varying.

Now get ready "for all that jazz".
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