Go Down

Topic: LiquidCrystal_SR3W Wiring E to the Strobe Pin (Read 7518 times) previous topic - next topic


First of all... man the documentation is just not right ... the pinout on the schematic doesn't match the library pinout at all,
which is where I got my wiring instructions.
This is from the library:
Code: [Select]
//   +--------------------------------------------+
//   |                 MCU                        |
//   |   IO1           IO2           IO3          |
//   +----+-------------+-------------+-----------+
//        |             |             |
//        |             |             |
//   +----+-------------+-------------+-----------+
//   |    Strobe        Data          Clock       |
//   |          8-bit shift/latch register        | 74HC595N
//   |    Qa0  Qb1  Qc2  Qd3  Qe4  Qf5  Qg6  Qh7  |
//   +----+----+----+----+----+----+----+----+----+
//        |    |    |    |    |    |    |   
//        |11  |12  |13  |14  |6   |5   |4   (LCD pins)
//   +----+----+----+----+----+----+----+----+----+
//   |    DB4  DB5  DB6  DB7  E    Rw   RS        |
//   |                 LCD Module                 |

My problem is according to the schematic...

... you can hook up the "E" line from a HD44780 to the strobe pin, which is pin 2 on my Teensy.

I tried this and had no luck. I would VERY much like to use the schematic pinout for "E" as it frees yet another pin on the shift register.

Here is my code, it's just the example code, so you can see my pinouts.
Code: [Select]
#include <LCD.h>
#include <LiquidCrystal_SR3W.h>

// constructor prototype parameter: data, clk, strobe, E, RW, RS, D4, D5, D6, D7
// Notice that E in this schematic is driven by the strobe pin so we will use a free
// pin Qa (0) and that R/!W is hardwired to GND, so we donĀ“t care for driving it,
// use another free pin Qb (1).
// Assuming that the header is connected to the same digital IO pin.
// Schematic also available in the LiquidCrustal_SR3W.(h|c)
LiquidCrystal_SR3W iLCD(0, 1, 2, 4, 5, 6, 0, 1, 2, 3);
void setup ( )
   iLCD.begin ( 16, 2 );


void loop ()
   // your code here ...


The library was written to be very flexible and give the flexibility to write the LCD in different ways to the SR. The default configuration of the library is that in the header file, while the schematic and the example in the wiki is just an example (that should work)  as to how to configure and use it.

If you are not too concerned about how the SR and LCD is connected, you can use the wiring in the header file and use the short constructor (default) to initialise your LCD, i.e. use the text schematic.


I just want to know why I can't hook my E pin from my HD44780 to the strobe line between the Arduino and the 74HC595. If I hook it up as I've always seen it it works, but not when those 3 are together.


The code in SR_3W is set up to drive E from a shift register output pin.
What you want is to use the SR interface in 3 pin mode instead of the SR_3W interface.
SR does not have the pin flexibility (it requires a specific wiring) but
it is written to drive E directly. It is also a bit faster than SR_3W.

Use this pinout and constructor:

Code: [Select]

// ===========================================================================
// Wiring when using 3 Arduino Pins (data pin, clock pin, enable pin)
// Constructor:
//  LiquidCrystal_SR lcd(DataPin, ClockPin, EnablePin);
// ===========================================================================
// ---------------------------------------------------------------------------
// 3 pin Wiring for a 74HC595
// --------------------------
// NOTE: the 74HC595 is a latching shift register. In order to get it to operate
// in a "non latching" mode, RCLK and SCLK are tied together. The side effect of this
// is that the latched output is one clock behind behind the internal shift register bits.
// To compensate for this the wiring is offset by one bit position lower.
// For example, while the backlight is hooked to Q0 it is still using bit 1 of
// of the shift register because the outputs are 1 clock behind the real internal shift
// register.
//                         74HC595    (VCC)
//                       +----u----+    |
// (LCD RS)------------1-|Q1    VCC|-16-+
// (LCD D4)------------2-|Q2     Q0|-15
// (LCD D5)------------3-|Q3    SER|-14-----------(data pin)
// (LCD D6)------------4-|Q4    /OE|-13--(gnd)
// (LCD D7)------------5-|Q5   RCLK|-12-------+
//                       |         |          |
//                     6-|Q6   SCLK|-11-------+---(clock pin)
//                     7-|Q7    /MR|-10--(VCC)
//                   +-8-|GND   Q6'|--9
//                   |   +---------+
//                   |      0.1uf
//                 (gnd)-----||----(vcc)
// (enable pin)-----------------------------------(LCD Enable)

this comment block is part of an update that I have for the library
that also includes backlight support for SR as well as a new IIC layer for i2c
that includes mcp23008 support and "auto locate" and "auto detect" modes
for i2c.
The IIC code is not yet done yet.

--- bill


(gentle) BUMP

