ShiftRegLCD lib (LiquidCrystal 3-wire replacement)

Anyone interested in I2C control for parallel HD44780 compat. LCD's using PCF8574?
I'm just finalyzing the library-modifications and would be glad to share.
(Still need a bit of time to clean the code and do some extra tests and find a webspot to store the files for download).

I needed to free up some ports on the Arduino and also wanted to be able to connect more than one LCD to it.
Doing it with I2C, I should in theory be able to connect up to 16 (8 on a PCF8574 and 8 on a 8574A) LCD's.
I'v only tested with one 16 x 2 LCD so far. Tests with 20 x 4 LCD are sheduled next.
For now all functions of the LiquidCrystal lib shipped with IDE 0017 seem to work. In addition I've added backlight control.
Still working on the buisy flag checks so timing is controlled by the LCD instead of the Arduino app.

CaptainObvious:

Since I also got a bunch of the 74HC164 since last time, I decided to give those a go. But it was a no-go on both my displays.

However, in 3-wire mode they worked. So the problem is probably the 74HC not managing the quick'n'dirty diode-resistor AND gate for the enable signal.

But then again, it seems Mouse above here made it work with the 74HC164 in 2-wire mode, so I'm not really sure. Also you got it to work with the HC595.

Could be experimenting more with the series R resistor solves it. Or, of course, have an actual factual digital AND gate :stuck_out_tongue: But that would increase complexity a bit.

I've tried to look up the capabilities of the 74LS164 and 74HC164, but it's not always easy comparing them when datasheets don't have the same names or tables.

For the 74LS164, datasheet says, under "recommended operating conditions"
HIGH level output current: -0.4 mA (max)
LOW level output current: 8 mA (max)

Whereas the datasheetsfor the 74HC164 says, under "Absolute maximum ratings":
DC output current, per pin: +/- 25 mA

I find that pretty puzzling, seems like the HC family IC's can sink and source more current than the LS family. Maybe my assumption above is wrong about it not being able to work with the diode-resistor AND gate. It would seem it should handle it pretty well (4.3-ish volt / 1k= 4.3-ish mA).

Mario_H:

Sounds interesting! I've never worked with I2C yet though, so I'm not sure how exactly that works or how complicated it is to set up. Also I'm wondering about the speed of an I2C bus and how well the bandwith is spent communicating about wating for a busy-flag is. As I understand it, it can be quite a few devices on an I2C bus? (This might not be a problem though, I'm just thinking out loud here).

May I suggest googlecode http://code.google.com/intl/nb-US/projecthosting/ to host your project?

Raron,

