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

LCD display keep flashing

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



Joined: 14 Mar 2010
Posts: 21

View user's profile Send private message

LCD display keep flashing
PostPosted: Sun Apr 25, 2010 7:19 am     Reply with quote

Code:
#include <18F4620.H>
#device adc=10
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=2000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#include <LCD20x4.c>

//============================
void main()
{
int16 adc_value;
float volts;
 
lcd_init();

setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);
delay_us(20);

while(1)
  {
   adc_value = read_adc();
   volts = (float)(adc_value * 500)/1023.0;   
lcd_gotoxy(2,1);
   printf(lcd_putc, "\f%3.2fv", volts);
   delay_ms(500);
  }
}


printf(lcd_putc, "\f%3.2fC", volts);
if i replaced it by printf(lcd_putc, "%3.2fC", volts);
it will not keep flashing ,
but if the volt under 10 such as 9.56 it will display 9.56vv

it loop the \f.....
how can i solve it ? thank you
Razz
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sun Apr 25, 2010 10:25 am     Reply with quote

The problem is that your input voltage is higher than the Vref.
Using:
setup_adc_ports(AN0); // The +5v is used as a Vref.

I gues that you are using a Vin/2 voltage divider.
When the input voltage is higher than 10.0V, let says 10.6V you get:
(10.6V*500)/1023= 5.18V

You need to recalculate the voltage divisor in the input AN0 in order that Vin
by no way should be higher that +5V.


Humberto


Last edited by Humberto on Sun Apr 25, 2010 10:34 am; edited 2 times in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 25, 2010 10:26 am     Reply with quote

Quote:
but if the volt under 10 such as 9.56 it will display 9.56vv

See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=34424&start=2
project2010



Joined: 14 Mar 2010
Posts: 21

View user's profile Send private message

PostPosted: Sun Apr 25, 2010 10:44 am     Reply with quote

Humberto wrote:
The problem is that your input voltage is higher than the Vref.
Using:
setup_adc_ports(AN0); // The +5v is used as a Vref.

I gues that you are using a Vin/2 voltage divider.
When the input voltage is higher than 10.0V, let says 10.6V you get:
(10.6V*500)/1023= 5.18V

You need to recalculate the voltage divisor in the input AN0 in order that Vin
by no way should be higher that +5V.


Humberto


oh...i just made and example....i have not focus on the voltage...
you're right, the v max must be=<5V

Anyway thank you for your reply.
project2010



Joined: 14 Mar 2010
Posts: 21

View user's profile Send private message

PostPosted: Sun Apr 25, 2010 10:45 am     Reply with quote

PCM programmer wrote:
Quote:
but if the volt under 10 such as 9.56 it will display 9.56vv

See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=34424&start=2


thank you PCM programmer:grin: , problem fixed.
This is the only way to fix it? add a if()
project2010



Joined: 14 Mar 2010
Posts: 21

View user's profile Send private message

PostPosted: Sun Apr 25, 2010 11:14 am     Reply with quote

i try it that's good.
i also found if i use %3.0f it can auto provide a space before the no.
_88 <like this
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