Problems with Microcontroller Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you the Codes for Registered Members of this site only, at free service...Follow Me.

Serial LCD for Low Pin-Count PIC Microcontrollers using 74HC595 Shift Register

Introduction


HD44780 based character LCD displays are very popular among hobbyists. They are easy to interface with microcontrollers and most of the present day high-level compilers have in-built routines for them. However, the bad part is at least 6 I/O pins of microcontroller are required to use them in your project. Therefore, they are not applicable for 8-pin devices like PIC12F series microchips. The aim of this project is to allow LCD interfacing to such devices using 3-wires. I am going to demonstrate this with PIC12F683 microcontroller. The character data or command from the microcontroller will be transferred serially to an 8-bit serial-in parallel-out shift register (74HC595), and the parallel output will be fed to the LCD driver pins.


About 74HC595

74HC595 is a high-speed 8-bit serial in, serial or parallel-out shift register with a storage register and 3-state outputs. The shift register and storage registers have separate clocks, SH_CP and ST_CP respectively. Data in the shift register is shifted on the positive-going transitions of SH_CP, and the content of shift register will be transferred to the storage register on a positive-going transition of the ST_CP. If we tie both the clocks together, the shift register will always be one clock ahead of the storage register. The 8-bit data of the storage register will appear at the parallel output (Q0-Q7) when the output enable (OE) is low.
 

In this project, SH_CP and ST_CP are tied together. So, if we want to receive a serially transferred 8-bit into parallel form at Q0-Q7, an extra clock pulse is required after transmitting the 8-th bit of serial data because the clocks are tied and the storage register is 1-clock behind the shift register.

HD44780-based character LCD

All HD44780 based character LCD displays are connected using 14 wires: 8 data lines (D0-D7), 3 control lines (RS, E, R/W), and three power lines (Vdd, Vss, Vee). Some LCDs may have LED backlight and so they may have additional connections (usually two: LED+ and LED-).

Pin Description

Control pins
The control pin RS determines if the data transfer between the LCD module and an external microcontroller are actual character data or command/status. When the microcontroller needs to send commands to LCD or to read LCD status, it must be pulled low. Similarly, this must be pulled high if character data is to be sent to and from the LCD module.

The direction of data transfer is controlled by the R/W pin. If it is pulled Low, the commands or character data is written to the LCD module. And, when it is pulled high, the character data or status information from the LCD registers is read. In this project, we will use one way data transfer, i.e., from microcontroller to LCD module, so the R/W pin will be grounded permanently.

The enable pin (E) initiates the actual data transfer. When writing to the LCD display, the data is transferred only on the high to low transition of the E pin.



Power supply pins
Although most of the LCD module data sheets recommend +5V d.c. supply for operation, some LCDs may work well for a wider range (3.0 to 5.5 V). The Vdd pin should be connected to the positive power supply and Vss to ground. Pin 3 is Vee, which is used to adjust the contrast of the display. In most of the cases, this pin is connected to a voltage between 0 and 2V by using a preset potentiometer.

Data pins
Pins 7 to 14 are data lines (D0-D7). Data transfer to and from the display can be achieved either in 8-bit or 4-bit mode. The 8-bit mode uses all eight data lines to transfer a byte, whereas, in 4-bit mode, a byte is transferred as two 4-bit nibbles. In the later case, only the upper 4 data lines (D4-D7) are used. This technique is beneficial as this saves some input/output pins of microcontroller.
For further details on LCDs, I recommend to read these two articles first from Everyday Practical Electronics magazine : How to use intelligent LCDs
Part 1: http://lcd-linux.sourceforge.net/pdfdocs/lcd1.pdf
Part 2. http://lcd-linux.sourceforge.net/pdfdocs/lcd2.pdf

Circuit Diagram
The hardware part of this project is fairly simple. The challenging part is to write the driver software that is responsible for a proper sequence of operations required to serially transfer character data and command to 74HC595 serial-in parallel-out shift register. The shift register parallel output is then connected to LCD data lines (D4-D7) and RS control pin. This arrangement requires 3-pins of microcontroller to display character data on a parallel LCD display: 2 pins for providing Clock and Data to 74HC595, and 1 pin for enable control (E) pin of LCD module. Since the data transfer uses 4-bit mode, any 8-bit command or character data is sent in two steps: send the higher nibble first, and then the lower nibble. The R/W control pin is grounded, and therefore no data or status read from the LCD module is possible in this case. 


The SH_CP (11) and ST_CP (12) clock inputs of 75HC595 are tied together, and will be driven by one microcontroller pin. Serial data from microcontroller is fed to the shift register through DS (14) pin. OE (13) pin is grounded and reset pin MR (10) is pulled high. Parallel outputs Q0-Q3 from 74HC595 are connected to D4-D7 pins of the LCD module. Similarly, Q4 output serves for RS control pin. If the LCD module comes with a built-in backlight LED, it can simply be turned ON or OFF through LED control pin shown above. Pulling the LED pin to logic high will turn the back light ON. I soldered this circuit on a general prototyping board (shown below).





No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Recent Comments

Popular Projects

Give Support

Give Support
Encourage Me through Comments

Microcontroller Projects

Total Pageviews