Home › Forums › Microcontrollers › PIC Microcontroller › Display Float on LCD – MPLAB XC8
- This topic has 6 replies, 2 voices, and was last updated 8 years, 11 months ago by
Ligo George.
Viewing 7 posts - 1 through 7 (of 7 total)
-
AuthorPosts
-
December 22, 2014 at 7:04 pm #10277
sahu
ParticipantHow to display floating point values on LCD ? I am using MPLAB XC8 LCD Library.
December 22, 2014 at 10:19 pm #10280Ligo George
KeymasterYou can display floating point values on LCD in following two methods.
- By converting floating point value to string and display that sting using Lcd_Write_String()
- By separating each digits and display that digit using Lcd_Write_Char() after converting it to character
The second method is the best method but it will vary depending upon the length of values that to be displayed.
December 22, 2014 at 11:49 pm #10281sahu
ParticipantPlease give me a example of first method.
December 23, 2014 at 7:18 am #10289Ligo George
KeymasterUse sprintf() to convert floating point number to string :
........ #include<stdio.h> ...... ... ... void main() { char s[16]; float f; ........ .... while(1) { .... ... ... sprintf(s, "Float = %f", f); Lcd_Set_Cursor(1, 1); Lcd_Write_String(s); ........... ..... } }
December 23, 2014 at 4:05 pm #10321sahu
ParticipantThank you Sir
January 6, 2015 at 4:05 pm #10424sahu
Participantwhat wrong with me `
a = ADC_Read(0); involts =a*5000/255; delayMs(10); { Lcd_Clear(); Lcd_Set_Cursor(1,1); Lcd_Write_String("Mains"); /* Lcd_Set_Cursor(1,10); Lcd_Write_Char(involts%10 + 48); involts = involts/10; Lcd_Set_Cursor(1,9); Lcd_Write_Char(involts%10 + 48); involts = involts/10; Lcd_Set_Cursor(1,8); Lcd_Write_Char(involts%10 + 48); */ sprintf(s, "Float = %f", involts); Lcd_Set_Cursor(1, 10); Lcd_Write_String(s); Lcd_Set_Cursor(1,13); Lcd_Write_String("VOLT");
found error as
lib\doprnt.c; 837. bad call to typeSub()
`January 7, 2015 at 8:55 pm #10433Ligo George
Keymaster- Try using the latest compiler
- Make sure that you properly set the pic type in configuration
- Try recreating the project after deleting all files
-
AuthorPosts
Viewing 7 posts - 1 through 7 (of 7 total)
- You must be logged in to reply to this topic.