Go Down

Topic: Shift Register Libraries for LCD Displays (Read 8 times) previous topic - next topic


Disregard previous question. I added the following line to the top of the code, and it compiled and uploaded fine:

#include <Wire.h>

Now I get random garbage being displayed on my LCD. I read a note in your page:


that says that decoupling caps should be added to fix this problem. I'm going to try that next, but first have a question. Is the screen supposed to be continuously rewritten? The screen doesn't just print one set of garbage lines and stop. It continues to write blah to line zero, mostly question marks and forward slashes. Shouldn't it just print one line and stop? For reference, I am using:

Arduino UNO SMD
V1.0 IDE
This LCD: http://www.sparkfun.com/products/709
And a 74H595N latching shift register
All is wired according to the instructions in the sample code above.


As suggested, I placed coupling capacitors between VCC (pin 16 on the 595N) to GND, and GND to GND (the second one was just in case). It didn't change anything. In the LCD3Wires tutorial, a decoupling cap is recommended for pin 12 to GND, to cancel out ripple which could cause flicker. I had this cap placed between pin 12 and pin 13, since pin 13 is tied to GND, and electrically it is all the same. To ensure that this was not the issue, I removed the cap entirely. When I did this, I can definitely see the flicker when the SR changes state (clock), and the LCD now writes garbage faster, and generally to only the first 6 blocks. If I hit the reset button on the Arduino, or remove power from it entirely, the LCD does nothing (I am running it off of separate power from a USB port). It holds the state of the characters until the Arduino is powered back on, then starts to write garbage again.


Apr 12, 2012, 03:40 pm Last Edit: Apr 12, 2012, 03:46 pm by celem Reason: 1
I also use the IDE v1.0 although these days I mostly use make for my compilations. I use the same LCD display as you.

I am not sure if I can help much as I haven't used this circuit with an actual Arduino for quite a while. I have moved on to using bare-chip AVR ATtiny85 and ATtiny84 designs. There  is a video of my ATtiny85 version at http://youtu.be/9r2GVga5cYs

I can say that without the bypass capacitors the circuit was unreliable, displaying random garbage, as you are experiencing. I could tell that the firmware was sane because I could send serial commands to the circuit to turn the LED on and off. Inserting bypass capacitors solved my reliability issues. If you insert bypass capacitors and still have reliability issues you may have power supply noise. Finally, substitute different physical ICs and display in case you have a chip problem.

Two pieces of advice that I have learned the hard way on this project. (1) If you use one of the ATtiny chips, pay attention to the core's pin assignments. There are several ATtiny cores out there and they differ. I use MIT's Arduino-Tiny core; (2) If you use a serial connection that uses a CP2102 I/O chip, isolate the Rx line (CP2102's Tx, your board's Rx) with a signal diode. Otherwise your circuit will lockup if connected during power-on - or appears to lockup as the LCD displays the same pattern as if no CPU were present. Oddly, if connected after power on it worked correctly. Anyway, diode isolation solved that issue.


Update: Partial success. After removing the decoupling cap between pins 12 and 13, and writing the last update, I reset the Arduino again, and it started working. I reinserted the cap between these two pins, and the garbage came back. Obviously there should not be a cap there. Anyone who has done the same thing should remove this cap if you are having this problem.

Now what I get is "Hello World" on the first line, and a counter on the second line, displaying the seconds since the Arduino has been reset. However, at random intervals the second line will display garbage, and continue counting. The first time it was near 60 seconds, then near 100, then near 400. If I reset the Arduino, the counting starts again, and the screen looks normal, but the problem comes back at some random point.

I am using .1uF decoupling caps: http://www.sparkfun.com/products/8375


I don't know what you are referring to with a "decoupling cap between pins 12 and 13". The only capacitors that I use are between the power and ground pins, as close to the chips as possible. I attached, to this post, a copy of the schematic of my ATtiny85 2w-LCD circuit. You can see the capacitor placement.


True. I was mistaken. The recommendation I saw was used in a circuit for using the 595 for PWM on multiple LEDs. The cap was placed wo avoid flicker on pin 12, but after further contemplation really makes no sense. It has been removed.

The good news is that I found my problem, and possibly the problem I was having with previous circuits as well. I am using a group of 3 breadboards to lay out a complex circuit. Since I didn't want to draw all of the current through the Arduino board, I hooked up a USB cable to the power rails of my primary breadboard, and daisychained that power to the rest of them. I ran all of my electronics off of that, but the Arduino was plugged into a separate USB port. After disabling this power option, and using the provided power from the Arduino board (5V and GND pins), it seems that I have eliminated all issues. The LCD has been going for 6000+ seconds without garbage. My assumption was that both USB ports use the same well-regulated power, but I guess that was wrong. Or, perhaps the secondary regulation provided by the Arduino's regulator creates a differential in grounds between the two, and caused the problems. Either way, the issue is gone.

Take note, kids: everything must be tied to the EXACT same ground plane.


Celem, like you, I have been chasing this library for weeks, prehaps even a month. I came across the LCD3Wires tutorial first, and was then led to Marc's page. He tells his readers to go to Francisco's page. Francisco's page actually has code on it that I couldn't seem to get to compile, so I kept searching. When I found this page, you were advocating Francisco's library here, but on your linked site you had deprecated everything. This search has been quite frustrating, but I REALLY appreciate the fact that you have created this post. It has saved me from desperate acts of frustration.

Now I need to find a reliable way to PWM LEDs using shift registers.


Guys, this shouldn't be so difficult.

There are many different libraries and write ups out there
and WAY too many different ways of wiring these up.
It can get a bit confusing how to wire things up
especially when dealing with using a a HC595 vs a LS164 or other shift registers
because of the clock to latch delay on the 595 when using it in a "non latched" mode.

Here is what I recommend:
Go get fm's latest library (version 2.1 : https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads )
It has been extensively tested and I know it works, including with backlight
control because I did many recent updates to the library and wrote the SR2W module and have tested
all the SR modes of all the SR modules (SR with 2Wire and 3 wire, SR2W, and SR3W)
on both AVR chips and pic32 chips using a HC595.

By using this library, you can at least be assured you will not be fighting any software issues.

If you are going to wire up your own 2 wire SR implementation,
then I suggest you use the SR2W module
and hook up the components using the wiring I drew in ASCII art
in the SR2W header file LiquidCrystal_SR2W.h

SR2W is essentially the same as the SR module in two wire mode
but uses a fixed/hard-coded wiring so there is less to potentially go wrong.
Just wire up as indicated in the SR2W header file and you should be good to go.

For reference, my test circuit was using a 4.7k resistor and a 1n4148 diode.
With a 595, decoupling is vital as it is being latched on every clock cycle when used in two wire mode.
And you must make sure not to have multiple long
voltage paths when using a breadboard.

If you want to use a NPN transistor like a 2n3904 rather than a FET for backlight control you can do that
but you will experience some flicker during LCD updates.
A different backlight circuit is required to eliminate the flicker when using a NPN transistor.

--- bill


take a look at this one http://arduino.cc/playground/Main/LiquidCrystal I hope there is no problem with the nomenclature. it is the same library that comes with Arduino but you can use it with a shift register and SPI.

Go Up