Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Display floating point and integers on LCD

Status
Not open for further replies.

CMOS

Advanced Member level 3
Joined
Jan 6, 2004
Messages
862
Helped
94
Reputation
186
Reaction score
50
Trophy points
1,308
Location
USA
Activity points
5,673
displaying floating point in lcd

Can anyone please show me a sample C code to convert floating point and integer to BCD/ASCII? I want to display it on alphanumeric LCD.
For ex. I want to display "0.5" etc. on LCD which are in float data types.
 

floating point to lcd

No one has ever done this? :(
 

float point lcd

Thanks. I'll register and ask over there.

In the mean time if anyone over here knows how to do this, please help.
 

floating point representation in lcd

I found the solution over there. Here it is if any one is interested.

Code:
char buffer[255]; 
double/float yourvar; 
sprintf(buffer, "%d" , yourvar);
 

Hi CMOS,

if you have sprintf available on you C compiler is good, but make attention of code space required by sprintf function. You can compare with (an example for one digit for integer part and one digit for fraction):

float a=0.5;
char str[4];
str[0]=(int)a+0x30;
str[1]='.';
str[2]=(int)(a%10)+0x30;
str[3]=0;


HH

NeuralC
 

This is more than easy, use the 8051 ANSI C Compiler from www.wickenhaeuser.de They have included drivers for own printf() formaters, with an example how to write an own 'lcd_printf()' Routine, that can even output floating point numbers.
There is a free 8kB code size limited demo... I tried it, nice product. The only problem (for them) is: the code is so dense, you have really to work hard until you get over the 8 kB :) :) :)

Nig.
 

Thanks for your suggestions guys. I've tried uC51. It has quite good library functions but it takes no time for the compiler to generate 8kb code for just a few lines of C code :(
 

:?: I think if you use the "%f" formater option, the code will get 1-2kB larger, because the full formater libs will be linked.

I am using a LCD on a 89S8252 with only integers "%d", "%u", for a RF-ID system (school project). Works fine :) and still half of the CPU (exactly 8k) is unused...

Maybe this could help you?: Use Fixedpoint formats:
You can use 'lcdprint("%d.%02u",val/100,(uint)(val%100))' to get a "pseudo" floating point output (with 2 digits).

Nig
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top