I2C is "simple". I'm a newby and got it working in a sec.
Thanks for the storage suggestion but I already found a spot to store Lib/samples/additional info.
Links on the playground:
Arduino Playground - LCD in the section "Using 4-bit mode with Hitachi LCD controllers."
Arduino Playground - LCDAPI
(both linking to: http://www.xs4all.nl/~hmario/arduino/LiquidCrystal_I2C/ )

I didn't get the Busy flag checking working as quick as I wanted and needed to move forward with my project so I've added that to my "To do" list.
The number of I2C devices on a bus can grow to big numbers when you start using busmultiplexers like the PCA9546.
My experience with I2C speeds is insufficient to give you any advice: Try it, play with is and see where you end up, thats my roadmap :wink:

hello all,

ive build the 74ls164 setup with a 16x2 display, and it only wants to display text on the first line. even lcd.setCursor(2,1) did not work. even to setCursor(2,0) it did'nt listen.

if i initialize the lcd with ShiftRegLCD srlcd(9, 10, 8, 2); i get a non functioning lcd. no characters show up.
ShiftRegLCD srlcd(9, 10, 8, 1 ); is working fine.

any ideas?

I'm sorry I don't know why it doesn't work. What is the name of your display?

I got a 20x2 line LCD that works with "ShiftRegLCD srlcd(12, 13, TWO_WIRE,2);". I use it in 2-wire mode, and have never actually tested 3-wire with this library myself (I use my old lib and old PCB for that). I don't see any bugs in the library regarding 3-wire mode (no guarantee though).

Could be your "contrast" setting (pot) needs to change to see it?

Update: Inluded an overview of the functions in its own wikipage, which was long overdue. So far I just used to look at the ShiftRegLCD.cpp if I needed to know what the functions (or methods) were.

thanks for your reply.
the contrast is ok. i can read the first line perfectly. last night i was connecting the display directly (4 bit parallel) with the arduino 0017 demo code, but could'nt get it to display info at all, so it could be that the lcd ids faulty. i will, receive another one this week, so i can check that later.

nice job!

hey guys, this thread is a little old but it has helped me so much, i have gotten all four lines working on my LCD screen but with only 1 problem. whenever i try to set the cursor it prints out two weird characters. any idea why this is.

here a image of it.

could you please edit the previous message so i don't have to stand 10 meters from my screen to see the picture? 640x480 will be enough...

woops i never preview the image before i posted sorry. it has been substituted with a thumbnail. :slight_smile:

Weird!

Could it have anything to do with the datatype you are using to set the position? Although I would think it would cast variable types automatically if that was the case. Also, your LCD shows the text properly, so it basically works. But just in case, can you say something about your circuit? What type of shiftregister, and how long are the wires connecting to it from the arduino? Noise maybe? Maybe the LCD isn't completely HD44780 compatible?

Actually I doubt all of what I'm saying here :stuck_out_tongue: In short; weird!

A question or two: even if the two strange characters show, does it actually change the cursor position? If not, how did you get it to the next line? What if you tried to write ASCII character 13 (CR), and / or ASCII character 10 (LF), will that get you to the next line without any strange output? Just a thought. I have never actually tried this with any LCDs yet.

it must of been something in the code that was grabbing the temperature data, when i tried a simple Hello World on each line it didn't happen.

i was/am using the 3 wire method with a 74LS164N.

Hi To all,

I am N.Nandhakumar from India. I am doing a project as part of my academics. I am doing a Datalogging project using EM-406a GPS and Arduino named "Tran-Duino"

I am also using the Adafruit GPS shield V1.1 and a 2-line JHD162a LCD display.

In the Arduino , pins 10-13 is used for sd card storage, pins 0-4 is used by GPS. I want to display the data the GPS logs into the sd card.

I have found the code for that, but since LCD display requires atleast 6 pins ,and the arduino is left with only 5 pins, I am not able to connect the LCD. If I do so, It just displays junk values :cry: .

Then I googled and I found the arduinoshiftreglcd library and tried it using 74HCT164N IC . But I am getting only the black Blocks in the first line of the display.

I followed the schematic given in this same thread . I am having a Arduino ATMEGA328 made by Bhasha Technologies, India.

I am using Arduino-0017 IDE in Ubuntu 9.10

Now My doubts are,

How to display text?

I can afford to connect the LCD with maximum 5 wires [ since that is the number of wires left in the arduino ] . So, It would be a great help If I get a interface less than that.

I also need help on how to display the text in 2 lines of the display

Please Help me out.

Waiting for your valuable suggestions

Thanks in advance

N.Nandhakumar :slight_smile:

Sparkfun has several serial LCD's. Here's one:

Only requires +5V, Gnd, and one digital pin.

have you connected the contrast controlling potentiometer to the lcd?

Thanks for the reply Mircho and PaulS .

I am using a variable resistor POT in the schematic .

But even when I tuned it , the black blocks only gets disappeared slowly but I am not able to get any text on it .

I am not able to identify the problem clearly . I have built the schematic using breadboard and also tried by directly soldering the wires to the IC using a IC Base.

In both the ways I get only the same output - black blocks.

Please give your suggestions. It will be of great help if I build the circuit using the shift register .

Regards

N.Nandhakumar

You have listed pins 0-4 and 10-13 as being used in your sketch, but you have not said that you are using any of the analog pins.

If you are not using the analog pins for any other purpose, you can use them as digital pins, referred to as numbers 14 (analog input 0) to 19 (analog input 5). You then have 11 pins available for output, not the 5 you think you have.

Hello!

How are you connecting the LCD/shiftregister? Via two or three wires? As stated, some (me included) had trouble getting the two-wire method to work with a HC family shiftregister. I am not sure why though. I guess the same applies to HCT. You can either try with a LS type shiftregister, or use the three-wire method (unless you are already doing that, in which case I do not know what the issue is).

Maybe if you posted the code related to the LCD it would help, as well as the schematic you use for the LCD.

Also, as TBAr explains, the analog inputs 0 to 5, can be used as digital I/O 14 to 19.

I am also using Ubuntu 9.10 and usually arduino-0017 btw, but I do not think that is the issue.
I have an old HD44780 compatible one-line LCD as well as a 2-line LCD named "JHD202C", which both works fine with the library.

As for using your 2nd line, you must first initialize the display correctly. The functions are explained in the usage page.

Initialization

#include <ShiftRegLCD.h>

ShiftRegLCD srlcd(Datapin, Clockpin, Enablepin or TWO_WIRE [, Lines [, Font]])

Or, if using three wires, and a 2-line display. Enable will be on pin 8:

#include <ShiftRegLCD.h>

ShiftRegLCD srlcd(12, 13, 8, 2);

and

Cursor positioning

srlcd.home();  // Set cursor position to zero

srlcd.setCursor(column, row); // Sets cursor position




Remember row begins at row 0 (zero), for the first line. Also column begins at column 0.

Hope this helps.

Hi Folks,

Can anyone tell me if the NTE brand NTE74LS164 is suitable for use with ShiftRegLCD. I'm not sure what the significance of the "N" is in the part number.

For some background?
I've had no luck getting ShiftRegLCD to work using a 74HC164N and, most recently a NTE74LS164. I've tried both 2 wire and 3 wire circuits and checked my wiring so many times that I am seeing it in my sleep. I think I may have blew out the HC and it seems like the LS is the way to go at any rate. My LCD works fine when hooked up parallel and the contrast setting is the same.

Thanks!