electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

how to display float number to lcd


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> how to display float number to lcd
Author Message
lgeorge123



Joined: 13 Jun 2004
Posts: 62


Post17 Apr 2008 14:13   

how to display float


i have two variables float number (may be 1.28 and 15.9, note the position of decimal point), can anyone tell me how to display to lcd using keil c ???
the only one way is to convert above two float number to array of ascii and then output to lcd, more trouble is how to determine the position of decimal point, the exact method i don't know !!!! mcu i am using is 89s52.
Back to top
nandhu015



Joined: 11 Feb 2006
Posts: 640
Helped: 46
Location: Tamilnadu, India


Post17 Apr 2008 16:26   

lcd display float


hi lgeorge123

what i do is simply convert all of them to 0.00 precesion.

I think you got the idea.

Regards
Nandhu
Back to top
RBB



Joined: 02 Jul 2007
Posts: 115
Helped: 11
Location: USA


Post17 Apr 2008 17:03   

float lcd


Can you:
1. type cast the real number to an integer
2. take the difference between the integer and the float
3. multiply the difference by some value
4. then type cast that value to an integer?

You would then have two integer values you could convert to ascii. You would then display a '.' between the two integers.

float realValue;
int intValue = (int)realValue;
float diffValue = realValue - (float)intValue;
int anotherIntValue = (int)(diffValue * 1000.0)

sprintf("%s.%s", itoa(intValue), itoa(anotherIntValue));
Back to top
jit_singh_tara



Joined: 22 Dec 2006
Posts: 110
Helped: 6


Post17 Apr 2008 17:24   

float to lcd


suppose you have

23.57

1. for integral part
equate temp1(int ) to 23.57;
temp1 will be 23 only as it is of int type so 23.57 will be typecasted to 23 .you have integral value.


2. for float part

multiply the number by 100 store it in int variable(0 to 65535) say temp;
now temp = 2357

get the lower two digits as 5 and 7 (i hope you can do it).just split 2357 into 4 separate values by taking remainder (after dividing by 10).

once you have 4 separate values of 2 , 3 ,5,7 dislplay it anywhere.
Back to top
gvinu4u



Joined: 10 Mar 2008
Posts: 24
Helped: 1
Location: Bengaluru


Post17 Apr 2008 17:49   

ascii display


I recommend u to store the values in two seperate variables ie interger and float part later display it on lcd seperated by a dot
Back to top
Google
AdSense
Google Adsense




Post17 Apr 2008 17:49   

Ads




Back to top
XNOX_Rambo



Joined: 13 Jul 2002
Posts: 437
Helped: 87
Location: Far out, man!


Post18 Apr 2008 0:09   

display float number to lcd


Code:
float xdata a, b;
char xdata str[20];

a = 1.28;
b = 15.9;

sprintf(str,"A: %4.2f B: %4.1",a,b);   // Adjust the formatting to your liking.

gputs(str);                   // Or whatever you use to write strings to the display.
Back to top
pak_soft



Joined: 19 Feb 2008
Posts: 2


Post20 Apr 2008 17:37   

display floating value on lcd


Hi,
I use keil compiler for 8051 mcu, i use sprintf to display float number to lcd pls refer to following example. Note: sprintf take a lot of memory space, but easier to use. All you need to do is to declare one array.
Code:
void main() {
  char buf[8];    // declare array
  delay_ms(100);  //settle time for lcd
  lcd_init();     // initialization of lcd
  lcd_clear();    //clear lcd display
  sprintf (buf, "float=%f", 1.156);  // here is sprintf prototype function usage
                                     // 1.156 is just example you can change it
  lcd_puts(buf);  // display float number from array to lcd
}


hope it'll help you,

regards,
pak
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> how to display float number to lcd
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
How to show a float number on a text LCD.... (1)
how to display range number include '+' and '-' on LCD?? (2)
problem of display number on LCD (1)
Problem in LCD display in PIC 16f876 with 16x2 lcd display (3)
float to whole number conversion (7)
How to display Real number ?? (7)
Hex (From ADC) to Float number (2)
how to display negative number properly in DC Compiler? (6)
How to program LCD-Display (7)
motorola lcd display how to? (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS