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

Implementing Variable Integers on an LCD screen

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



Joined: 15 Sep 2009
Posts: 4

View user's profile Send private message

Implementing Variable Integers on an LCD screen
PostPosted: Mon Sep 28, 2009 1:15 am     Reply with quote

Was wondering if someone could supply me with sample code of a clock displayed via an LCD screen either using the Flexible LCD Driver or the CCS LCD Driver. Any help would be appreciated.

I've attempted it so far:
Code:

#include <16F871.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000) // 4Mhz Crystal is Used
#include <stdio.h>
#include <flex_lcd.c>
unsigned char sec=0;

void main()
{
lcd_init();

while(1)
  {
   printf(lcd_putc,"\fSeconds:  %u",sec);
   delay_ms(1000);
   sec++;
  }
}


However it tends to run into a multitude of errors. I've also attempted it by changing bits of hardware around and used the CCS LCD Driver, the results are similar. Help!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 28, 2009 2:27 pm     Reply with quote

Quote:
However it tends to run into a multitude of errors

Explain what you mean by this. You should write the program.
It would be a good learning experience. We should not do it for you.



These example files show how to use printf to display the date and time:
Quote:

c:\program files\picc\examples\ex_rtclk.c
c:\program files\picc\examples\ex_rtc.c


This one is a complicated example of a clock based on a PIC timer:
Quote:
c:\program files\picc\examples\ex_rtctimer.c
SamRekem



Joined: 15 Sep 2009
Posts: 4

View user's profile Send private message

PostPosted: Tue Sep 29, 2009 7:38 am     Reply with quote

Thank You

Last edited by SamRekem on Tue Sep 29, 2009 7:41 am; edited 1 time in total
SamRekem



Joined: 15 Sep 2009
Posts: 4

View user's profile Send private message

PostPosted: Tue Sep 29, 2009 7:40 am     Reply with quote

Well the clocking program was really just a method to test the printf command and lcd_putc with a changing variable, I'm partially certain the contrast is to blame due the the consistent need to reset it after every variable change. I was more curious if I was in fact making errors in the code. I'm fairly new with working is the PIC series of microcontrollers, and with the ccs compiler. The LCD capability to display variable integers is just a small part of a much larger project.

For the most part of the project I have the timing functions working, the 4x4 keypad working (I tested it with a several LED attached to the processor to indicate which key had been pressed and where)

What I don't understand is why i don't have to reset the contrast when I run code like this


Code:

while(1)
{
      lcd_putc("LED ON");
      output_high(PIN_E0);
      delay_ms(5000);
      lcd_putc("LED OFF");
      output_low(PIN_E0);
      delay_ms(5000);
}

however if i use a printf command i consistently have to reset the contrast for it to display anything after the first line.
Ttelmah
Guest







PostPosted: Tue Sep 29, 2009 8:46 am     Reply with quote

Who's actual LCD are you using. Part number?.
On _some_ LCD's, there are timing issues, with things like the reset being slower than on the original Hitachi chipset that the drivers are meant to operate. On these it may be necessary to slow down some of the operations a little. However this will normally result in corrupted data, rather than contrast changes.
How is your contrast voltage actually being derived?. How long are the connections?. How is the PIC supplied?. What smoothing is present (on the LCD supply, the PIC supply, and the contrast line).
A contrast shift, almost certainly implies an unstable voltage somewhere (it will also change with temperature, but not significantly over normal room ranges).

Best Wishes
SamRekem



Joined: 15 Sep 2009
Posts: 4

View user's profile Send private message

PostPosted: Tue Sep 29, 2009 9:37 am     Reply with quote

LCD Part No. QP5520 the chip-set is based on the Hitachi. Contrast is being derived by a 10k potentiometer, connections are roughly 10-15cm via Ribbon Cable, power is supplied by a 5v regulator with two capacitors a 100uf and 0.1uf cap to remove additional noise. Right now the regulator is supplied with an old PC power supply running at 12V DC. However, later on I plan to supply it with a car battery. (our project has to be portable.)

The pic is programmed on a homemade PCB demo board. (as by that I mean all the programming connections are specific, with all ports running single copper lines with 3 component holes per line) I didn't use a veroboard. (programming works perfectly)
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