Parallel LCD Interfacing
Sal Ammoniac
Posts: 213
I have an HD44780-compatible 20x2 LCD that I want to interface to a Propeller Proto board.
This LCD doesn't work with 3.3v on Vdd, but does with 5v. When I look at some of the LCD's pins (e.g. the data pins DB0-DB7) with a scope I see 5v on them. Can I connect this display directly to the propeller, or do I need a level converter to convert 5v -> 3.3v on the interface pins (RS, R/W, E, DB0-DB7)?
·
This LCD doesn't work with 3.3v on Vdd, but does with 5v. When I look at some of the LCD's pins (e.g. the data pins DB0-DB7) with a scope I see 5v on them. Can I connect this display directly to the propeller, or do I need a level converter to convert 5v -> 3.3v on the interface pins (RS, R/W, E, DB0-DB7)?
·
Comments
Most displays have an input threshold of 2V, in some rare cases I have come across CMOS threshold modules (0.7VCC).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
I'm finding it very easy to write driver code in Spin to control things like the LCD and the SCP1000 pressure sensor I wrote last night. The only mildly disappointing thing is the speed. I can only toggle an I/O pin every 11 usec in a tight loop at 80 MHz. I'll have to write drivers for devices that require faster timing in assembly.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Post Edited (Leon) : 11/21/2009 8:35:02 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
Pin 1,3,5,7,9,8,10,16 to ground.
Pin 2 to 5V.
Pin 15 to 5V via a 1k resistor (backlight).
Pins 11,12,13,14 = data lines
Pin 4 = RS
Pin 6 = E
As Peter says, tying R/W low means the device never sends any data back (it is a display so it doesn't really need to). So you don't need any resistors.
Neither do you really need a contrast pot. After constantly finding they always ended up wound right round one way, I just tie the contrast to ground.
No delays needed in spin code (there is code on the obex with 1ms delays but they are not needed). The only delay is one on startup = put all 6 lines low and wait 200ms before sending the setup codes.
The only thing I haven't actually tested is running it from 3v3. I am driving it via a HC374 latch that is run from 5V and I know the latch will accept 3V3 as a high input. But I'm not 100% sure if LCD modules will.
Re When I look at some of the LCD's pins (e.g. the data pins DB0-DB7) with a scope I see 5v on them., try pulling R/W low and see if any of those pins still have 5V on them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.smarthome.viviti.com/build
There is nothing stopping all these hundreds and hundreds of Hitachi compatible chip makers from putting in a shift register and do what the makers of the 128x64 LCD that I have been talking about have done by making it compatible plus practical so that you can just use two I/O instead. That would at least make a lot more sense than having this archaic interface on intensive life support. Of course I2C or asynch serial would make even more sense.
Some LCD usage tips (take em or leave em):
1. Tie R/W low and just use an appropriate delay as specified in the datasheet (1.5ms for clear and home commands, 40us for all else)
2. Skip the pot. Try tying the contrast pin directly to ground or through a diode (0.6V) which is a good compromise. Alternatively use PWM into an RC network to drive the contrast. You find that most pots only use a few percent of their range and you need a screwdriver and access anyway so why bother.
3. Practically all LCDs have 2V thresholds so they will work fine without buffers. As James pointed out you can probably run them off 3.3V but the contrast pin needs to be around 4.5V negative to the supply (that's why they quote the figure as Vdd-Vo).
4. The backlights on some require over 200ma but you don't need a TO220 pack transistor to switch this, no no no, I use a tiny SOT-23 pack BC817 with a series 2R2 resistor to achieve on/off and PWM control of the backlight. Sometimes it makes more sense to tie the backlight to a higher voltage and control the current with the resistor or via PWM rather than cook the systems 5V regulator.
If you really want to know about these displays then don't look at the display datasheets as they are little more than a brochure, go to the definitive source, the "Hitachi HD44780 Dot Matrix Liquid Crystal Display Controller/Driver" manual, it's 226 pages long.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
Where can I get this manual? A Google search turned up a few references to it, but not the manual itself.
www.pbjtech.com/propeller/hd44780%20MANUAL.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
Power users such as myself require the resistors because we are reading from the LCD.· If you're not reading the busy flag before sending data out to the LCD then you have no choice but to delay every byte sent.· Some commands take the controller longer to process than others meaning extra long delays for data not requiring it.· In my routines the busy flag is read allowing the next byte of data to be sent immediately upon the LCD being ready to receive it.· I have also had need in the past to read data stored in off-screen memory in the LCD.· Nonetheless, it is important to understand how to do this if you plan on reading any data.· Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
50 72 6F 6A 65 63 74 20 53 69 74 65
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*