Daisy chain 74HC595 causes issues

Hi folks,

I am trying to cascade 3 shift registers (74HC595) to run 3 large seven segment display (4 inches each). I am using ULN2003 as display drivers between the 7 segments and each shift register. I have been successful in running the first digit. However, when I hook up the second 74HC595, it even messes up the output of the first digit which was previously working fine.

I have done a fair bit of debugging and here is a list of when I have checked without any success:

  1. GND and VCC (drawn from 7805) of each IC is correctly connected.
  2. The serial out of the first IC is connected to data of second.
  3. CLK and LATCH pins are common in both ICs.
  4. I have tried putting on 220nF disk caps next to each 74HC595 (I saw this on other threads but it appears to not help in my case).

I am sharing the schematic and relevant part of code. I am open to all suggestions. Please share your thoughts!

Ps. I am using ESP32. But, I think it should not make much difference.

Thanks,
Usman

int strobePin = 27; //Pin connected to Strobe 
int dataPin = 14;  //Pin connected to Data 
int clockPin =26;  //Pin connected to Clock 

int shiftOutBuffer[3]={0};
byte segChar[]={ //.gfedcba 0, 1, 2, .. 9, all off
  0b00111111,  0b00000110,  0b01011011,  0b01001111,  0b01100110,  0b01101101,
  0b01111101,  0b00000111,  0b01111111,  0b01101111,  0b00000000,
};
int counter = 231;
void update_display()
{
  digitalWrite(strobePin, LOW);
  delay(100);
  shiftOut(dataPin, clockPin, LSBFIRST, segChar[shiftOutBuffer[0]]); 
  shiftOut(dataPin, clockPin, LSBFIRST, segChar[shiftOutBuffer[1]]);
  shiftOut(dataPin, clockPin, LSBFIRST, segChar[shiftOutBuffer[2]]); 
  delay(100);
  digitalWrite(strobePin, HIGH);
  // Serial.println("updated data successfully");
}
void update_shiftOutBuffer(){
  shiftOutBuffer[2] = counter % 10;
  shiftOutBuffer[1] = (counter / 10) % 10;
  shiftOutBuffer[0] = (counter / 100) % 10;
}

void setup(){
update_shiftOutBuffer();
update_display();


}
void loop(){
  

}

The bypass caps for each 74hc595 should be 0.1uF ceramic.

How did you connect your bypass caps? Please update the schematic.

Did you change the sketch at the same time as attaching the second '595?

What cap values are you using with the regulator?

You could try powering the 74hc595 from 3.3V.

You could replace the 74hc595 and uln2803 with tpic6b595.

Hi, @usman_ashraf678
Welcome to the forum.

Thanks for the basic information in your first post. :+1:

Do you have a DMM.
Measure the 5V supply and the 12V supply when the problem occurs?
What value capacitors do you have at the 7805, consult the data sheet for info, place them as close to the regulator leads as possible.

What are you using for your 12V power supply?

Do you have this on protoboard, or have you made a PCB?

Can you please post a picture(s) of your project?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Really great ideas Paul. Appreciate your input!

I am using ceramic capacitors but won't 220nF have almost same effect as 100nF. I have updated the schematic. The caps are attached between Vcc and GND of the 74595 close to the IC. I am attaching a picture to show how close and you can judge the length of the cap wires.

The sketch remains the same throughout. I think the problem is with the hardware. I have tested multiple codes but the same issues appears although the exact digits displayed may change.

I am using 220nF ceramic on 9V input of the 7805 and 0.1uF on the output of 7805.

I have read about tpic6b595 and looks a good option but it's not available in my city.

You're suggesting 3.3V directly from MCU? How could using 3.3V help?

Thanks,

Hi Tom,

Here's a picture mate!

I have placed the caps around 7805 fairly close. On the input side (9V), it is 220nF (ceramic) and on output side, it is 0.1uF (electrolytic). Both are fairly close. Please check the picture shared.

The 9V is a adjustable bench top power supply. It is rated for 15V 2A and my circuit only takes 200-250mA. I have a PCB.

I'll check the voltages and report back.

Thanks again,
Usman

I would think it's probably ok, so only change those later if nothing else works. But 0.1uF is normal, so I would always use those from the beginning.

Are these the values recommended in the 7805 data sheet? They don't sound big enough to me, unless you meant 0.1mF = 100uF?

0.1uF are not normally electrolytic.

Also please clarify the input voltage. You mentioned 9V a couple of times but your schematic shows 12V. That doesn't make any difference to the cap values you are using in the input (as long as the cap's rated voltage exceeds the input voltage) but it will affect the power dissipation in the regulator (higher input voltage == higher power dissipation == more heat).

Yes, might be worth trying. The 74hc595 are powered with 5V, so their inputs are expecting a 5V signal, but the esp pins only output 3.3V signals. In theory, this should be ok, but it's possible that it's right on the edge of working, so that with one '595 connected it just about works but with 2 it doesn't quite work. Powering the '595 with 3.3V would fix that, and because the Uln inputs are sensitive (high gain) and current driven, I don't think 3.3V signals would be a problem there.

If course, trying this is not so easy on a PCB. So, again, try this only as a last resort. I always prototype on breadboard, and test the circuit is working as close as I possibly can to the final version before designing a PCB.

Are you having a leg pull here?

Of course 220 nF is better than 100 nF! You apparently missed the reference to "disk caps" in the OP. I am not aware of (or cannot recall) disk capacitors other than ceramic. The capacitors are not as close to the 74HC5895s as you would prefer but do not seem too likely to be a problem.

