In a low-cost microcontroller-based design, it's possible to generate the negative voltage supply required to bias extended-temperature character LCD modules without a dedicated voltage inverter IC. Using fiv inexpensive general-purpose npn switching transistors (2N3904 or equivalent), two storage capacitors, a handful of resistors, and a periodic square wave generated by the microcontroller, an elementary switched-capacitor or "flying-capacitor" negative voltage supply can be realized.
The figure details an HC11's "timer output compare" that generate a 1-kHz square wave. When OC2 goes high, Q1 and Q2 are switched on, charging C1. Q5 also turns on, turning off Q3 and Q4. When OC2 goes low, Q1, Q2, and Q5 are shut off. Q3 and Q4 then are turned on via pullup resistor R5, which transfers C1's charge to C2, and inverts its voltage with respect to ground. The cycle is repeated, thus forming a charge pump. A 1-kHz, 50% duty cycle produces a peak negative voltage output of about −3.8 V, with a 4-mA load.
An elementary switched-capacitor, or "flying-capacitor," negative voltage supply can be achieved using a minimal amount of low-cost parts. Here, an HC11's "timer output compare" will generate a 1-kHz squarewave.
By increasing or decreasing the duty cycle of OC2, the output voltage, and thereby the contrast, may be varied. This would eliminate a digital or resistive potentiometer. A switch attached to port PC0 is used to increase or decrease this contrast. Also, by using the LCD module in 4-bit mode, only 8 control lines plus the "timer output compare" output are needed for full LCD control. Adjusting the values of R7 and R8 may be necessary to optimize the contrast range for a particular display type and viewing angle.
The software listing details assembly code for a Motorola HC11 8-bit microcontroller. It consists of three subroutines and an interrupt service routine. SWCAP_ON enables the OC2 squarewave output, at a 1-kHz rate and a 50% duty cycle. SWCAP_OFF disables OC2. SWCAP_INT is the interrupt service routine. For a 50% duty cycle, the routine is called every 500 microseconds, and takes 47 cycles. SWCAP_SWITCH increments the duty cycle of TCMP in 5% increments. The routine limits the duty cycle between 20% and 80%. When the switch is pressed while at an 80% duty cycle, it jumps to a 20% duty cycle. At a 20% or 80% duty cycle, SWCAP_INT generates a minimum interrupt period of 200 µs (200 µs ON / 800 µs OFF or vice versa).