I've been trying to connect an HD44780 LCD with an Arduino Uno via a 74HC595N SR, and failing brilliantly. I've used a variety of schematics and constructors with your classes, ending up with Bill Perry's method in the new header of (what I presume is) the LiquidCrystal_SR class posted above this. I've triple-checked the wiring, but all I get on the screen are random symbols. It's perfectly possible I've intercepted an alien transmission, but before I notify SETI, I thought I'd check here that ...
a) it _is_ the LiquidCrystal_SR class I should be using with that schematic, and that ...
b) the circuit should work with the class as is? Because the schematic in the header appears not to have been committed to the code-base yet, it struck me there just might be some extra and relevant functionality waiting.

Many thanks for your time and effort in creating these classes BTW.


I just wired up the 595 setup above. And it does work.
Although I did waste nearly an hour and even hooked up my analyzer because
it initially wasn't working.
I was inadvertently using the incorrect constructor.
Felt a bit silly afterwards.

Here is exact constructor I'm using:
Code: [Select]
#include <LiquidCrystal_SR.h>
                 //   d,clk,strb
LiquidCrystal_SR lcd (2, 3,  4);

In the LCDiSpeed sketch enable
line. This will use the constructor above.
It runs the interface is "SR" mode with 3 Wires.

--- bill


Many thanks for taking the time to sort this out. As an alternative I rigged up the three wire latch SR schematic described in srlcd595.jpg on https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics, but was unable to get that working with the constructor used in the attached code - LiquidCrystal_SR3W iLCD(2, 1, 3, 0, 1, 2, 3, 4, 5, 6). After a bit of flailing around, I in fact got another to work OK - LiquidCrystal_SR lcd(2, 1, 3). You might want to check this out. Again, thanks. Maybe I'll volunteer to help this project, if help is needed. I might be (probably am) a bit of a dummy when it comes to electronics, I've got 20 years experience programming.


Aug 01, 2013, 04:40 am Last Edit: Aug 01, 2013, 04:44 am by bperrybap Reason: 1
I couldn't follow what you did as to which wiring you were trying to use with which
interface (SR3W vs SR and what constructors)

I haven't ever looked very closely at or used those diagrams on fm's page.
After looking at them I did notice that the wiring figure and example code under the "Three wire latch Shift Register Schematic."
is wrong.
It is mixing up SR and SR3W and has other errors.

There is no way to make SR3W drive E from an arduino pin, it simply does not work that way.
SR3W drives E with a shift register output pin rather than driving it directly so therefore
there is no way to configure SR3W to work with the "Three wire latch Shift Register Schematic"
or any other wiring that requires E to be driven directly from an Arduino pin.

SR can drive E drive directly.
However, SR does not allow configuring which shift register output pins can be connected to which LCD pins.

So if you want run in 3 wire mode where the arduino drives E you must use SR
and the 595 must be wired up the way that SR interface wants it to be wired up.

SR always wants the internal bits assigned as follows:
0 - not used
1 - (backlight control in coming update)
2 - LCD RS
3 - D4
4 - D5
5 - D6
6 - D7
7 - EN - in 2 wire mode

The 595 can be wired up run in latching mode or non-latching/free-running mode.
In order to use 2 wire mode, the 595 must run in non latching mode.
In 3 wire mode the 595 can be run in either mode.
The 595 has lots of internal delay so when running in non-latching mode,
because of the internal delays, the output bits end up being 1 clock behind which
means that the output bits show up on pins all shifted down 1 bit/pin.

The schematic that I provided above was for 3 wire mode with the 595 wired in non latching mode
to match how it is wired/connected in 2 wire mode.
so technically while all the internal 595 bits are still the same, the output pins are all shifted down
when making the connections to the LCD.
(This is noted in the comment above the ascii art schematic)

If the 595 is connected in in latching mode then all the output pins will
be different than what I provided.

So the 595 can wired up two different ways and still work with the SR interface code.
The difference is whether the part is being run in latching mode or not.

As luck would have it, the schematic diagram jpg image on fm's page
happens to have the 595 wired up in latching mode and with the pins
connected in a way so it will work with SR.

So here are the two different ways to wire up the 595 to work with SR using 3 Arduino pins:
(I updated the ascii art to include both)

Code: [Select]
// 74HC595 wired in "non latching mode" for SR 3 wire operation
//                         74HC595    (VCC)
//                       +----u----+    |
// (LCD RS)------------1-|Q1    VCC|-16-+
// (LCD D4)------------2-|Q2     Q0|-15-------------(BL circuit)
// (LCD D5)------------3-|Q3    SER|-14-------------(data pin)
// (LCD D6)------------4-|Q4    /OE|-13--(gnd)
// (LCD D7)------------5-|Q5   RCLK|-12-------+
//                       |         |          |
//                     6-|Q6   SCLK|-11-------+-----(clock pin)
//                     7-|Q7    /MR|-10--(VCC)
//                   +-8-|GND   Q6'|--9
//                   |   +---------+
//                   |      0.1uf
//                 (gnd)-----||----(VCC)
// (enable pin)-----------------------------------(LCD Enable)
// (LCD RW)--(gnd)
// ---------------------------------------------------------------------------
// 74HC595 wired in "latching mode" for SR 3 wire operation
// NOTE: pin 11 is not connected to pin 12
//                         74HC595    (VCC)
//                       +----u----+    |
// (BL circuit)--------1-|Q1    VCC|-16-+
// (LCD RS)------------2-|Q2     Q0|-15
// (LCD D4)------------3-|Q3    SER|-14-------------(data pin)
// (LCD D5)------------4-|Q4    /OE|-13--(gnd)
// (LCD D6)------------5-|Q5   RCLK|-12--------+
//                       |         |            \
// (LCD D7)------------6-|Q6   SCLK|-11----------)--(clock pin)
//                     7-|Q7    /MR|-10--(VCC)  /
//                   +-8-|GND   Q6'|--9         |
//                   |   +---------+            |
//                   |      0.1uf               |
//                 (gnd)-----||----(VCC)        |
//                                              |
// (enable pin)---------------------------------+-(LCD Enable)
// (LCD RW)--(gnd)            

