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

How to display floating point variable value on 16x2 lcd?

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



Joined: 04 Aug 2005
Posts: 21

View user's profile Send private message

How to display floating point variable value on 16x2 lcd?
PostPosted: Wed Sep 14, 2005 6:07 pm     Reply with quote

Hello..

Im trying to display the contents of floating point variable on my alphanumeric 16x2 lcd..
ex: count = 123.4532 and i want to display on lcd - 'cpm 123.4532'

The floating point value keep changing because it is related to my Timer1 value as external counter divide by some number.

Anyone can help me on this? Thanx a zillion~ Wink
Calamar



Joined: 07 Sep 2003
Posts: 60
Location: Buenos Aires (Argentina)

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Wed Sep 14, 2005 10:14 pm     Reply with quote

Do you use LCD.C library attached with CCS compiler ?


printf(lcd_putc"\f cpm = %f",myFloatVar);

you must give details, it's a standar LCD module ?
how did you wire it ?

There are a lot of previus topics taloking about that.
_________________
Best Regards
Daniel H. Sagarra
La Plata (Argentina)
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Sep 15, 2005 7:44 am     Reply with quote

Is it really a floating point number? Or is it fixed point non-integer? Maybe you should print the integer part, then print ".", then print the decimal part. Doing true floats takes a lot of resources.
I often measure things in mm and print the result in meters this way.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Henk



Joined: 22 Mar 2004
Posts: 6
Location: JOHANNESBURG, SOUTH AFRICA

View user's profile Send private message Send e-mail

DISPLAYING FLOATING PT NUMBERS
PostPosted: Sun Sep 18, 2005 1:21 am     Reply with quote

Depending on required number of dec. places, I multiply the float by 100, say, for 2 dec. places, then convert to an integer, which is then devide by 100000, to determine thousands, calc the remainder, div by 1000,etc, if you get the idea, remembering to display a "." for the decimal pt. The routine works well, and is adustable for 0 to 2 dec places, but can be modified for more.
Ttelmah
Guest







PostPosted: Sun Sep 18, 2005 2:38 am     Reply with quote

Worth also adding, that with the last couple of compiler versions, CCS have added support for this type of scaled integer with the '%w' printf format. The first version with this, had a fault (didn't put a '0' in front of the DP), but they have now fixed this, and indeed added an option to control this. Using such a scaled integer, results in much smaller code than a float. :-)

Best Wishes
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