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 CCS Technical Support

lcd with 16f676
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Nov 27, 2014 4:34 pm     Reply with quote

Glad to hear it... You are welcome.
_________________
Google and Forum Search are some of your best tools!!!!
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Fri Nov 28, 2014 1:11 pm     Reply with quote

now i want to display adc value on lcd. those code as
Code:
    set_adc_channel(1);
            delay_us(10);            //-------->NOTE:AQUISITION TIME NECCESARY
            battvolt=read_adc();         //reading current
            delay_us(10);
         battvolt=   (float)(battvolt * 5)/1023.0;   
 lcd_gotoxy(1,1);
 printf ( LCD_PutC,"Battery:\f%3.2f", battvolt);   
       lcd_gotoxy(12,1);
       printf(LCD_PutC," VOLT \n");

found error as
Quote:
Printf format type is invalid

_________________
sahu
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Fri Nov 28, 2014 2:57 pm     Reply with quote

Battvolt is declared as something other than a float.
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Fri Nov 28, 2014 3:45 pm     Reply with quote

Ttelmah wrote:
Battvolt is declared as something other than a float.

%3.2f is show only float only?
_________________
sahu
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Sat Nov 29, 2014 1:27 am     Reply with quote

Yes.

This is standard C. Look in the manual for printf.
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Sat Nov 29, 2014 6:51 am     Reply with quote

Quote:

This is standard C. Look in the manual for printf.

battvolt is declared as int32 battvolt . so how can printf it ?
_________________
sahu


Last edited by sahu77 on Sat Nov 29, 2014 7:30 am; edited 1 time in total
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Sat Nov 29, 2014 7:05 am     Reply with quote

Ttelmah wrote:
Yes.

This is standard C. Look in the manual for printf.

battvolt is declared as int32 battvolt . so how can printf it ?
_________________
sahu
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Sat Nov 29, 2014 9:02 am     Reply with quote

%Ld

However it won't have any decimals since it is an integer number.

Use:
Code:

         battvolt=read_adc();         //reading current
         battvolt=   (battvolt * 500)/1024;   
         lcd_gotoxy(1,1);
         printf ( LCD_PutC,"Battery:\f%5.2LW", battvolt);

This prints an integer, as a scaled value (/100 here). So the integer is made 100* larger in the earlier calculation.

Read the threads for why the correct divisor is 1024, _not_ 1023.
sahu77



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

PostPosted: Sat Nov 29, 2014 9:09 am     Reply with quote

Ttelmah wrote:
%Ld

However it won't have any decimals since it is an integer number.

Use:
Code:

         battvolt=read_adc();         //reading current
         battvolt=   (battvolt * 500)/1024;   
         lcd_gotoxy(1,1);
         printf ( LCD_PutC,"Battery:\f%5.2LW", battvolt);

This prints an integer, as a scaled value (/100 here). So the integer is made 100* larger in the earlier calculation.

Read the threads for why the correct divisor is 1024, _not_ 1023.

can u explain me 5.2 LW ?
_________________
sahu
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Sat Nov 29, 2014 9:18 am     Reply with quote

Read the manual....

It is a printf specifier to print an integer as a 'scaled' value.
The .2, specifies how far it is to be scaled.

So the integer '100', printed with 5.2w, prints as '1.00'. Scaled by two places.

The 'L' says that the number is a _long_ integer (bigger than int8).
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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