Electronic – arduino – 74hc595n shift register error

74hc595arduinoshift-register

I want to put in series 2 74hc595N . I made the schematic from here:

figure1

When I send a value the first register sends it also to the second one. I have same value on both. I change them (master/slave) but the result is the same. What I am doing wrong because several days ago I made it and it worked…. I can't figure it out.

Best Answer

Albert's ice cream parlor

Albert, Bob, Charlene, and Daisy are lined up in alphabetical order.

Albert is in the role of the CPU, scooping the ice cream. First he scoops out the date-raisin ice cream and hands it to Bob -- even though Bob hates raisins! Then Albert scoops out the chocolate-chip ice cream, and also hands it to Bob. Finally, Albert scoops out a brown cow float, and also hands it to Bob.

Bob, Charlene, and Daisy are in the role of the '595 daisy chain queue. It works like a conveyor belt. If everything works out right, Daisy gets the date-raisin ice cream, Charlene gets the chocolate-chip ice cream, and Bob gets the brown cow float.

Occasionally the CPU drives a positive-going transition on the "latch pin", also called a "storage register clock pin", on pin 12 of the '595. This is like Albert yelling out, "All done. Enjoy the ice cream in front of you!"

Then everyone is happy. (Even Bob, who hates raisins, is happy).

hardware

It looks like your hardware is fine -- the CPU MOSI output (in your case the Arduino pin 2) is connected to the MOSI input of the first '595 pin 14; and the daisy-chain MISO output from the first '595 pin 9 is connected to the MOSI input of the second '595 pin 14.

software

I'm pretty sure we're seeing a minor programming bug or a minor conceptual bug: Why do some people think that "255" is something special?

It sounds like the software is sending 8 bits to the first '595 chip just fine.

Every time you send a byte to the first '595 with shiftRegister.send(), whatever data is currently in that first '595 gets pushed out of it and into the second '595. That's the way daisy-chaining shift registers is supposed to work. The second '595 in the chain is always active.

Often we have a long chain of '595 chips, and we only want to update the value in the first one in the chain. The only way to do that with the normal daisy-chain configuration is for the program in the CPU to remember every value in every '595 chip, and re-send all the values. The johnny-five shift-register program probably needs to do something like:

var first_595 = 24;
var second_595 = 10;
var third_595 = 5;
// ...
// Always send all three values, in this order:
shiftRegister.send(third_595);
shiftRegister.send(second_595);
shiftRegister.send(first_595);

Some people find it a little backwards that the first value the CPU pushes out is the value for the last '595 chip in the chain; and the last value the CPU pushes out is the value for the first '595 chip directly connected to the CPU.

What can I say? That's the way Albert's ice cream parlor works.