Using PIC16C5X microcontrollers as LCD drivers Al Lovrich Logic Products Division Microchip Technology Introduction This application report describes an LCD controller implementation using a PIC16C55 microcontroller [1]. We start by an overview of LCD devices and their theory of operation followed by software implementation issues of the controller. The source code for controlling a multiplexed LCD display is included in the appendix. background Liquid Crystal Displays (LCD) are modelled as a capacitor with one side connected to the ground (Common Plane) and the other side connected to the controller (Segment). The segment is then turned on by applying a voltage of opposite polarity to the ground signal. To turn the segment off a voltage that has the same polarity as the common plane is applied. Internally the LCD uses an electrochemical process to display the segment. Driving a liquid crystal display at direct current (DC) will cause permanent damage the display unit. In order to prevent irreversible electrochemical action from destroying the display, the voltage at all segment locations must be reverse polarity periodically so that a zero net voltage is applied to the device. This process is referred to as AC voltage application. There are two LCD driving methods available: Static driving method and multiplexed driving method. Conventional LCDs have separate external connections for each and every segment plus a common plane. This is the most basic method that results in good display quality. The main disadvantage of this driving method is that each segment requires one liquid crystal driver. The static driving method uses the frame frequency, defined as a period of the common plane signal, of several tens to several hundred Hz. A lower frequency would result in blinking effects and higher frequencies would increase power requirements. To turn a segment on, a voltage that has an opposite polarity to the common plane signal must be applied. To turn off a segment a voltage that is of the same polarity to common plane signal is applied. This drive method is universal to driving LCD segments. Figure-1 shows an example of this driving method. Multiplexed LCDs maintain their liquid crystal characteristics. These are low power consumption, high contrast ratio under high ambient light levels, and reduce the number of external connections necessary for dot matrix and alphanumeric displays. The multiplex driving method reduces the number of driver circuits, or microcontroller I/O pins if a software method is used. The method of drive for multiplexed displays is Time Division Multiplex (TDM) with the number of time divisions equal to twice the number of common planes used in a given format. In order to prevent permanent damage to the LCD display, the voltage at all segment locations must reverse polarity periodically so that zero net voltage is applied. This is the reason for the doubling in time divisions; each common plane must be alternately driven with a voltage pulse of opposite polarity. The drive frequency should be greater than the flicker rate of 25Hz. Since increasing the drive frequency significantly above this value increases current demand by the CMOS circuitry, an upper drive frequency level of 60Hz is recommended by most LCD manufacturers. We have chosen a drive rate of 50Hz for this application report which results in a frame period of 20 ms. The most commonly available formats are 2x4, 3x3, and 5x7. In this report we use a 2x4 format LCD to display hexadecimal digits. LCDs are sensitive to Vrms (root mean squared voltage) levels. Different LCDs have different characteristics; figure-2 shows a typical voltage vs relative contrast characteristics. Notation on curve shows operating points for multiplex operation with threshold voltage set to 1.7 Vrms. The curve is normalized and assumes the viewing angle is 90 degrees to the plane of LCD. It is possible to move the operating point of the LCD by applying voltage to the LCD, thus providing for contrast control. Figure-3 shows a simple circuit to accomplish this. To better understand multiplexed LCD control it is best to look at the general case. The segments in a multiplexed LCD are arranged in an X-Y grid form as shown in Figure-4. The common plane signals maintain their relative shape at all times, as shown in Figure-5. To turn on segment 1 (SEG1), we need to apply a voltage Vd, such that Vs+Vd turns the segment on and Vs-Vd turns the segment off. Note that the segment signal Vd is symmetrical. This is a consequence of the intervals that the common plane signal is not present at all times. Use of nonsymmetrical waveform will result in a higher Vrms present on the unaddressed segments. The symmetrical nature of the waveforms theoretically result in a zero DC voltage levels. CMOS drivers (e.g. microcontrollers) operate at 0 to +5V levels (rail voltage levels). This would require driving voltages beyond the range of operation. This constraint is addressed by a technique referred to as "level shifting" or "biasing". Level shifting allows application of voltages in the range of 0 to +2.5V, which is compatible with these drivers. This would require an additional voltage level of +2.5V, which can be implemented through a simple resistive voltage divider circuit. Implementation The ideas presented in the previous section can be applied to any size multiplexed LCD display. In our implementation we used a 4-digit LCD from Occular Inc. The circuit diagram used in this application report is shown in Figure-6. Each I/O pin on the PIC16C55 device controls the state of two segments (see Figure-6) which requires a total of 16 I/O pins. The reference voltages are generated through a simple resistive voltage divider circuit. The 0 and +V levels are generated by taking advantage of PIC16C5X I/O pin set to input, which tristates the voltage level seen on the pin. This method uses 4 I/O pins to generate the proper voltage levels. Figure-7 shows the truth table for generating the voltage levels. Figure-8 shows how to create a bitmap for different digits. Figure-9 shows the waveforms generated for the accompanying software which implements a hexadecimal counter. Conclusion In this application report we have demonstrated the use of PIC16C5X devices to implement a simple LCD controller. As discussed earlier, it is important to keep the generated DC voltage to a minimum to extend the life of the LCD. Ideally one should switch all the I/O lines simultaneously, however a software implementation of the LCD controller will necessarily introduce a delay which is proportional to the instruction cycle of the microcontroller. Therefore it is necessary to keep the switching time to a minimum. Our implementation introduced xx mV of DC voltage on the segment lines which is below the manufacturer's recommended DC offset voltage of 60 mV. References [1] PIC16C5X Data Sheet, DSxxxxx, Microchip Technology, 1993