Chaining of shift registers not working

Hi,
I am trying to control 5 RGB LEDs using two 74hc595 shift registers. I tried this on Wokwi and on a breadboard before finally soldering the layout. No with the soldered version I just don't get it working properly anymore.

This is the general layout (here in Wokwi, but with more unrelated components: Wokwi - Online ESP32, STM32, Arduino Simulator):

And this is how the actual wiring looks like:


The header pins are connected to their neighbors on the backside of the board.

Now when I try the following code:

int latchPin = 10;
int clockPin = 12;
int dataPin = 11;

int32_t leds;

int32_t get_color_bits(char c){
  if (c == 'r') {
    return 0b001;
  } 
  else if (c == 'g') {
    return 0b010;
  }
  else if (c == 'b') {
    return 0b100;
  }
  else if (c == 'y') {
    return 0b011;
  }
  else if (c == 'w') {
    return 0b111;
  }
  else {
    return 0b000;
  }
}

void  setup(){
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}
void  loop(){
  int32_t speed_led = get_color_bits('r');
  int32_t force_led = get_color_bits('r');
  int32_t acc_led = get_color_bits('r');
  int32_t gyro_led = get_color_bits('r');
  int32_t result_led = get_color_bits('r');
  leds = (result_led << 12) | (gyro_led << 9) | (acc_led << 6) | (force_led << 3) | speed_led;
  shiftOut(dataPin, clockPin, MSBFIRST, (leds >> 8) & 0xFF);
  shiftOut(dataPin, clockPin, MSBFIRST, leds & 0xFF); 
  digitalWrite(latchPin, LOW);
  digitalWrite(latchPin, HIGH);
  delay(500);
}

The two LEDs controlled by the shift register that is directly connected with the data pin of the Arduino are correctly lit up in red. However the outputs of the second shift register are all high no matter what. Now I thought maybe I was unlucky and somehow damaged the second shift register during soldering. So I switched the order of the two shift registers and the I was able to control the second one, but the outputs of the first one are all set to high.

What am I missing here? I double-checked that everything is connected properly. And also switched the little solid core wire that connects the two registers with a jumper cable, to check if maybe the wire is damaged. But I can't find any reason for the behavior that is happening.

  • First off, your register I.C.s each need a 100nF ceramic de-coupling capacitor from their Vcc pins to the GND pins.
    As close as possible to these pins.

  • Triple check your soldering and wiring.

Hi @LarryD thanks for your reply! Oh, I didn't know about the de-coupling capacitor. I will check how I could include those and then come back to let you know if it changed the outcome :slight_smile:

Hi @LarryD I added the capacitors between the Vcc and GND pins, but the problem that the second shift register has all outputs on high still persists :frowning:

+1

Not only that it's correct but also look for solder bridges - inadvertent connections between adjacent pins - use a magnifying glass. If using stranded wire check also for any 'whiskers' making contact with adjacent pins/devices.

  • Show us close up images of the perf board top and bottom.

Hi @LarryD Thank you so much for sticking with me. Really appreciate it! Here are images of the top and bottom of the perf board.


@LarryD Sorry the images here get quite severly compressed. The original images are here:

Google Photos
Google Photos

Disregard. I see you need to bridge between pads.

Apply flux and wick-away about half the solder on each joint.
They should not look like "bubbles," looking for a "tent" look.

  • You need to fix up the connections.

Strive for this quality.

  • Review these:

The reverse side is this... solder bridges across traceless pads

I'd probably set the latch pin LOW, then do the two shiftOut operations, then set the latch HIGH. But maybe just pulsing the latch at the end, as you are doing, works with a 595 shift register.

That inverting the order of the shift registers appears to transfer the problem to the other side seems to imply that the wiring is correct.

@loetamateur

I've had a play around with the code for the LEDs. My conclusion is that there is a short to HIGH on the second register data line input.

I'm also with @6v6gt on this...

Hacked your code in the Wokwi, run this as it introduces the issue, cycling every 5 seconds...
Although I'm a little puzzeled as to why you have 3 white leds, as you can only drive 2 and 2bits from 1 register.

Although I'm a little puzzeled as to why you have 3 white leds, as you can only drive 2 and 2bits from 1 register.

You are correct! The 5th LED is of course not white, but violet, the green LED is off.

Could you explain what that death pin is doing in the code? I don't quite understand it I am afraid. Should I add this wire?

Ah I get it. You were able to simulate the isse. Okay, that means I have a high on the data pin for some reason, right?

My little joke :grin:
It's to introduce the "kiss of death" to the setup, by shorting the second register data input to HIGH. Reproducing what is wrong with your perf board soldering. And no you wouldn't put that in your code.

Yeah, you got it!

Ah, okay. So I guess using these solder brides to connect neighboring pins is not really the way to go :sweat_smile: I think I have all the parts to try the whole thing again. To place these small (30 AWG?) bare wires, I probably need to buy proper tweezers. Thanks for all the good information. That tips thread is pure gold!

I've been following this but not been able to help as I've not spotted anything that would cause a problem. However, one thing to note is I never solder ICs directly into prototype board, I solder a socket into the board then plug the IC into the socket. Doing so makes them a lot easier to replace if needed.

Yes, that is definetely a lesson I learned here.

It can be done, but your ideal tools would be a fine point soldering iron with fine gauge solder wire. And good eyesight :slightly_smiling_face: