Practically speaking it is much easier to use a preassembled module consisting of a controller and glass. But if you ever wondered how the controller actually drives the segments, read on.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Identifying the Pins
Using a two digit LCD glass I came across recently I explored how to drive it. None of the documentation I could find really spells out how they are controlled. And there seems to be a real dearth of identification on any of the glasses I've looked at. As in non-existent. If the glass you're using is in an operating circuit, use a 'scope to look for the pins with the complex pattern shown in the COM0 and COM1 figures. Connect the 'scope ground to circuit ground. These are the COMs.
All the segment pins will have simple square waves. To identify the pins remove the glass from the circuit and connect one side of low voltage AC to a COM and apply the other side to the pins one at a time to find the segment pairs. A few volts AC will be enough.
If you don't have the luxury of a working circuit to start with, experiment with the AC, applying it to various combinations till you see a pattern. Stay away from using elaborate glasses at first, it gets way too complicated.
Step 2: Exploring the Matrix
This particular glass has 2 back plane (COM) pins and 8 segment pins, 4 per digit. Glasses with more digits or figures require more back planes but I will be exploring this 2 back plane glass only. And only the left digit. The right digit is just more of the same. Glass pins 3-6 are for the right digit.
Each pair of segments is controlled by one SEG pin and the two COM pins. Segments c and e of the left digit are controlled by pin 10 plus COM pins 1 and 2. Segments f and g are controlled by pin 9 plus the COM pins and so on. All the segments are multiplexed between the individual segment pins and the COM pins. Segment d alone is controlled by pin 7 and COM1.
This is quite different than a standard LED display plus while LEDs use DC, LCDs require AC. In fact if you apply DC to an LCD for very long it will damage the glass.
The 2 COMs of a two back plane glass require 3 different voltage levels to operate: Vcc, Vcc/2 and Gnd. Since the glass draws extremely little current (think RC with high R and low C), Vcc/2 is easily achieved with a resistor divider with both ends controlled by the uP. The center points of the dividers are connected to the COMs. With one end of the divider high and one low the (1,0 or 0,1) the divider output is Vcc/2. Both high (1,1) the output is Vcc, both low (0,0) the output is Gnd.
Step 3: It's All About the Timing
In t1 COM0 is Vcc, t2 and t3 are Vcc/2 and in t4 COM0 is Gnd. COM1 is identical to COM0 but 180 degrees out of phase with COM0; t1 is Vcc/2, t2 Gnd, t3 Vcc and t4 Gnd. With more than 2 back planes you will have more divisions in every frame (period). This frame is 40 mS wide or 25Hz. The documentation says that is too slow but it works OK. Any problems just shorten all the times to increase the frequency, it’s a looks issue; with the frequency too low you will notice the flicker, too high causes ghosting.
The COM patterns remain unchanged regardless of the digits displayed.
PORTD.3=1; For 10mS. Then
PORTD.3=0; For the next 10mS and so on to produce the above waveforms.
Once you have the above waveforms functioning forget about them. From now on you just have to manipulate the segments.
Step 4: Looking at One Segment Pair
The segments require Vcc or Gnd. Even though only DC voltages are present WRT (With Respect To) Gnd, the segments see AC from the presentation of the voltages at the proper time (COM WRT SEG). If you connect the 'scope ground to a SEG pin and the probe to a COM pin you will see the AC RESULT waveform. The Alternating Current comes from the SEG in relation to COM0. Imagine putting the negative lead of a voltmeter to the SEG terminal, and the positive to COM0. In t1 the meter will read +5VDC (0V and 5V). Now in t4 the meter will read –5VDC (5V and 0V).
That is how the AC is realized. You don’t need to think about that any more; you only need DC levels at the proper time.
Step 5: Controlling a Segment Pair
Timing of the voltages is the key to controlling the segments. Each segment pair requires its own uP pin and follows this timing pattern:
t1 t2 t3 t4
Gnd Vcc Gnd Vcc both segments on
Vcc Gnd Vcc Gnd both off
Vcc Vcc Gnd Gnd 1st segment on
Gnd Gnd Vcc Vcc 2nd segment on
For the segments ab, ce, fg and d the 1st segments are a, c, g and d. 2nd are b, e and g.
0101 = both segments on
1010 = both off
1100 = 1st segment on
0011 = 2nd segment on
All the SEGs and COMs are controlled in the same t1-t4 time frame based on a 10 mS interrupt.
Actually, turning the segments on is easy. Just apply 10V p-p across a SEG pin and either COM pin and they will turn on. The tricky part comes in turning them off. For this you need 5V p-p for the unwanted segment at the proper time. Apply the various waveforms above and it all comes out in the wash.
Step 6: Putting It All Together
Controlling all the segments gets a little confusing. Each segment pair (d is considered a pair here) requires its own group of 4 bits, one each for t1-t4. Since there are 4 sets of segment pairs, 16 bits of refreshed data are needed for every frame. And that's just for the one digit.
So to display "4", send 0xC35A to the segment terminals. The code uses Switch statements. One function for the COMs has a single Switch statement and runs whenever the program is running. Then another function with 4 Switch statements (one for each pair of segments) which gets the refreshed data. All Switch statements key off the same 10mS interrupt to keep all the uP pins timed correctly.
Take a look at the code and hopefully it will all make sense. It's written in C using Code Vision. There is a lot of extraneous stuff, SPI (Serial Port Interface) etc. Initially I thought I was going to have to produce four voltages for each pin to get the "result" pattern. So I connected a DAC to get the various voltages only to find they weren't needed. Too lazy (project fatigue!) to take it out. Really it's all about producing the proper levels at the proper time.