// 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 );

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.

transcendtient

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.

transcendtient,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.

// ===========================================================================// 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)

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

--- bill

geekspeek

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.

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 becauseit initially wasn't working.I was inadvertently using the incorrect constructor.Felt a bit silly afterwards.

geekspeek

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.

I couldn't follow what you did as to which wiring you were trying to use with whichinterface (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 thereforethere 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 SRand the 595 must be wired up the way that SR interface wants it to be wired up.

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 whichmeans 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 modeto 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 downwhen 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 willbe 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 pagehappens to have the 595 wired up in latching mode and with the pinsconnected 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)

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.http://www.instructables.com/id/3-Wire-HD47780-LCD-for-less-than-1-dollar/

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.http://www.instructables.com/id/3-Wire-HD47780-LCD-for-less-than-1-dollar/

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 595to control a ladder network to provide s/w controlled contrast.

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.

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