I'm currently struggle getting two chained shifting registers (SN74HC595) to work with the Arduino Nano 33 IoT. Everything works fine with an Arduino Nano Every, Nano ESP32 and Uno R3.
Using a simple code example that activate/deactive each output, one by one, so only one output of the shift register is active at the same time.
I get some unexpected behaviour, when talking to the first shift register everything seems to work fine but as soon as I trigger the second one the problems start to begin. Problems are, two ore more outputs are active at the same time or no output is active (but should be). The output is inconsistent, I can not see a pattern.
When replacing SPI with the ShiftOut()-function the exact same problem occur.
Here is the code example I'm using. As described above it just activate/deactivate each output, one after another.
Here's a simplified schematic. I haven't drawn wires for Vcc and GND. I have an external power source (5V) connected to Vcc of each shift register.
OE is connected to GND.
SRCLR is connected to Vcc.
A LED is connected to every output so I can visually see what happens.
As mentioned above the output follows no real pattern (in my opinion) but there are some cases that seems to happen very often. I therefore created this little table, it may be helpful?! Normally only the output that shares the same value as i should be active.
For me the most interesting part is the first entry in the table. Because when i == 7 I'm sending 10000000b to the first shift register and 00000000b to the second one. So why is output 8 (first output of the second shift register) active?
value table
i
active outputs
7
7, 8
9
9, 10
11
11, 12
13
13, 14
14
14, 15
15
no output active
I have no ideas (and skill) to figure out what is happening here. Since the code works fine with three other boards I may think it has something to do with the Arduino Nano 33 IoT. Is there something special about this board? Does my board malfunction?
Thanks for any help and ideas. Have a nice evening.
2. OP is advised to use level shifter (Fig-2) among Nano 33 IoT, DS, SH_CP, ST-CP for which he requires a 5V supply at the High Side of the level shifter. Should work; if not, efforts are to be made to find the problem.
The first chip is getting 3.3 V on all inputs and just happens to work, but the second one is getting 5 V from the first chip on SER, which might cause the problem.
EDIT
I was looking at the Texas Instruments datasheet, it does not have a 'typical' or 'nominal' value for VIH, just a minimum value.
The other boards are a Nano Every, Nano ESP32 and Uno R3. Yes I know that the IoT is a 3V board. As stated in OP I'm using an external 5V power source to drive the shift register. I used this external power source for all four boards and never used the onboard 5V (in case it existed).
Sorry, I have updated the schematic and drawn some more GND and Vcc lines.
I don't see how you address the different shift registers
Qh' is connected to SER of the next shift register. Both shares the same RCLK and SRCLK. That should be all? Even the documentation tells me to connect it like that to daisy chain shift registers.
Thanks for testing this but it seems like you were using an Arduino Nano in that simulation? As stated in OP the code runs fine for me on a Arduino Nano, Nano ESP32 and Uno R3. It's just the Nano 33 IoT that is not working properly.
As an experiment, what happens if you change the 5V supply to the 74HC595s to 3.3V from the Arduino Nano 33 IoT?
This would show whether or not the problem is caused, when operating on 5V, by the GPIO output of the Arduino Nano 33 IoT not being high enough to reliably cause the 74HC595 to see a logic 1. I know you tried another 3.3V Arduino that worked, but maybe it had slightly different GPIO high voltage
No! The SCLK (ST_CP) must be seperated - meaning each HC595 will have its own ST_CP clock line to latch the data at the input of the 3-state output buffer. Fig-1 (a tested Min-Sec Down Counter) may help to understand the functioning of two 74HC595 in casecade operation.
The VIH and VIL specifications of both 74HC595 and 74HCT595 are exactly nearly the same except that HCT596 is CMOS design. Then how HCT595 is going to solve OP's problem? //edit
Right!
'C' for CMOS , 'T' for TTL-compatibility and H for high-speed.
Thank you! I am editing my post #13.
When I have asked Google for 74HCT595 data sheets, I have thought that I have got the right data sheets. Now, I see that Google has supplied me the data sheets fo 74HC595. This is the cause of my errors!
Thanks for your suggestion.
I did tried that and it worked without any problems when using the 3.3V. I observed it for 30 minutes without any errors. I then turned on the 5V power source again and the problem returned instantly.
It seems like your guess is correct. Since I'm an absolute beginner I have no clue how to solve this problem. In my final application I need the 5V power source to drive some other ICs so it would be no solution for me to switch to a 3.3V power source.
Is there any way to handle this?
Typically, all of the clock signals will be shorted together, although they can be separated for unique cases.
I have seen some threads here where users need to seperate each latch pin but in my case I just want to use the registers the normal way (and not in an unique way).
If I follow your approach further. Let's say I want to use 30 chained registers. Do I need 30 latch pins?
I also wonder how the code would look like then. Like this?
So everytime I pull latch pin 1 down I need to pull latch pin 2 down, too and vice versa. So my understanding would be that I can short them together. Or do I miss something?
Thanks for suggesting that. Could you please explain to me why they should work? Sadly I do not understand very much of the data sheet.
This chip seems to be unavailable in my country so I have to import them. I would like to know why before I buy them.
@EmilyJane: since you metioned the same chip I would like to ask you the same question.
Do you have a schematic, block diagram, or IC list for your final application? Without more information suggestions for solutions may not be a good fit.