Go Down

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

celem

Feb 06, 2012, 01:26 am Last Edit: Feb 06, 2012, 05:33 am by celem Reason: 1
I am working on a project where, ultimately, I will be driving a 16x2 1602 LCD with a ATtiny85. For now, however, I am testing Shift Register libraries, and there are several out there. I am testing several and will, eventually, pick one. So far I have tested ShiftLCD by Chris Parish and LiquidCrystal_SR by Francisco Malpartida. They both work well but require significantly different wiring. I have posted my test "Hello World" for both libraries below. The wiring differences are noted. I thank both Chris and Francisco for generously donating the libraries to the community.

First, with LiquidCrystal_SR:
Code: [Select]

#include <LiquidCrystal_SR.h>

/*
 ShiftLCD Library - Hello World

Demonstrates the use a 16x2 LCD display.  The ShiftLCD library works with
all LCD displays that are compatible with the Hitachi HD44780 driver.
There are many of them out there, and you can usually tell them by the
16-pin interface.

This sketch prints "Hello World!" to the LCD
and shows the number of seconds since reset.

 The circuit:

---Shift Register 74HC595---
* SR SER - Pin 14 to Arduino pin PD2
* SR RCK - Pin 12 to Arduino pin PD3 and (LCD E 1602 Pin 6)
* SR SCK - Pin 11 to Arduino pin PD4
* SR GND - Pin  8 to Ground
* SR VCC - Pin 16 to +5v
* SR OE - Pin 13 to Ground
* SR SCLR - Pin 10 to +5v
-----Shift Reg to LCD--------
* SR QG - Pin 6 to D7 (LCD 1602 Pin 14)
* SR QF - Pin 5  to D6 (LCD 1602 Pin 13)
* SR QE - Pin 4  to D5 (LCD 1602 Pin 12)
* SR QD - Pin 3  to D4 (LCD 1602 Pin 11)
* SR QC - Pin 2  to LCD RS (LCD 1602 Pin 4)
-----LCD HD44780-------------
* Vss to Ground    (LCD 1602 Pin 1)
* Vdd to +5V       (LCD 1602 Pin 2)
* Vo  to 10k Wiper (LCD 1602 Pin 3)
* R/W to Ground    (LCD 1602 Pin 5)
* LEDA  to +5v     (LCD 1602 Pin 15)
* Gnd to LEDK via 330 Ohm resistor  (LCD 1602 Pin 16)

The schematic at this link is:
http://code.google.com/p/arduinoshiftreglcd/ see
the last schematic labled "Latched shiftregister"

*/

#define  DATAPIN  2
#define  CLOCKPIN 4
#define  STROBEPIN 3
#define  MAXCOLUMNS  16
#define  MAXLINES  2


LiquidCrystal_SR lcd(DATAPIN, CLOCKPIN, STROBEPIN);

void setup() {
 // set up the LCD's number of rows and columns:
 lcd.begin(MAXCOLUMNS, MAXLINES);
 // Print a message to the LCD.
 lcd.print("Hello, World!");
}

void loop() {
 // set the cursor to column 0, line 1
 // (note: line 1 is the second row, since counting begins with 0):
 lcd.setCursor(0, 1);  //lcd.setCursor(column, row);
 // print the number of seconds since reset:
 lcd.print(millis()/1000);
}


Next with ShiftLCD:
Code: [Select]

#include <ShiftLCD.h>

/*
 ShiftLCD Library - Hello World

Demonstrates the use a 16x2 LCD display.  The ShiftLCD library works with
all LCD displays that are compatible with the Hitachi HD44780 driver.
There are many of them out there, and you can usually tell them by the
16-pin interface.

This sketch prints "Hello World!" to the LCD
and shows the number of seconds since reset.

 The circuit:

---Shift Register 74HC595---
* SR SER - Pin 14 to Arduino pin PD2
* SR RCK - Pin 12 to Arduino pin PD3
* SR SCK - Pin 11 to Arduino pin PD4
* SR GND - Pin  8 to Ground
* SR VCC - Pin 16 to +5v
* SR OE - Pin 13 to Ground
* SR SCLR - Pin 10 to +5v
-----Shift Reg to LCD--------
* SR QA - Pin 15 to D7
* SR QB - Pin 1  to D6
* SR QC - Pin 2  to D5
* SR QD - Pin 3  to D4
* SR QG - Pin 6  to LCD Enable (LCD 1602 Pin 6)
* SR QH - Pin 7  to LCD RS (LCD 1602 Pin 4)
-----LCD HD44780-------------
* Vss to Ground    (LCD 1602 Pin 1)
* Vdd to +5V       (LCD 1602 Pin 2)
* Vo  to 10k Wiper (LCD 1602 Pin 3)
* R/W to Ground    (LCD 1602 Pin 5)
* LEDA  to +5v     (LCD 1602 Pin 15)
* Gnd to LEDK via 330 Ohm resistor  (LCD 1602 Pin 16)

The schematic at this link is correct except that, in this implementation,
The MOSFET circuit is replaced by a 330 ohm resistor (see above).
http://cjparish.blogspot.com/2010/01/controlling-lcd-display-with-shift.html

Library modified from the original LiquidCrystal Library
This example originaly by Tom Igoe, Jul 2009
Example modified for use with ShiftLCD
Chris Parish, January 12th 2010
*/

#define  DATAPIN  2
#define  CLOCKPIN 4
#define  LATCHPIN 3
#define  MAXCOLUMNS  16
#define  MAXLINES  2
#define  FOURBIT  4


