Hi
I am planning to use 2 pcs of 74HC595 shift registers for extended outputs and for LCD display.
Since the libraries are different, I just want to know would it be possible to allocate same Arduino pins for SHCP, STCP for both 74HC595?
Hi
I am planning to use 2 pcs of 74HC595 shift registers for extended outputs and for LCD display.
Since the libraries are different, I just want to know would it be possible to allocate same Arduino pins for SHCP, STCP for both 74HC595?
What libraries?
What LCD display?
What "extended outputs"?
Thanks for your response.
MultiShiftRegister for extended digital outputs.
ShiftedLCD for a 16x4 LCD.
Yes. See "Example 2"
I think it's much easier to use an I2C backpack for those 1604 LCDs.
Actually, I need 14 digital inputs and 13 outputs + 2 or 6 for LCD. But I am left with only 5 digital outputs.
So I decided to use 3 x 74HC595.
Digital outputs ------> Library MultiShiftRegister uses D13 for STCP, D11 for SHCP and any other pin for DS.
LCD ----------------> Library ShiftedLCD uses D13 for STCP, D11 for SHCP and any other pin for DS.
I know how to cascade 74HC595 but I am confused that in my case do I need to cascade all three 74HC595 or only 2 of them. Please see following examples of configurations to understand what I mean.
CONFIGURATION (1)
ARDUINO 595(a) for Outputs 595(b) for Outputs 595(c) for LCD
D13---------------> STCP------------------> STCP ------------------> STCP
D11---------------> SHCP------------------> SHCP ------------------> SHCP
D4----------------> DS
Q7* (pin 9)-------------> DS
D6-------------------------------------------------------------------> DS
CONFIGURATION (2)
ARDUINO 595 for Outputs 595 for Outputs 595 for LCD
D13---------------> STCP------------------> STCP ------------------> STCP
D11---------------> SHCP------------------> SHCP ------------------> SHCP
D4----------------> DS
Q7* (pin 9)-------------> DS
Q7* (pin 9) ------------> DS
I would not suggest either of your configurations 1 or 2.
What do you need these inputs and outputs for? If you need to read and write to the outputs at maximum speed, then you should be using the hardware SPI feature. If you are using hardware SPI, then you have to use the same fixed pins for DS and SHCP. But you can use different pins for STCP. That way, you can chain two of your shift registers (sharing the same DS, SHCP and STCP pins) and the third register can be not chained (sharing the same DS and SHCP pins as the others but with a separate STCP pin). I suspect the ShiftedLCD library will not work if the register connected to the LCD is chained.
But if you do not need maximum speed, then I2C is easier, and uses fewer Arduino pins. You can use an I2C backpack for the LCD, as suggested above, and use PCF8574 (8 input/outputs) or PCF8575 (16 inputs/outputs) or MCP23008 (8 input/outputs) or MCP23017 (16 input/outputs) instead of 74hc595.
PaulRB:
I would not suggest either of your configurations 1 or 2.What do you need these inputs and outputs for? If you need to read and write to the outputs at maximum speed, then you should be using the hardware SPI feature. If you are using hardware SPI, then you have to use the same fixed pins for DS and SHCP. But you can use different pins for STCP. That way, you can chain two of your shift registers (sharing the same DS, SHCP and STCP pins) and the third register can be not chained (sharing the same DS and SHCP pins as the others but with a separate STCP pin). I suspect the ShiftedLCD library will not work if the register connected to the LCD is chained.
Yes, I need the outputs at maximum speed. Would you please guide me what pins I should use for SHCP, STCP and both DSs for chaining 2 registers for outputs and 1 for LCD.
"Maximum" is not a specification. How fast do you actually need? What Arduino do you have?
Configuration 1 seems likely to work. What happened when you tried it?
MorganS:
"Maximum" is not a specification. How fast do you actually need? What Arduino do you have?Configuration 1 seems likely to work. What happened when you tried it?
I have Arduino Nano ATMega 328P.
Either of the configuration is not working in Proteus. I will check physically tomorrow, then I can tell the actual behavior.
abuhafss:
Yes, I need the outputs at maximum speed.
How many updates per second? Give us a number.
abuhafss:
Would you please guide me what pins I should use for SHCP, STCP and both DSs for chaining 2 registers for outputs and 1 for LCD.
CONFIGURATION (3)
ARDUINO 595(a) for Outputs 595(b) for Outputs 595(c) for LCD
D9-----------------------------------------------------------------> STCP
D10(SS)-----------> STCP------------------> STCP
D13(SCK)----------> SHCP------------------> SHCP ------------------> SHCP
D11(MOSI)---------> DS---------------------------------------------> DS
Q7* (pin 9)-----------> DS
Note: You must use D13 and D11 as shown if using hardware SPI on atmega328. Other pins could be used instead of D9 and D10, but D10 must be used as an output, so you might as well use it for one of the STCP pins.
abuhafss:
Library ShiftedLCD uses D13 for STCP, D11 for SHCP and any other pin for DS.
Not correct. With this library you must use D11 for DS and D13 for SHCP. This is because it uses hardare SPI. See this page.
abuhafss:
Library MultiShiftRegister uses D13 for STCP, D11 for SHCP and any other pin for DS.
Also not correct. This library allows you to specify any pins for STCP and SHCP. But this library does not use hardware SPI and so will not give you the maximum speed you say you need. Actually, this library uses the shiftOut() function, which is quite slow and maybe slower than using I2C bus.
PaulRB:
CONFIGURATION (3)ARDUINO 595(a) for Outputs 595(b) for Outputs 595(c) for LCD
D9-----------------------------------------------------------------> STCP
D10(SS)-----------> STCP------------------> STCP
D13(SCK)----------> SHCP------------------> SHCP ------------------> SHCP
D11(MOSI)---------> DS---------------------------------------------> DS
Q7* (pin 9)-----------> DS
Note: You must use D13 and D11 as shown if using hardware SPI on atmega328. Other pins could be used instead of D9 and D10, but D10 must be used as an output, so you might as well use it for one of the STCP pins.
Based on this information I simulated in Proteus, I am getting unexpected results. Also no display on LCD.
Here is the code:
#include <SPI.h>
#include <ShiftedLCD.h>
#include <MultiShiftRegister.h>
const int latchPin = 10; // to 12/STCP of Output 595
const int clockPin = 13; // to 11/SHCP
const int dataPin = 11; // to 14/DS
const int LCDlatchPin = 12;
MultiShiftRegister msr(1, latchPin, clockPin, dataPin);
LiquidCrystal lcd(LCDlatchPin);
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(LCDlatchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
lcd.begin(16, 2);
lcd.print("hello");
}
void loop()
{
msr.clear(0); // LED at Q0 - off
msr.set(7); // LED at Q7 - on
msr.shift();
delay(100);
lcd.setCursor(0, 1);
lcd.print(millis()/1000);
msr.clear(7); // LED at Q7 - off
msr.set(0); // LED at Q0 - on
delay(100);
}
Proteus? No idea, sorry. Maybe ask on Proteus forum.
What happens on a real Arduino/shift register/LCD?
Okay, just verify if the connections shown in the schematics are correct.
I'll check with real circuit tomorrow and report.
ARDUINO 595(a) for Outputs 595(b) for Outputs 595(c) for LCD
D9-----------------------------------------------------------------> STCP
D10(SS)-----------> STCP------------------> STCP
D13(SCK)----------> SHCP------------------> SHCP ------------------> SHCP
D11(MOSI)---------> DS---------------------------------------------> DS
Q7* (pin 9)-----------> DS
I'm not certain if it is a good idea to use D12 like in your schematic and the link I gave you before. D12 is MISO, which is a hardware SPI pin, and you need to use hardware SPI for that LCD library. When using hardware SPI, MISO (Master In Slave Out) is an input pin, used to read serial data into the Arduino from, for example, a 74hc165 shift register. You said
Actually, I need 14 digital inputs
You could use 2x 74hc165 to give you those inputs. They also can be chained, would need to use D12 and share D13 and possibly D10 with the 595s.