is a preferred medium of interface when dealing with embedded systems.
It can display both numbers and characters. Further, the graphical LCD
(GLCD) is even better, as it can display texts, plot curves, display
pictures. In the present context, graphical LCD (GLCD) refers to 128x64
pixels monochrome LCD (shown below, blue/white).
Why build serial interface?
One issue with LCD is that they need lot of micro controller pins: -
1. Character LCD needs 6 pins for control (4 wire mode).
2. Graphics LCD needs 14 pins!!. Graphics LCD only have 8-bit mode :-(
Lets take an example of controlling a graphical LCD with a 28-pin controller (dsPIC33FJ128MC802):
1. Power pins of microcontorller = 7 pins (MCLR, Vss, Vdd, Vss, Vcap, AVss, AVdd).
2. Crystal = 2
3. Programming = 2 (PGD, PGC). Though, these pins can be used for final application, but not while debugging the circuit.
Left out pins = 28 - (7+2+2) = 17.
we use 14 pins for GLCD, pins left for other tasks = (17-14) = 3. That
is impractical for any application. So effectively, we could as well
decide not to use 28-pin device for GLCD.
is that, if your controller is 3.33V, you will have to read the LCD
data sheet and make sure that the VIH and VIL are OK for 3.33V inputs.
2 Wire serial interface
I was inspired with the 2 wire -- clock and data scheme using 74HC595 very famous to drive character LCD. Please refer to this link (Bill's version): -
Advantages of this scheme are: -
1. Only 2 wires required ( additional 2 wires for 5V and GND). There are 1 wire version as well for LCD interface, but that is more complex. If we extrapolate the trend, we could also achieve 0-wire scheme (say by using bluetooth), but that is even more complex.
2. Interface board does not need its own software, since, the design is purely hardware based (shift register).
3. The serial interface enables 3.33V controller to be used, since VIH and VIL of 74HC595 is compatible with 3.33V.
4. Cheaper in the way that lot of wires and connectors are eliminated and makes easier to use any controller pins if the design is changed.
1. Might slow down the LCD a bit, but that is negligible as LCD users are human; we are slower than any microcontroller.
2 Wire serial interface for Graphical LCD
Click on the image to see a zoomed version. The 20-pin header is the one that will fit with connector on LCD module. Pleas refer to the LCD module data sheet (bottom of web page) to know the pin description of LCD module.
The board design can be optimized if a true 2-layer is used. I preferred to use a 1-layer (solder layer = blue traces), and hence, the other layer (component layer = red traces) are minimal which are supposed to be replaced with jumper wires.
Picture of real hardware
Though I made the hardware drawings, the PCB guy could not give me a PCB within 2 days. So, I made my own board based on the designed hardware.
Please note that the solders are mostly straight line and hence is easier. Also, compare the soldered board vs board layout above. It all same.
The 2 small caps are 0.1uF for decoupling purpose. The big cap is 1uF (though can be reduced to 0.1uF) is for resetting the LCD module after power ON. Please refer to LCD data sheet and my hardware design.
Entire setup. Note the 4 wires going from controller board to LCD -- +5V, GND, CLK, DATA.
LCD and interface board.
How does the interface board work?
I am too lazy to explain. Basically compare the software code and hardware design, and you will figure out..
Please download the zip file from the bottom of page. The code is written for dsPIC33FJ128MC802 using MPLAB X and XC16 compiler. If you have not yet used the (free) MPLAB X IDE from Microchip, this could be your chance. Otherwise, create another project using MPLAB 8 and source codes from the zip file.