Shift Register circuit for LCDBitmap

It is probably staring me right in the face, but does anyone know where I can get a circuit for connecting a 595 shift register to control a 16 * 2 LCD using Tim Eckel’s LCDBitmap library.

http://code.google.com/p/arduino-lcd-bitmap/

I am successfully using a circuit that uses a 595 to control the LCD, but I do not know if this will work with the LCDBitmap library.

Thanks Pedro.

Edit - I see that you also need LiquidCrystal_SR3W.h in LCDBitmap sketches. I found out that this was included in fm’s LCD library at

https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home#!contributors

I see that this library also includes a LiquidCrystal library. Is this the same as the original LiquidCrystal library that you use with the plain old 4 bit LCD sketches and if so can I delete it and just use the LiquidCrystal library that is included in fm’s LCD library? I assume that you can judging by this quote from the above link

The library has been developed to replace the current Arduino library, therefore you will need to remove/backup the LiquidCrystal folder from the Arduino library folder the original LiquidCrystal library and replace it for this one.

It does seem to get a bit confusing with all these different variants of some of these libraries so I just thought that I would check this thanks.

With respect to all these LiquidCrystal library variants.
The simple answer/recommendation from me, is ignore them and stick with fm's library.

fm's library is a replacement for the LiquidCrystal library.
The wording you quoted is correct. Simply backup the existing LiquidCrystal library
(so you can get back to it if for some reason you need to).
The goal of fm's library, which I think has been achieved, is that it fully replaces the stock library.
All API functions and examples for the LiquidCrystal library will all work "as is"
and will now work on different interfaces by simply changing the include header and constructor.

fm's library also has backlight API extensions for backlight control that do not exist
in the stock library.

--- bill

Thanks Bill I will keep the “original” LiquidCrystal library in a safe place just in case, but I would still like to try the LCDBit library. Both you and fm offered advice to the author of this library, teckel, at http://forum.arduino.cc/index.php/topic,103956.0.html and on the web page of LCDBit

Works with both the standard Liquid Crystal library as well as Francisco's New Liquid Crystal library. Works with LCD connection methods including: 4bit, shift register (2 or 3 wire), and I2C. In-depth example sketches are included with library download.

So I am still wondering if anyone can suggest how to coonect up a shift register to the LCD so I can try out the library.
Thanks again for your advice,
Pedro.

In the first post you said:

I am successfully using a circuit that uses a 595 to control the LCD, . . .

The LCDbitmap library sits on top of fm's library and can function with any interface.

So what library are you using successfully and what else you want/need?
I'm confused...

There are several different ways to hook up a shift register to control a LCD.
2 pins or 3 pins. And then when using 3 pins you can have E go directly to the LCD
or use a shift register output.
The shift register code in the library is flexible enough to be configured for whatever you
already have working.

--- bill

Sorry if my questions was confusing Bill I have successfully used the the LiquidCrystal595 library and LCD wiring at

I have since had a look at the shift register to LCD wiring at fm’s page at

https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!latch-shift-register

and think that I will have a go at the three wire latch shift register wiring there and see how I go.
Thanks again Pedro.

Edit -
I thought that I could make sense of this but I am still confused. In this wiring schematic from the New LiquidCrystal Wiki, how do I connect the Arduino to the shift register, and what is the strobe pin? latch pin maybe?

Rather than switching to a different wiring, I’d recommend using the wiring that you already
have working from that instructable since fm’s library can pretty much handle
any wiring. (that is what it was designed to do)
It is just a matter of creating the proper constructor to match the wiring.

So, time to get familiar with reading datasheets and schematics.
First go get a 595 datasheet.
Google for “74hc595 datasheet”
Different datasheets call the pins different things but all 595s work the same way
and have the same pinouts.
Grab the NXP datasheet as that one uses the same names as the instructable.

First, if you look closely at the schematic in the instructable you will notice
an error.
The LCD LED + pin is not connected to anything.
The stripboard and the Fritzing diagram properly show it connected to VCC.
So this is an error in the schematic.
One other thing not in the schematic is a current limiting resistor.
If one is needed it will go between the LED- and the transistor collector.

Since there are 3 wires going to Arduino and E is driven by
the 595 you will need to use LiquidCrystal_SR3W

Now go back and look at the schematic for the instructable.
Look at the output bits on the Shift register (Q0 to Q7)
Where do they go?
Q0 LCD E
Q1 LCD D7
Q2 LCD D6
Q3 LCD D5
Q4 LCD D4
Q5 (Not connected)
Q6 Backlight Transistor

