Using Arduino > Programming Questions

Driving more than 1 LCD via Shift Registers

<< < (2/4) > >>

Korman:

--- Quote ---Is it just not feasible to use the shift registers?
--- End quote ---


Yes, you can use shift registers to drive multiple displays with shift register, although you will have to adapt the library a little. On the Aduino, you still just need your 3 lines, dataout, clock and latch.

What's necessary? The usual 44780 display in 4 bit mode  is driven with 6 lines: 4 data lines DB0-DB3, the RS line to select command or data mode and E line to latch the data. If now you want to drive more displays, you can share DB0-DB3 and RS between all displays and have one individual E line for each display. So on your 74hc595 with 8 lines, you can use up to 3 pins for individual E lines thus driving 3 displays with one 74hc595. The remaining 5 are used for the common DB0-3 and RS.

You now just need to adapt the Serial LCD library - which I don't have at hand at the moment, to set the correct E line on the 74hc595 to high (and toggle to back to low) and make sure the E lines for the other displays are set to low. If you need even more display, cascade another 74hc595 to get up to 11 displays and tell your library to shift out one more byte for the additional E lines. If you want to write in parallel (for example to clear all displays at the same time), just toggle all respective E lines to high and back t the same time. Just make sure, you always send the whole command to all of them - the command word plus all pieces of the data.

Korman

rizla420:

--- Quote from: Korman on May 24, 2011, 04:33 pm ---

--- Quote ---Is it just not feasible to use the shift registers?
--- End quote ---


Yes, you can use shift registers to drive multiple displays with shift register, although you will have to adapt the library a little. On the Aduino, you still just need your 3 lines, dataout, clock and latch.

What's necessary? The usual 44780 display in 4 bit mode  is driven with 6 lines: 4 data lines DB0-DB3, the RS line to select command or data mode and E line to latch the data. If now you want to drive more displays, you can share DB0-DB3 and RS between all displays and have one individual E line for each display. So on your 74hc595 with 8 lines, you can use up to 3 pins for individual E lines thus driving 3 displays with one 74hc595. The remaining 5 are used for the common DB0-3 and RS.

You now just need to adapt the Serial LCD library - which I don't have at hand at the moment, to set the correct E line on the 74hc595 to high (and toggle to back to low) and make sure the E lines for the other displays are set to low. If you need even more display, cascade another 74hc595 to get up to 11 displays and tell your library to shift out one more byte for the additional E lines. If you want to write in parallel (for example to clear all displays at the same time), just toggle all respective E lines to high and back t the same time. Just make sure, you always send the whole command to all of them - the command word plus all pieces of the data.

Korman

--- End quote ---


Korman, thanks for the higher level overview of the process involved.  The problem for me is that i'm not that strong of a coder, especially when dealing with OOP which the library is written with.  So i dont understand exactly how one function/class will pass certain parameters to the helper (objects?).  I looked at the code for the ShiftLCD library and it seems well documented and straight forward, but for example i cant even figure out where the print command is utilized.

So even if i were to use your approached and tie everything together except for the E line to toggle.  I dont know how i'd pass the unique display data for an individual lcd.  The typical usage is like this:


--- Code: ---
ShiftLCD lcd(2, 4, 3);

void setup() {
  // set up the LCD's number of rows and columns:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("First LCD");
}

--- End code ---


Ideally, it would haev to work like this:


--- Code: ---
ShiftLCD lcd1(2, 4, 3);
ShiftLCD lcd2(2, 4, 3);

void setup() {
  // set up the LCD's number of rows and columns:
  lcd1.begin(16, 2);
  // Print a message to the LCD.
  lcd1.print("First LCD");

  lcd2.begin(16, 2);
  // Print a message to the LCD.
  lcd2.print("Second LCD");
}

--- End code ---


Anyhow, i dont think I have the requisite skills to pull it off.. :~

Korman:
The parts you care about that need to be adapted are just the lines containing EN_SWITCH in ShiftLCD.cpp. All EN lines should always be set to high, except when you strobe one to pass data. Extending the library to work in 4 bit mode with two displays connected to pins 2 and 3 on the shift registers should be fairly easy. If you need help on this, post your hardware setup and where you connect what. I hope I can look into it later or tomorrow. Be warned, I'm on the road without an Arduino, so you'll have to do all the testing.

Korman

floresta:

--- Quote ---So Don, seeing that you've actually weighed in on this all across the forums on multiple sites.  Is it just not feasible to use the shift registers?  Whats the disadvantage?  Code bloat?
--- End quote ---


I've been using LCD modules for decades and have them pretty well figured out so I respond to lots of LCD threads.  I don't think I have answered too many shift-register questions since I have no actual experience with the general purpose ones and only limited and very recent experience with the Microchip IO Expander.  

There's really no reason not to use the shift registers with the LCDs.  The main disadvantage of any serial data transfer technique (compared to parallel) is the loss of speed.  Since the typical LCD implementation requires many time delays this loss of speed is immaterial.  Another disadvantage with most shift register LCD implementations is the loss of the ability to read the busy-flag to determine when the LCD is ready for another operation.  The majority of LCD applications do not require this capability and consequently this is really not a serious deficiency.

Korman's clear and concise explanation (middle paragraph) would apply to the use of the IO expander chip as well.  I think that the big difference would occur when you wanted to drive more than 3 LCDs.  Using the 74HC595 it looks like you max out at three LCDs.  Using the MCP23017 you can drive 8 LCDs using the straightforward technique I mentioned previously and you could get 3 more if you implemented their enable lines on the unused pins of the port that drives the data and rs lines.  You might even be able to do all this by using (or modifying) the library described here: http://koenwar.wordpress.com/io-expander-library/ .

So aside from the less than trivial problem of the software, using the IO expander gives you the ability to drive more LCDs with one chip, an easier (I think) route to adding more chips, and all this with one less Arduino pin.  If you want to use three pins then you can use the MCP23S17 chip which uses SPI rather than I2C and take advantage of the higher speed of this interface.

Don

floresta:

--- Quote ---All EN lines should always be set to high, except when you strobe one to pass data.
--- End quote ---


Shouldn't that be low, or is there some inversion going on with the shift register?

Don

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version