Wednesday, May 12, 2021

How to Test and Explore an LCD Segment Display

 


Welcome to my first article in "Dabbling in Electronics."

I was working on a project using a Microchip PIC microcontroller to drive a bare, 4-digit, LCD segment display chip, and I wasn't seeing anything displayed. I began to question whether I damaged the LCD segment display. But I didn't know how to test it without risking damaging it. This article is about what I learned and what I implemented to test my LCD.

Googling turned up this Stack Exchange article with both an explanation and a solution in one of the answers that I knew I could implement.

What's important about testing bare LCDs is that they are driven by AC waveforms. A DC bias will damage an LCD. What I needed was a 3V square wave generator. I didn't have a signal generator, but the Stack Exchange article pointed out that I could generate one with a microprocessor.

The Circuit

The following schematic shows the quick-and-dirty circuit I threw together. I had a PIC16LF19156 microcontroller available (it was what I was trying to use to drive the LCD in the original project that wasn't working), so I used it, but any MCU running at 3V would work with two available digital output pins would work. The PIC model I used operates only between 1.8V-3.6V, so I couldn't test 5V LCDs with it. If I had used a PIC16F15156 (notice the "F" instead of "LF" in the middle of the part number), the circuit would operate with a Vdd of either 3V or 5V, because the latter PIC will operate at 2.6V-5.5V.

The idea is to generate two pulse trains with a 50% duty cycle that are out of phase. The difference between the two outputs is an AC square wave. Series capacitor C2 in the circuit serves to block any DC from getting to the LCD. I was aiming for a 250Hz wave. That means the square wave has a period of 4 milliseconds.

The Firmware

The body of the infinite main loop was trivial:

  1. set output bit A to high and output bit B to low
  2. delay 2 milliseconds
  3. set output bit A low and B high
  4. delay 2 milliseconds

This being a PIC, I used Microchip's MPLAB X IDE to write and download the firmware via a Pickit 4 in-circuit programmer/debugger connected to the five-pin header J1.

Testing an LCD with the Tester

Each pixel in an LCD has two external connections: a common pin (COM) and a segment pin (SEG). (By "pixel" I mean a displayable element of the LCD. It might be a numeric segment, a decimal point, a colon, or a low battery indicator, for example.) I needed to test a Lumex LCD-S401M16KR 4-digit, 7-segment display with some decimal points and a colon. It is a multiplexed display with 12 pins divided into 4 COMs and 8 SEGs for a total of 32 segments. Its lead spacing is only 1.0mm. I tried spreading out the leads to plug them into a breadboard, but I just couldn't make it work, so I found a breakout board and ordered a short PCB run.

The way to test the LCD is connect one of the two MCU outputs to a COM pin (it doesn't matter which output) and the other one to a SEG pin. Just make sure there is a series capacitor in one of the output connections. Since, for this LCD, all COM-SEG combinations are used internally, All I had to do to test the chip.

The next picture shows the pixel that was displayed by signalling the COM0-SEG0 pair (leads 1 and 5).



Another way a tester like this can be used is on an unknown LCD. By systematically signalling pairs of LCD pins to see what displays, it is possible to reverse engineer which are COM pins and SEG pins and discover a mapping between COM-SEG pairs and display pixels.

I intend to retarget the circuit to use an 8-pin, 3V/5V PIC12F1572, because I bought a few for some other projects that don't need an MCU with many pins and the PIC I used in this article is overkill and more expensive. I think I may use this tester again, so I intend to directly transfer my breadboard design to a solderable breadboard such as the ElectroCookie.

Updates

5/16/2021 - Circuit output seen on an oscilloscope

I broke down and bought a low-end, 100MHz, digital oscilloscope to help debug another project. Here's a view of the nice square wave produced by the circuit. The picture is high resolution, so if you find a way to zoom in on it, you should see at the bottom of the scope that voltage peak-to-peak (Vpp) is ~6V and RMS voltage (Vrms) is ~3V, as desired. The frequency of the wave as measured by the scope is 248-249Hz, more than close enough to the target 250Hz.


5/18/2021 - Changed to a smaller, cheaper MCU

I wanted to commit the square wave generator to a soldered board, but, as I said earlier, I thought the 28-pint PIC16LF19156 MCU I used was sort of overkill and expensive for the purpose (~$2.10 quantity 1). On top if it, that MCU and cannot be used at 5V to test 5V LCDs. So, I reimplemented the circuit using an cheaper (~$0.80 quantity 1), 8-pin PIC12F1572 that will operate at 1.8V to 5.5V.

I bought a few of these PIC12s because they are dirt cheap and I wanted to play with low-pin count applications, including simple controlling of 4-5 LEDs in a decorative, animated solar garden light, so I thought I could spare one. I will socket it in the soldered board, though, just in case I need to borrow it for a different project.

Here's the new breadboard with an oscilloscope showing the output, followed by a closer shot of the breadboard. I like how sparse it is, just an MCU, two capacitors, and an in-circuit programming header. But I might later add a potentiometer, read by an MCU analog input to control the frequency. I might also play with using the pulse width modulation (PWM) peripherals to generate the complementary DC square waves instead of doing it in a loop with delays. If I do, I will write about it in another article rather than an update here.



5/27/2021 - Final update, committed to permanent circuit

This will be the final update on this article. I did one last thing with the test generator. I committed it to a permanent circuit board using an ElectroCookie-brand, solderable breadboard.

Boards like the ElectroCookie are laid out with the same hole spacing as a breadboard and have columns electrically connected just like in a breadboard. To make the soldering easier, I did it in three waves: wires, capacitors and socket, then pin headers. Labels were to refresh my memory on how to use the circuit in the future. I also socketed the PIC in case I needed to borrow or replace it in the future.


As you can see by comparing the breadboard and soldered board, the connections transfer exactly, even with the same row and column labels. The only noteworthy difference is that the power busses have more holes.

Well, that's it for this article. I may revise this circuit to use the pulse with modulation (PWM) module of the PIC and control frequency with a potentiometer on the currently unused pin 5 (port RA2), but if I do, I'll discuss it in a new article.