And now what about the Clock, Data and Latch pins on the 595?
Refer to the 595 datasheet.
Go to table 6.2 “Pin Description”
The rows you want are:
SHCP pin 11
STCP pin 12
DS pin 14

The table will tell you what the pins do
(note: storage register clock is the “strobe” or “latch”, it latches the 595 outputs)

So using the 595 datsheet and the schematic, see how the SHCP, STCP, and DS pins
are connected to the Arduino pins.
Those are Arduino pins are the pins that will be used in the constructor
for data, clock, and strobe/latch.
(I’m leaving the lookup of those arduino pins to you)

So now you have almost all the information you need for the LiquidCrystal_SR3W
constructor.
The one perhaps not so obvious thing will be the backlight polarity.
The circuit uses an NPN transistor. That will turn on when the base is connected to
positive voltage. So you guessed it, the polarity will be POSITIVE.

Another not obvious thing is that the SR3W code is written to drive the RW
line on the LCD with the 595. If you look at the schematic you will notice
that the LCD RW pin is directly connected to ground vs the 595.
This is actually a good thing since the LCD will only every be written to and
ensures that incorrect wiring or constructor will not ever damage the LCD.
However, the SR3W code wants an output bit number for RW since it wants to drive
RW from a shift register output pin.
Because of this, you must assign RW an output bit number even if it is not needed.
The key is you MUST select a bit that is not used by anything else.
If you look at the wiring you will notice that bit 5 not used, so that will be what
you use for the RW bit in the constructor.

So now just create and fill in the information into the SR3W constructor:
(The values are blank and left as an exercise for you)

#include <LiquidCrystal_SR3W.h>
                   //     d,clk,strb, en,rw,rs,d4,d5,d6,d7,bl,blpol
//LiquidCrystal_SR3W lcd (?, ?,  ?,    ?, ?, ?, ?, ?, ?, ?, ?, ?);

So that’s it.
Fill in the values and it should work with your existing wiring.

— bill

As usual thank you for the thorough explanation Bill. You explain things in a very clear and concise manner. When I first connected up the circuit from Instructables, I dispensed with the transistor and associated wiring and just connected pin 16 of the LCD to ground.
So the way I am seeing it the constructor for the wiring that I am using, without the transistor for the backlight, would be -
LiquidCrystal_SR3W lcd (7, 9, 8, 0, RW?, 7, 4, 3, 2, 1);
Because-
data pin of SR goes to Arduino pin 7
clock pin of SR goes to Arduino pin 9
latch pin of SR goes to Arduino pin 8
E of LCD goes to SR pin Q0
RW of LCD goes to SR pin ? A bit confused here, might it possibly be zero because RW is tied to Ground ?
RS of LCD goes to SR pin Q7
Data 4 of LCD goes to SR pin Q4
Data 5 of LCD goes to SR pin Q3
Data 6 of LCD goes to SR pin Q2
Data 7 of LCD goes to SR pin Q1
I am not 100% certain of my RW “element, is it ?” of the constructor because it goes to ground whereas all the other “elements ?” of the constructor are referencing Arduino digital pins or output pin numbers of the shift register.
I assume that I leave out the eleventh and twelfth “elements ?” of the constructor because the backlight is not controlled by software.
Pedro.

Looks like you got it.

On the RW argument, the library always wants to control RW. So it "thinks" it is controlling RW
but the circuit is wired up with RW connected to ground instead of the SR.
Since the library wants to control RW, it must always be told what bit (output pin) to use even
if RW is not actually hooked up to the SR.
Just give the constructor an unused bit (output pin) on the SR for the RW
argument when RW is not connected to the SR.

As mentioned earlier I think permanently wiring RW to ground is better than
wiring it up to the SR. The reason being, if the constructor is wrong,
then the library will incorrectly drive the SR output pins.
If the pins are incorrectly driven, then it is possible
that the LCD gets put into read mode instead of write mode and then if E is set to HIGH,
the SR and the LCD will both be driving the 4 data pins.
If a data pin from the LCD is not the same level (low or high) as the corresponding
SR output pin, this can potentially damage the circuitry since the SR and LCD will be fighting
each other to set the level of the signal.
Also, when using a SR to control the LCD it is not possible to read the LCD anyway
since the SR pins are output only, so supporting read mode by controlling the LCD RW signal
from the SR makes little sense since it must always be LOW for writes anyway.
So that is why I'd recommend wiring RW to ground rather than to the SR.