ShiftLCD lcd(DATAPIN, CLOCKPIN, LATCHPIN, FOURBIT);

void setup() {
 // set up the LCD's number of rows and columns:
 lcd.begin(MAXCOLUMNS, MAXLINES);
 // Print a message to the LCD.
 lcd.print("Hello, World!");
}

void loop() {
 // set the cursor to column 0, line 1
 // (note: line 1 is the second row, since counting begins with 0):
 lcd.setCursor(0, 1);  //lcd.setCursor(column, row);
 // print the number of seconds since reset:
 lcd.print(millis()/1000);
}


http://cjparish.blogspot.com/2010/01/controlling-lcd-display-with-shift.html
https://github.com/marcmerlin/NewLiquidCrystal

floresta

Quote
So far I have tested ShiftLCD by Chris Parish and LiquidCrystal_SR by Francisco Malpartida.

Your post would be a lot more helpful if you included actual links to these libraries.

don


floresta

I always wonder what the author of a program named NewWhatever will call his next version.  Perhaps 'NewerWhatever', or the worst possibility - 'NewestWhatever'.

What is really important and troubling is the fact that virtually every 'new' LCD library that comes out:
(a) still contains the same irrelevant comments that have been with us since the early days of the original LiquidCrystal library,
and
(b) fails to follow the initialization code sequence that is recommended in the data sheets.


Don

liudr


I always wonder what the author of a program named NewWhatever will call his next version.  Perhaps 'NewerWhatever', or the worst possibility - 'NewestWhatever'.


And you live in which great state Don?  ;)

My libraries and hardware have a common prefix and fortunately it is not the word "new" or my name.

floresta

Quote
And you live in which great state Don?

I didn't name it, but I guess it should have been York v01 or York1664

Don

roachburn

Will this work with an arduino UNO R3? I tried the shift LCD but I got a couple of errors when I tried to compile it.


In file included from sketch_mar07a.cpp:1:
C:\Program Files\arduino-1.0\libraries\ShiftLCD/ShiftLCD.h:116: error: conflicting return type specified for 'virtual void ShiftLCD::write(uint8_t)'
C:\Program Files\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'
 
Thanks a bunch for any advice on getting this to work.
"I have not failed. I've just found 10,000 ways that won't work."
Thomas A. Edison

celem

LiquidCrystal_SR from New-LiquidCrystal is the best library choice.
Get it directly from the author: https://bitbucket.org/fmalpartida/new-liquidcrystal/overview

Other good reading: http://code.google.com/p/arduinoshiftreglcd/ - contains important info regarding the circuit design.

and, yet more: http://www.3guys1laser.com/blog-cheap-arduino-2-wire-lcd-display-0


roachburn

I got it working. The circuit was fine. Something was wrong with my IDE, so I re-installed it then was able to get the liquidCrystal_SR library to work. I still get the same errors for the shiftLCD library but the other works fine for my purpose. Thanks for sharing this  code, and also pointing these libraries out to us. I have been trying to get this 595 to run my LCD for weeks. Here is my schematic I made with Fritzing for anyone who is interested.



"I have not failed. I've just found 10,000 ways that won't work."
Thomas A. Edison

roachburn

How do I go about powering everything off another voltage supply? Would this setup work using either a wall adapter or battery, as long as I connect all the grounds?


"I have not failed. I've just found 10,000 ways that won't work."
Thomas A. Edison

floresta

Quote
How do I go about powering everything off another voltage supply? Would this setup work using either a wall adapter or battery, as long as I connect all the grounds?

It wouldn't work very long with that battery.
You would have to power the Arduino somehow.
I don't see the recommended capacitor on the input side of your voltage regulator.
Not too many LCDs give a suitable display with that contrast pin circuit.
How did you manage to get two wires into one breadboard hole?


Don

celem

Consider getting a breadboard specific power supply, such as this: http://tinyurl.com/85avtt2

They are under $5 and perfect for Arduino breadboard work, specifically designed for the type of breadboard shown in your Fritzing image. You'll also need a 6-to-9 volt wall wart transformer - maybe hiding in your closet or at the local thrift store.


roachburn

I really just wanted to know if this was the right way to do it. I heard that in some cases you can have multiple voltages in a  system and you connect the grounds together. So basically the question is will the circuit short anything out. I will be using a seperate power supply for the arduino of course and the 9v can be replaced with a wall wort. I have been wanting to get a breadboard ps like that but for now i am using a voltage regulator and 2x 10uf caps with a .1 uf. Also, lets say I want to add a mosfet to power a high current device such as a solenoid. Would I also connect that ground to the circuit? Do you always connect all the grounds in these situations?

Thanks for the reply,
Anthony
"I have not failed. I've just found 10,000 ways that won't work."
Thomas A. Edison

celem

Yes, you can use multiple power supplies, connecting the common, within reason. The Vcc should be as close to the same as you can get it, given that there will be some feedback through circuit connections, such as the Atmel chip, i/o chips, etc.

icyfyer

I have downloaded the "latest" library from Francisco's GITHUB (dated 20Aug2011) and installed it. When I go to compile your example code, I get errors related to "I2CIO.cpp", where "Wire.h" does not exist. I am using the IDE V1.0. I went through his .ccp file and noticed that it says "#include...Wire.h". Are there changes I need to make to this file in order for this to work, or should I reinstall the IDE as was suggested above by roachburn?

Go Up