Jaycar LCD Modules
Couple of weeks ago I wanted to add a display to one of my pic projects so I headed down to jaycar and purchased a simple LCD module. 3 screens later I’ll share the do’s and do nots on these screens and hopefully form a good howto on these babies.
Models covered: QP5515, QP5517, QP5518, QP5519, QP5520. Stay away from the mini version unless you have a ribbon cable clap, jaycar don’t.
Step 1: Connections
This is a vital step :). Messed up logic connections aren’t going to damage this unit but power connections are important!!! Look at the datasheet because connections do differ between different models, but usually pin1 = 5v and pin2 = 0v, GET THIS ONE RIGHT!
5v -> Pin1 ;Power
GND -> Pin2 ;Gnd
GND ->10Kpot -> Pin3 ;Contrast Adjust
RS -> Pin4 ;Register Select – Instruction/Data
GND -> Pin5 ;Write/Read
E -> Pin6 ;Write Enable
GND -> Pin10-7 ;4LSB data
Data7-4 -> Pin14-11 ;4HSB data
Power. On these modules this powers the controller, backlight(if app) and LCD screen so don’t worry about that A & K crap in some of the data sheets its already been done for you.
Contrast Adjust. This must be hooked up if anything is to be displayed on the screen as it completes the LCD circuit. A 10kpot gives good adjustment and can be replaced by a single resistor at a later stage. The LCD isn’t too fussy, I’m just using a 100k pot I had laying around . When you turn on the screen you should see some square boxes along the top row if you have the contrast set correctly.
RS. This pin tells the LCD whether we are writing an instruction(clear screen etc..) or a character(A B C 123 etc..)
R/W. Tells the LCD controller whether we are reading or writing to LCD memory. We will only ever be writing to memory so we can set this to gnd.
Enable. Setting this to high informs the LCD controller that our data is ready to be read
Data0-3. Used in 8bit communication mode. Will be set to gnd in our configuration for consistency.
Data4-7. Data lines.
Note: Making all these connections on a breadboard or the like can be time consuming and the LCD is sensitive to heat and static. So I suggest buying a 2 x 16pin header from jaycar also (they didn’t have 14pin ones when I was there) and some ribbon cable and connector. Solder one to the screen and one to some prototyping board with some dip legs so you can have the screen off the bread board and lots of room to make connections. The headers legs just aren’t wide enough to make it across the center of my breadboard thats why I made a little prototype attachment
Blown: If your power line is shorted to ground I’m sorry but that screen is now rubbish, there may be a way to repair it but for the meantime its broken, time to get a new one.
Step 2: Software
The LCD controller is based upon a Hitachi 44780 LCD controller (Datasheet http://www.datasheetcatalog.org/datasheets/400/81271_DS.pdf) and there are heaps of example code out there on how to get the thing running. Perhaps later I will post mine but for the mean time I will just leave some hints and notes how how to best get it working.
First you need to run the initialisation sequence. Follow the steps in the datasheet with gaps of around 100ms inbetween the first 3 instructions and 10ms in between the following pairs of instructions. Choclabs have some good example code here for PIC but its all assembler in the end http://www.choclab.eu/mtorrens/Files/LPM01-4bit.asm
If your having trouble I found it to be my Enable signal. The best sequence is as follows, set your data out and RS then call a function that puts E high, few nops, then low, so it pulses the enable line. We want the enable pulse to last about 1uS(thats heaps) whilst the data is stable.
where high in both Data & RS is to demonstrate that the line is stable and containing values, they may be of another value.
Once the initialisation has finished the data is going to be sent in pairs(4bits then 4bits), there doesn’t need to be a delay between 4bit pieces longer than 1uS, but once both instructions have been sent a delay of 1mS is needed before the next instruction.
The LCD controller does produce a busy flag whilst it is processing an instruction which is raised at the end of a data pair. You can use this to determine when to write to the screen but it will require an extra connection to RW to enable reading from the screen and the time savings will be minimal/of no real use when your first starting. I suggest just waiting 1mS after a data pair is sent until you are familiar with the unit.
Step 3: Troubleshoot
Its unlikely you will get this baby working first time so don’t be disheartened. It took me a few nights to get mine going. Just check the cables, make sure the screen is getting the signals. Keep the supply voltage around 4.7-5v and use example code on the web but make sure your pin assignment is the same as theirs and adjust as necessary.
Filed under: Builds, Electronics | 5 Comments
Tags: qp5515, qp5516, qp5517, qp5518, qp5519, qp5520