Has anyone used a shift reg for a 20x4?

Has anyone used a shift register for a 20x4 lcd? i've been looking at the lcd3wire but it seems to be designed for 20x2, will it work on a 4 line display?

Also the print statement seems very clunky, has anyone designed a more fluid way of printing text?

i've been looking at the lcd3wire but it seems to be designed for 20x2, will it work on a 4 line display?

Yes.

the print statement seems very clunky, has anyone designed a more fluid way of printing text?

Like transferring the words directly onto a screen using the power of thought alone?
What do you mean?

No need for the sarcasm!

The whole printing one character at a time thing and differences for numbers and text, just looking for a simple lcd.print and prinln, if no ones got one i'll just write one.

Also how does the cursor position work in hex? i mean in the usual positioning would be cursor(0,1) hex works different with no explanation.

Not slagging off the code for being clunky, im sure its a lot less memory hungry than what i want, im just trying to get a simple solution up to test my project, then i will have to optimise the memory usage.

No need for the sarcasm!

Arr go on.

The whole printing one character at a time thing

What?? No need for that. You can print strings, either literals or variables.

Also how does the cursor position work in hex?

Absolutely no different from using it with any other number base. In the end it is all just bit patterns.

hex works different

What makes you think that?

Oh god! its late, im looking at the wrong code!

Sorry, thanks for your help, its simple looking at the right code!

No problem. :slight_smile: :slight_smile: :slight_smile:

Sarcasm was justified eh!

Has anyone used a shift register for a 20x4 lcd? i've been looking at the lcd3wire but it seems to be designed for 20x2, will it work on a 4 line display?

As far as the LCD controller is concerned there is absolutely no difference between a 20x2 and a 20x4.

You should be aware that the LCD initialization sequence used in LCD3wire does not follow the recommendations in the Hitachi (or any other) datasheet. There's nothing new with that situation but it still baffles me. Not only is the sequence of instructions wrong but the technique used to send the initial commands is wrong as well. Also, the comment for the 'function set' command is wrong, but it is also wrong in the code that he used for a model and the author either did not know that or did not bother to correct it. Good luck with the rest of the code.

Don

You may want to have a look at this library by forum member fm.
It is a drop in replacement for the LiquidCrystal library:
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
It supports 4 bit parallel, 3 wire serial and 2 wire serial.

Once you declare your mode and pins with the proper include and constructor
it works no different than the LiquidCrystal library.

I've run it in 3wire and 2 wire modes on 74HC595 and 74LS164.

I've used it on both Arduino AVR m328 based boards as well as chipkit pic32 based boards
and it it is faster than the default LiquidCrystal library even on the AVR based boards.

I'm in the process of brining up an addition that will add support for talking
to the lcd display using a shift register but only 1 arduino pin. It isn't as fast as 2 or 3 wire modes
but can be useful for the ATTINY parts where pins are very limited.

--- bill

Bill (and others):

You should be aware that the LCD initialization sequence used in this replacement library also does not follow the recommendations in the Hitachi (or any other) datasheet. Again, there's nothing new with that situation but it still baffles me.

In this case it he has used the initialization code written by Lady Ada a few years ago. I exchanged Emails with her right after she released the code and she ultimately, grudgingly, agreed that I was correct - but the code has never been changed.

I am talking about the instruction that immediately follows the 'Function Set' instruction. This is technically a 'Display ON/OFF ' instruction which is normally used to control several aspects of the display. But this is apparently not the time to do so because the flow chart clearly shows the instruction as 00001000, not 00001DCB. This indicates that at this point in the initialization routine the Display (D), the Cursor (C), and the Blinking (B) should all be turned off by making the corresponding bits = 0.

There is no question that her code works but that is still not a good reason to not follow the datasheet. We are only talking about changing this instruction to agree with the datasheet and adding another 'Display ON/OFF ' instruction after the initialization to turn the display on again.

Don

OP, if you want a fluid experience on print, such as one instruction to print a mixed result of strings and numbers, you should read up on sprintf:

Do you by any chance have a Java programming back ground, where you can concatenate strings and numbers with a simple '+' operator? It won't work in C++, by the way.

floresta:
There is no question that her code works but that is still not a good reason to not follow the datasheet. We are only talking about changing this instruction to agree with the datasheet and adding another 'Display ON/OFF ' instruction after the initialization to turn the display on again. [/color]

Don

Don,
Contact forum member fm, I'm sure you won't have the same difficulties getting this library updated
as you have had with the Arduino/LadyAda library version.
So far it hasn't been very difficult to get updates into this version of the library.
Right now fm is bringing up the Vinciduino board, but once that is done,
there are some updates already slated for the next version of the library, I'm sure
you could get these kinds of updates in as well.

--- bill

liudr:
OP, if you want a fluid experience on print, such as one instruction to print a mixed result of strings and numbers, you should read up on sprintf:

sprintf | LiuDr Electronic Solutions LLC Official Blog

Do you by any chance have a Java programming back ground, where you can concatenate strings and numbers with a simple '+' operator? It won't work in C++, by the way.

I actually have a heavy programming background, using various languages from fortran 70 to C# and .net. Im well aware of the sprintf function, You could use the strcat function aswell for concatenation, however sprintf is a much better way of doing it.

That doesn't relate to the post though, if you actually read the whole postings, i read the wrong code, my bad yes, but then again you could always read the replies.
You'll have to excuse this error, after sitting all day scratching my head at bit reversal on outputs from a ferranti argus generally screws with my head so much im barely able to make a cup of tea.

To others looking for help in this post, the link from bperry seems to be the most up to date library for use, here is the direct link to the code though:

mattius:
To others looking for help in this post, the link from bperry seems to be the most up to date library for use, here is the direct link to the code though:

GitHub - marcmerlin/NewLiquidCrystal: LiquidCrystal library with object support to allow for multiple kinds of connections (3 wires through shift registers, or even a 2 wire SR hack) I2C support is unmaintained and probably broken

Marc's library looks like a very minor fork off fm's work.
The only difference looks like he added a new module that uses a slightly different wiring
between the shift register and the lcd than the _SR module and a new demo sketch.

One thing I would do differently if I were wiring this up myself (vs using an existing PCB)
and wanting to use this new _SR_LCD3.cpp module,
is that I'd hardwire the r/w line from the lcd to gnd rather than drive it from the
shift register. It isn't used by the code anyway (it is always set to low) since BUSY it not polled.
And by connecting it to ground, you can ensure that there is never a situation where the shift
register and the lcd are both trying to drive the same signal lines.

shift register pin to lcd function configuration is a messy.
There are several existing boards and implementations
out there that are electrically compatible but use different wiring between the lcd and shift register.

2 wire mode can't directly map nibbles to bits 4-7 on the shift register as bit seven
is part of the EN circuitry.

LadyAda's SPI/I2C board, for example, uses the same bits as the 3 wire _SR.cpp module (when in SPI mode)
but also uses bit 7 for the backlight.

I've been looking at using bit 0 for adding backlight control to 2wire implementations
and a future 1 wire implementation for fm's code.

There are also 3 wire shift implementations that use 8 bit mode on the glcd.
http://frank.bol.ucla.edu/AVR2LCD.htm
(this is currently not supported by fm's library)

I've talked briefly about this with fm, and we all agree that it an issue
and would be nice if it could be addressed,
but as of today, the user can not specify which shift register output bit is connected to which lcd function.

--- bill