One of the limitations of the small 8 bit microcontrollers like the Atmel ATMega family adopted by the Arduino board, is the reduced number of I/O ports. Among the main advantages of these microcontrollers: they are cheap, robust and simple to program. Therefore, also Arduino or one of its clones are cheap as well.
Microcontrollers in industrial applications are frequently used to manage almost simple circuits dedicated to a single task. We might think that an AVR microcontroller – e.g. the ATMega328p adopted by the Arduino UNO boards – has the sufficient number of pins to manage an alphanumeric LCD. In a complex industrial machine architecture that is more than sufficient.
Thanks to the tons of Arduino users worldwide, we already know that the same ATMega328 microcontroller can do more than few basic functions. So why not many of them together?
In this first article we will propose to explore the power of the Arduino board with experiments, including circuitry and software, moving further to a high-level activity than a simple demonstration. Guys, with a little effort and few $$$ of components Arduino is the ideal tool to solve a lot of problems whereas other alternative solutions may be more expansive.
The Alphanumeric LCD for Arduino will be our first circuit: using only one component, and of course the LCD, we can povide our Arduino board with at least a 16×2 alphanumeric LCD display that we will use in all our future applications. This project consumes only three I/O pins, no matter what we decide to use, connected to a Shift Register. I have experienced that an alphanumeric LCD added to Arduino as a stable add-on devices is very useful during the debug phase of the sketches and gives much more options to our projects. Especially in case of unavailability of the Arduino USB port connected to the PC.
The shift register is an easy-to-manage component. We will dedicate a series of articles illustrating applications giving us the opportunity to develop circuits using one or more shift register saving a lot of I/O pins on our Arduino board.
Therefore you should expect that the software part (that is, the Arduino “Sketch”, more properly named firmware) covered extensively in the second part of this article, should be a bit complex. But the result is fascinating.
We should use a cheap parallel shift-out registers (it costs, depending on the country, a variable price around half dollar): the 74HC595
As a matter of fact there are two types of shift registers: shift-in (don’t worry, in future we will use this too) and shift-out parallel registers.
Regardless of the type of shift-register we are using, we need only three pins in our microcontroller. One pin is used for the serial data and the other two act like a clock to notify to the shift-register when a bit is ready to be shifted (shift-out) or the microcontroller is ready to acquire a new bit for reading (shift-in).
Another important aspect is the name of the component: register. In the assembler language a register is usually a place where a series of bits are stored for special purpose. In fact, the shift-registers not only are able to shift in one direction a certain number of bits but the bit status of every pin is persistent until another byte has not been completely sent (or received). This is perfect for us, as we need to write bytes to the LCD device managing a timing series of steps (e.g. writing a new character, moving the cursor, etc.)
At this point, the LCD Device will be connected with the 8-bits of the shift register (you can see the schematic and the circuit layout for the circuitry details).
So, what happens when we send a set of data to the LCD Device?
Our resulting sketch will be almost simple.
The most inspiring source to make this project comes from a blog post by Chris Parish proposing a similar circuit in 2010. Chris also provided a first modified version of the standard Arduino LCD Library supporting the shift register features. In 2010 Arduino libraries to manage shift registers were based on the 74LS164 component.
This arduinoshiftreglcd distributed on Google code was the only reference trying to solve the problem but included some bugs in the data timing and was not working properly.
The very valuable work by Chris consisted in modifying the 2010 version of the LiquidCrystal library distributed with the Arduino IDE (it was not supporting the shift register at all) and thanks to his work, in January 2010 the ShiftLCD Arduino library was born.
We suggest to download the ShiftLCD library from the link provided by this article. This version of the library implements the original Chris Parish ShiftLCD library with a couple of patches granting the compatibility with the most recent Arduino IDEs.
In the mentioned circuit implemented in 2010 by Chris Parish, you can find also the use of a high impedance MOSFET to control the LCD backlight. We have removed this component from our circuit because it proved useless with the cheap LCD devices working fine with or without backlight support. Note that the devices without the backlight support cost about the half compared to those with it, anyway offering a good visibility.
In the second part of this article we will consider the usage of this tool with some software developed to simplify and shorten the sketches with the LCD device as part of our Arduino architecture.