Yes, you can control simple bare-bones LCD displays using just an Arduino. No driver boards or additional chips are required. If you have controlled a 7-segment LED display directly from an Arduino, you can do the same with an LCD.
However, there are a few tricks to doing it correctly. It's easy really. But I was trying to do it with mystery, undocumented displays. As you might guess, much fun and hilarity ensued.
Why a Bare LCD
I have plenty of working LCD displays in all sizes and types. They are easy to hook up and simple to control with an Arduino. Why would I want to use a bare LCD instead?
Well, because I have them and because I didn't know how to use them. It was a challenge.
Over the years I have scavenged a large collection of LCD displays out of broken electronic devices. They still worked when I salvaged them, but I had no idea how to
power them or control their displays. They have no chips or circuitry attached. They are just the bare LCD display with a bunch of pins sticking out.I wanted to use them in an Arduino project, but it turned out to be a little more difficult than I expected. The process itself is not very difficult. But there is a lack of information about using them. While there are thousands of tutorials on using the equivalent LED versions, there are only a handful of good tutorials about driving bare LCDs.
TOO COMPLEX: Reusing the complex graphical LCDs is beyond my current skill level, so I mostly use them for my craft projects They have a unique, shaded and semi-transparent appearance that's difficult to find in commercial craft supplies. And some of them contain lots of hidden diffusing and reflective sheets as well as Fresnel lens, all useful items for a crafter. The LCDs are also polarizers, a fun thing to play with.
First Tests
One day, with a pile of those stripped down LCD displays sitting on my workbench, I decided to apply some power to them just to see what happened. They were, for my purposes, already dead so I couldn't hurt them any more. I was just curious to see if I could revive them and maybe use them in a project.
I used the same technique as I do when I'm trying to a reverse-engineer a mystery LED display. I attached the ground wire from one battery to a pin on the LCD, then dragged the positive wire quickly along the other pins of the LCD.
To my surprise and delight, it worked. I saw a flicker on some of the segments. So I upped the power to two batteries (3v instead of 1.5v) and repeated the process. More segments darkened, and it worked on several different displays. So I tried three batteries (for 4.5v) and tried again. None of them exploded or emitted smoke (better than some of my experiments with mystery LEDs).
Now that I was sure the displays still worked, I needed to find out more information about them. Is the voltage standard, do I need a current limiting resistor for each segment (like for an LED), is it safe to apply continuous power or do I need to pulse it? I started googling and came up empty for quite a while. I was beginning to wonder if there was a reason everyone used LEDs instead of LCDs. Maybe it was really difficult.
Voltages and Waveforms
I learned a lot about LCDs in general. But none of my usual mentors for hobby electronics had detailed instructions for controlling bare LCD displays. The closest I could find was Adafruit's tutorial on using their "LCD light valves" (also available at Amazon) The light-valve is like one big LCD segment (pixel), basically the lens from from welding helmets (affiliate links). It was helpful information, but it wasn't really what I was looking for.
However, if I could figure out how to correctly turn on one segment, I could probably use the same techniques with a 7-segment display. In the Adafruit tutorial, they simply attach a battery to to the display. A resistor bridges the +/- wires. However, they also caution against running the valves for more than a few minutes without using an AC square wave. They linked to some instructions on driving TN shutters. I didn't even know what a TN shutter was and I didn't understand the schematics or the notes about digital logic. But it was enough to improve my Googling.
Next, I filtered Digikey results to show me bare bone LCD displays and looked at their datasheets. Most operated on 3v or 5v, so maybe these voltages were standard for powering LCD displays. And LCDs draw a tiny amount of power, like microamps or even less. That was good. I have Arduinos that can output 5v and 3v at several milliamps, so I had the power requirements met.
The datasheets also said I had to send the LCDs a waveform (square) of some sorts in order to operate them safely. They also seemed to indicate that the waveform had to be AC, not the DC that Arduinos use. While I understood the concept, I had no idea how to generate an AC waveform with an Arduino. Maybe I was going to have to buy a special chip or board.
Doing It With Chip Assist
Luckily, my Googling and YouTubing improved with my new, yet still basic, understanding of LCDs. I found a video from David Watt about driving a bare LCD with an Arduino that sent commands through a "4055 BCD to 7-segment" chip. He also noted that the LCD display requires an oscillator to create a waveform.
Robert's Smorgasbord provided a detailed example of using an Arduino to control a specialized LCD driver chip (the AY0438). The explanation of how to use registers and trigger signals to load data into the chip then send it to the LCD for display is particularly helpful. He has a second video where he experiments with voltage and frequency to see their effect on the displays.
The videos were very informative, but both examples required the use of a chip in addition to the Arduino. That extra component bothered me. If I needed another component why not just use an LCD display that already had the driver chip and a library to run it? I already had several of those, and they worked great. But that wasn't the point.
I still wanted to know if I could drive a bare LCD with just an Arduino. If I was going to drive a display with 40, 50 or 100 segments I would definitely need specialized driver chips. But I only wanted to control a single digit display (maybe two), so I should only need seven I/O pins plus maybe power and ground. Even my tiny microcontrollers have that many pins.
Only Using an Arduino
Maybe my vocabulary was getting better, or maybe the GooTube algorithms figured out what I was looking for. Either way, they led me to the EEVblog. As part of making a custom LCD screen, he explains (in his excited, entertaining way) the process of how LCDs are powered and controlled.
His explanation of these foundations of LCD operations taught me the final pieces about how to correctly power and drive a bare LCD display. It took multiple watchings of two of his videos, but I finished with enough knowledge to successfully power and control a 7-segment LCD screen using nothing more than an Arduino.
The first video explains the basic types of LCDs and talks about how to power them. It confirmed that they have a "common" pin just like LEDs. It also confirmed that LCDs need an AC current. Or, as he hinted, maybe just a workable equivalent. More importantly, he explained why.
LCDs are capacitive, they hold a charge. That's why they sometimes stay opaque for a short while after power is removed. Even though the charge dissipates after a short time, it is better to send a reverse polarity charge. If the positive and negative signals average out to zero over time, the LCD will not build up a charge. You probably won't damage the LCD by short tests with a single polarity. But the LCD can be damaged by driving it with a single polarity for a long time. That made sense to me.
He also promised to explain exactly how to drive an LCD display with nothing but an Arduino in the next video. I watched it immediately.
And as promised, in his video on how to drive an LCD (after more info about driver chips) he does explain in detail how to use an Arduino to directly control and power an LCD display using no additional chips or circuits.
The part I needed, driving LCDs directly from an Arduino, is at the very end of the video and only takes a few minutes to explain. But the entire video is very informative and worth watching. (BTW, he also has an excellent tutorial on driving old VFD displays with an Arduino)
Go For It
Tricky Tricky
I also discovered several more of this type of LCDs attached to small PCB boards. The displays can be cut away from the PCB boards and used as nice 3 digit displays. I think, with a little more research, I could find an easy standardized way to send a serial signal to the driver board. That would definitely use fewer pins on the microcontroller. So I'm going to save a few of these displays intact.
Coding, Arrays and Bit Banging
Summary
- You can power and control bare 7-segment LCD displays using only an Arduino
- Many LCDs operate on 3v to 5v at the microamp level or lower
- Over powering an LCD can cause ghosting and damage the display over time, but it probably will not go "Pop!" and start smoking like an LED
- None of the tutorials show current limiting resistors like with LEDs
- Many LCDs, especially simple 7-segment displays, have a single "common" pin, much like the similar LED display
- Others have multiple common pins to control multiple layers of displays
- The common pin(s) can be used for power or for ground
- The pin-out and wiring for LCDs is similar to the equivalent LED display
- LCDs need a square wave that averages to 0v (Applying steady or pulsed power will eventually kill an LCD)
- You can create a square wave that is safe for LCDs by toggling the digital I/O pins of an Arduino
- First, set the common pin to pinMode(#, INPUT_PULLUP) and set the segment's pin to pinMode(#, OUTPUT) and send a digitalWrite(#, LOW)
- Then flip the input to an output and vice-versa.
- Use a delay() value that gives you a steady display (2-8 works for most)
- Invert the pinMode() of both the common and segment pins
- Coding the Arduino to control an LCD is very similar to controlling the equivalent LED version, except you have to constantly toggle between input/output modes
- You can do the same thing with a Raspberry Pi
- Look for a part # and find a datasheet for your display if you can, it will save you lots of time
I see that you did INPUT_PULLUP as a substitute for OUTPUT and HIGH. While it does make sense if you don't want an accidental short circuit to harm your Arduino, it's not strictly necessary here. Using OUTPUT and HIGH will allow the segment to "turn on" a little faster too and not have the internal resistor dissipate power.
ReplyDeleteYes, that absolutely should work. It's much simpler and it was the first thing I tried. But I was getting odd behavior. The display did not update reliably. Some elements would keep displaying light gray "ghost" lines. It's like there was still a capacitive charge that had not been completely drained. So, I tried the INPUT_PULLUP technique and that worked. I did not have datasheet for the displays I was working with, so I wonder if there wasn't a master drain or reset line I needed to toggle.
ReplyDelete