View previous topic :: View next topic |
Author |
Message |
Acktung
Joined: 05 Jun 2005 Posts: 10
|
LCD Contrast regulated by a PIN |
Posted: Sat Jun 18, 2005 6:13 pm |
|
|
is possible?
... is there someone whom he knows how to regulate ana analogical tension on a pin? in this way it would be possible to check the contrast of a lcd eliminating the use of the trimmer ... |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Sun Jun 19, 2005 1:05 am |
|
|
You can connect a pin to an RC filter, and then pulse-width modulate the digital signal on it. You'll have a primitive DAC. |
|
|
Ttelmah Guest
|
|
Posted: Sun Jun 19, 2005 4:29 am |
|
|
Key thing to remember, is that on most LCD's, the contrast control is a -ve voltage. This means that if you use a PWM DAC, or any other form of simple DAC, you end up needing a voltage shifter circuit afterwards.
However some digital potentiometer chips, will support voltages on the pot, beyond the supply rails. I use the X9C503, to control the contrast on a number of projects. This supports terminal voltages down to -5v, and have the big plus that the chip itself stores the last set position on power down. We have a bit of code that during the first ten seconds after power up, alows two keys normally used for other operations, to change the pot value.
Best Wishes |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Sun Jun 19, 2005 4:31 am |
|
|
you can also use digital potentiometer ICs for a really fancy LCD contrast setting. These are available from Microchip as MCP4021 /2/3/4, (or many others from different manufacturers), these usually have up/down control, last value saved, and many other features. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 19, 2005 6:57 pm |
|
|
Quote: | on most LCD's, the contrast control is a -ve voltage |
I don't think this is true for modern character LCDs. I checked the
data sheets for 16x2 LCDs from various manufacturers, and all of
them will work with a contrast control that consists of a 10K trimpot
connected between +5v and GND.
CrystalFontz:
The 16x2 Data Sheet shows a trimpot connected to +5v and GND.
They show an optional Vee generator, but I have used a CrystalFontz
LCD and I know that a positive voltage for the contrast voltage works OK.
The notes on my schematic say that 0.425v gives the best contrast on
a 8x2 LCD.
http://www.crystalfontz.com/products/1602b/index.html#CFAH1602BYYBJP
Comment on their tech forum that says contrast voltage is positive:
http://www.crystalfontz.com/forum/showthread.php?
s=7b92e998cbb9eb1559d4d7b1facde2b3&threadid=2281
Hantronix:
Page 6 of the specification for their Character LCDs shows a trimpot
connected between +5v and GND. They show an option of using Vee,
but I have used Hantronix LCDs and I know that the positive-voltage
method works OK.
http://www.hantronix.com/down/char-comm.pdf |
|
|
jruibarroso
Joined: 07 Jan 2006 Posts: 64 Location: Braga
|
Hi, Ttelmah , can you post the "driver" code for X |
Posted: Thu Oct 12, 2006 12:32 pm |
|
|
Hi, Ttelmah (or anyone) , can you post the "driver" code for X9C503 you used to control contrast ?
Thank you ALL |
|
|
Mark Weir
Joined: 11 Sep 2003 Posts: 51 Location: New Zealand
|
PWM |
Posted: Thu Oct 12, 2006 12:56 pm |
|
|
Hi There ,
I have had great success just using the on board PWM module and adjusting the duty cycle to give the desired contrast here is an example. Code: |
setup_timer_2(T2_DIV_BY_16,250,1); //Timer2 enabled, prescaler of 1, PR1 = 250, post-scaler = 5
setup_ccp1(CCP_PWM);
set_pwm1_duty(10);
|
I use this example with both 16 F 872 and 18 F 252 PIC's.
I connect pin C2(ccp1 out) to pin 3 ( Vee) on the lcd then adjust the value in set_pwm_duty to suit.
Hope this helps.
Cheers
Mark |
|
|
C Turner
Joined: 10 Nov 2003 Posts: 40 Location: Utah
|
|
Posted: Thu Oct 12, 2006 1:13 pm |
|
|
In line with a previous reply of mine, I might point out that many surplus/new LCDs that will work with a 0-5 volts contrast voltage have very high input impedance on their contrast adjust pins. This would make them pretty good candidates for using the CVref pin (as mentioned in the "is it possible to output an analog voltage on an analog pin" thread) to control the contrast.
In my experience, most LCDs have the majority of their useful range "scrunched" near one end of the adjustment (the GND end, I believe) so this is a case where it might be beneficial to use a resistive divider (or even heavily load the R-2R network) to move the D/A range closer to GND. Having only 4 bits (16 steps) of adjustment should be enough for LCDs, too...
CT |
|
|
Ttelmah Guest
|
|
Posted: Thu Oct 12, 2006 2:36 pm |
|
|
Yes. In fact I am using a couple of the Powertronic ones, with the simplest possible contrast control. Resistor/capacitor from a PWM output. Runs very well indeed.
Best Wishes |
|
|
|