Unfortunately we do not seem to have the actual code to check, so we do not know whether the three control pins have actually been set as OUTPUT. :roll_eyes:

Can't image what the delay(100); is supposed to do!

I only recommended 100nF over 220nF because that's what is suggested in the data sheet. And I did say I thought 220 would be ok!

Me too. But maybe you missed this:

That makes no sense! :crazy_face:

If you replace the Arduino shiftOut() function with your own code, then you choose how the clock and data timing is. Then you can even make it very slow to be able to measure the signals with a multimeter.

This is a Wokwi simulation with just digitalWrite() for the clock and data: https://wokwi.com/arduino/projects/301213976182653448.

1 Like

Thank you so much with your input guys.

I checked with the code and figured out it was fine!
@PaulRB, @TomGeorge: I figured out that the problem was either on the shift register side or on the 7805 side. To isolate the two, I removed the 7805 and instead used my laptop usb to power the ESP and used the same 9V from the bench top supply to power the displays.
The good part is it worked with the usb power. That means something is wrong on the 7805 side. I have checked the data sheet and it says 0.33uF on the input and 0.1 uF on the output. I have tried 0.22uF on both input and output but that hasn't worked. I am going out to procure 0.33uF and 0.1uF ceramic and see if these work. The goal is to make it work with the 7805. I think we are getting close!

Thanks for your suggestions guys. Open to hear more!

Usman,

Hi,
What are you using for the 9V supply to the LM7805?
I can't see it in your picture, does the 7805 get warm?

If you measure the 5V while the problem is occurring, does it change?
Do the same with the 9V on the input to the regulator, see if it changes?

Tom... :smiley: :+1: :coffee: :australia:

Clearly if the 7805 chooses to oscillate due to incorrect stabilisation, that will upset the shift registers - and in unpredictable ways.

1 Like

Ok, then I would put those ceramic caps in, but also add a couple more electro caps, perhaps 10uF on input and output and see if that helps. If not, try 100uF. If that still does not work, maybe replace the 7805 in case it's faulty.

Is there any ground plane on the back of the board? With traces that long and thin, you may have some ground loop and supply loop issues due to resistance and inductance in the traces...

Also, where is the 3.3V-5V level shifter between the SR's and the ESP? There is a risk of damage to the ESP pins without them. Also you lose a significant amount of noise immunity without them.

A lower valued bypass capacitor is better at filtering higher frequencies. Here, on page 15, it says:

Each VCC pin should have a good bypass capacitor to prevent power disturbance. For devices with a single supply, 0.1 μf is recommended; if there are multiple VCC pins, then 0.01 μf or 0.022 μf is recommended for each power pin. It is acceptable to parallel multiple bypass caps to reject different frequencies of noise. A 0.1 μf and a 1 μf are commonly used in parallel. The bypass capacitor should be installed as close to the power pin as possible for best results.

1 Like

Hi,

The difference in 0.1uF and 1uf or even 10uF, is type of capacitor.
0.1uF has better capacitor type properties at high frequencies.
1uF or 10uF, usually electrolytic are lousy high frequency capacitors, but good a low frequencies to DC.
Good Dave Jones Tutorial.

Tom... :smiley: :+1: :coffee: :australia:

2 Likes

In your update_display function, you have long delays relative to the speed of the IC. Although not creating an issue, there's an opportunity to significantly shorten them.

More importantly, I think its better to pulse the latch signal when ready rather than letting it sit high for a period of time while other code is processing. In other words, make it normally low, then pulse it high-low when ready to latch the output register.

Something like this:

void update_display()
{
  shiftOut(dataPin, clockPin, LSBFIRST, segChar[shiftOutBuffer[0]]); 
  shiftOut(dataPin, clockPin, LSBFIRST, segChar[shiftOutBuffer[1]]);
  shiftOut(dataPin, clockPin, LSBFIRST, segChar[shiftOutBuffer[2]]); 
  delay(2);
  digitalWrite(strobePin, HIGH);
  delay(2);
  digitalWrite(strobePin, LOW);
  // Serial.println("updated data successfully");
}

Perhaps adding an inter-byte delay would be helpful?

void update_display()
{
  shiftOut(dataPin, clockPin, LSBFIRST, segChar[shiftOutBuffer[0]]); 
  delay(2);
  shiftOut(dataPin, clockPin, LSBFIRST, segChar[shiftOutBuffer[1]]);
  delay(2);
  shiftOut(dataPin, clockPin, LSBFIRST, segChar[shiftOutBuffer[2]]); 
  delay(2);
  digitalWrite(strobePin, HIGH);
  delay(2);
  digitalWrite(strobePin, LOW);
  // Serial.println("updated data successfully");
}

Why would they be in any way necessary? We are dealing with HCMOS shift registers, not old CMOS. Particularly since the digitalWrite function does not code to a single machine instruction anyway - or does it?

Funny ... no one mentioned the delays when they added up to 200ms.

Anyways, many possible reasons. Looking at the board pic:

  • long track lengths from IC to IC ... clock or strobe signal reflection issues?
  • flux between tracks/pads ... leakage issues?
  • no conformal coating ... humidity or electrical isolation issues?
  • propagation issues due to above?

Also, more here.

It's easier just to try some strategically placed small delays and see if they resolve the problem, then delete any unnecessary delay(s).

However, the clock and strobe signals operate on the hardware in parallel for all bits, much faster than a single machine instruction.


EDIT: Looking back through this thread, yeah, I would put level shifting as the number one concern!