With respect to the backlight, you are correct, leave off the two backlight arguments if
you don't need it.
Backlight control is kind of nice to have. Do you have any transistors?
Pretty much anything will do for a lcd backlight,
NPN or PNP and it doesn't need to be a mosfet or FET,
simple cheap transistors like 3906, 3904, 2222 etc can work just fine, they just need
slightly different wiring. (requires a resistor)
I get cheap parts from these guys: http://www.taydaelectronics.com/

--- bill

That’s great Bill.
A good teacher makes learning easier. Yes I do have some transitors so I will give the backlight control a try. If I use the backlight control via a transistor, the arguments for “LiquidCrystal_SR3W lcd ( ……bl,blpol); presumably are bi is the SR pin number that we use.In the Instructables circuit this is SR pin Q6. The blpol argument is for backlight polarity? How is this set please. If I used a BC574, does the resistor go between the base and Q6 of the SR and what is a good value for this application.
I just found out about Tayda Electronis and am awaitng my first delivery - Great prices.
Thanks again Pedro.

Pedro147:
If I use the backlight control via a transistor, the arguments for “LiquidCrystal_SR3W lcd ( ……bl,blpol); presumably are bi is the SR pin number that we use.In the Instructables circuit this is SR pin Q6.

YES

The blpol argument is for backlight polarity? How is this set please.
I’m assuming you have a BC547? (vs a BC574? )
Then that is a NPN transistor which turns on with positive voltage.

If I used a BC574, does the resistor go between the base and Q6 of the SR
YES
and what is a good value for this application.

Hard to know the exact/best value without knowing your backlight current requirements
but 1k to 10k should work.
The higher the value the lower the wasted current. A 16x2 backlight typically doesn’t
use much current (2-50ma) so 10k should work ok. I wouldn’t go lower than around 1k
but the value isn’t that critical

Bill,
thank you so much for taking the time to not only help me but also educate me, I really appreciate it. Here is a photo of the 3 wire shift register PCB I made last night running LCDBitmap with fm’s new LiquidCrystal library
Pedro.

Cool!
Wow, when you said you made a PCB you really made one.
I'm pretty lazy and often just use strip board and some wires.
What does the back look like? I'm curious what you used to make the traces.

--- bill

Yes Bill,
I only started making PCB’s a few weeks ago, so mine “are not the most elegant solution”, but it is fun and after having made some other more complicated circuits on veroboard this is much easier and quicker. This 8 x 8 LED matrix with two 595’s and a ULN 2803 took me days of soldering but at least it worked.
When I get home from work I will post a photo of the back of the LCD SR board,
Pedro.

Bill,
Here is the back of the SR LCD PCB. Next step double sided boards to eliminate jumpers 8)
and “just because I can” ( and it’s fun )

bperrybap:
With respect to all these LiquidCrystal library variants.
The simple answer/recommendation from me, is ignore them and stick with fm's library.

fm's library is a replacement for the LiquidCrystal library.
The wording you quoted is correct. Simply backup the existing LiquidCrystal library
(so you can get back to it if for some reason you need to).
The goal of fm's library, which I think has been achieved, is that it fully replaces the stock library.
All API functions and examples for the LiquidCrystal library will all work "as is"
and will now work on different interfaces by simply changing the include header and constructor.

fm's library also has backlight API extensions for backlight control that do not exist
in the stock library.

--- bill

LCDBitmap has nothing to do with replacing the LiquidCrystal library. LCDBitmap actually uses (and requires) the LiquidCrystal library. LCDBitmap allows people to output GRAPHICS to a normally text only display. LCDBitmap is an enhancement, not a replacement.

See more information here: LCDBitmap

Tim

teckel:
LCDBitmap has nothing to do with replacing the LiquidCrystal library. LCDBitmap actually uses (and requires) the LiquidCrystal library. LCDBitmap allows people to output GRAPHICS to a normally text only display. LCDBitmap is an enhancement, not a replacement.

See more information here: [url=http://forum.arduino.cc///LCDBitmap[/url]

Tim

Tim,

This is a pretty old thread.
But If you read the context of the discussion with respect to the topic and then look at the responses, they seem to be accurate.
The LCDbitmap library is a layer on top of fm's library when fms' library is being used and it is fm's library that is replacing the stock IDE liquidCrystal library.
i.e. the LCDbitmap library does not require the stock LIquidCrystal library.
It functions with either fm's lbirary or the stock IDE LiquidCrystal library.

--- bill