Notice that the latching mode schematic above matches
the pin wiring in the schematic jpeg image for "Three wire latch Shift Register Schematic" on fm's page.

--- bill


I see two issues on the wiki.
There isn't a sample schematic and example code for SR3W.

The example "Three wire latch Shift Register Schematic" has incorrect sample code
below it. The sample code needs to be updated to use SR.

I can see how people can easily get confused by this.

--- bill


Work is building up to maintain the wiki! I have to find a bit of time to maintain it and will do so in the coming weeks.


I wrote an instructible on how to get the HD44780 connected to 2x595, and also provided a simple and CrystalLiquid compatible library.
My solution uses arduino's SPI pins, but in my experience it works great (on a breadboard, a perfboard prototype, and I should soon have some PCBs to confirm whether it works in a "production environment").
Maybe it can help you out with figuring out what the problem is with your SR3W setup.


I wrote an instructible on how to get the HD44780 connected to 2x595, and also provided a simple and CrystalLiquid compatible library.
My solution uses arduino's SPI pins, but in my experience it works great (on a breadboard, a perfboard prototype, and I should soon have some PCBs to confirm whether it works in a "production environment").
Maybe it can help you out with figuring out what the problem is with your SR3W setup.

There  isn't really a problem with the 3 wire setup in the library.
There is a documentation issue that is creating confusion as to how to wire it up.

Interesting setup. I've seen a similar setup that used the unused outputs on the 2nd 595
to control a ladder network to provide s/w controlled contrast.

--- bill


If by any chance you saw it recently, it was probably mine as well.
I thought that a resistor ladder wasn't very practical, so I removed it.


Aug 02, 2013, 12:24 am Last Edit: Aug 02, 2013, 09:15 am by kowalski Reason: 1
After working the latest week with different port adapters for the HD44780 this it the fastest SR version I have implemented (so far). Below is the wiring of the SR4W 3-wire plus back-light control/8-bit parallel LCD adapter using a single 74HC595 Shift Register.
Code: [Select]

  *                         74HC595    (VCC)
  *                       +----U----+    |
  * (LCD D1)------------1-|Q1    VCC|-16-+
  * (LCD D2)------------2-|Q2     Q0|-15-----------(LCD D0)
  * (LCD D3)------------3-|Q3    /OE|-13-----------(GND)  
  * (LCD D4)------------4-|Q4    SER|-14-----------(SDA)
  * (LCD D5)------------5-|Q5   RCLK|-12-----------(EN)
  * (LCD D6)------------6-|Q6   SCLK|-11-----------(SCL)
  * (LCD D7)------------7-|Q7    /MR|-10-----------(VCC)
  *                   +-8-|GND   Q6'|-9
  *                   |   +---------+
  *                   |      0.1uF
  *                 (GND)-----||----(VCC)
  * (LCD RS)---------------------------------------(SDA)
  * (LCD EN)---------------------------------------(EN)
  * (LCD BT)---------------------------------------(BT)
  * (LCD RW)---------------------------------------(GND)

The byte write operation for this adapter in Cosa is simply:
Code: [Select]

HD44780::SR4W::write8b(uint8_t data)
 m_sda.write(data, m_scl);

The first write() operation will transfer (shiftout) the data to the SR using SDA and SCL. The second write() will use the SDA pin to set the current RS value (m_rs) before toggling the LCD enable signal (EN). The delay is necessary so that there is at least 37 us between two enable pulses. The loading of the next byte to the SR is done in parallel with the LCD execution of the previous (pipelining).

Inspired by AVR2LCD, a solution by Frank Henriquez. The original 74HC164 based design is by Stefan Heinzmann and Marc Simons. http://frank.bol.ucla.edu/avr2lcd.htm, http://web.archive.org/web/20100210142839/http://home.iae.nl/users/pouweha/lcd/lcd_examp.shtml#_3




You keep saying SDA, but do you mean the MOSI pin on the Arduino? Are you using SPI or just GPIO pins?
Also, that is a pretty good implementation, using SDA for RS. This keeps complexity of the circuit lower, but adds complexity to your code + requires more pins.
What I like about this thread is that several different people have several views on this and add their input for the benefit of everyone :)

Off topic question, how do you make these ASCII schematics?

Go Up