Intermittent 595 - Page 1
Forum section: electronics / projects

author: chipwitch
author_rank: Frequent Contributor
timestamp: March 22, 2014, 06:46:23 pm
content: I know this is a kind of broad question. Before you ask for a circuit or code or anything, I ask you to consider an answer from a purely theoretical perspective.I'm playing with a TI SN74HC595N on a breadboard (which may very well be the problem). I'm using a stand alone ATMEGA 328p to shift in data. The program is simple: alternate between shifting out 0xFF and 0x00. Delay(2500). Also in the loop is pin 9 alternates HIGH with the 0x00. In effect, it should look like a train crossing light or school bus lights. Perhaps, 80% of the time, the shift register output goes HIGH when it should. Otherwise, it just stays low.The breadboard is one of my best ones, though not a name brand. I've never had an issue with it. I don't know enough about using my scope to be confident I'd catch the data and clock pin events, so I haven't tried using it. I see no sign that there's a loose connection, such as flickering or dim LEDs. I've removed everything from the circuit except for a single output LED (595), current limiting resistor (330 ohm). Current around 8mA (2.7V across resistor). Enable is pulled LOW. The breadboard lays undisturbed.The simple alternating pattern should be simple to diagnose. High for 2.5 seconds, then Low for 2.5 seconds. I sat with a pencil and paper and for a couple minutes wrote down the output. This is typical: 10101010010101000101010... Purely random. No reasonable repeating pattern. No consecutive HIGH's. I've replaced the 595, but the results are the same.The atmega chip and the shift register circuit both share the same 5V input. Which is coming from an ATX power supply with a standard cap filtered LM350 regulated circuit. The regulator circuit is mounted to a solder board.Assume the circuit and program are correct. What might cause this behavior. Capacitance of the breadboard? Poor regulator? Bad connections?

author: chipwitch
author_rank: Frequent Contributor
timestamp: March 22, 2014, 08:16:30 pm
content: SOLVED!For posterity's sake... I found someone was having the same problem using a Parallax Propeller MCU. Seems the 595 doesn't like having the same voltage as the microprocessor. Since my microprocessor and the 595 were both being fed from the same 5V rails, I was getting semi-random output. On the Parallax website, it was determined sending the signal to the 595 through a buffer solved the problem for one member. It was further decided that a lower, alternate supply to the 595 would resolve the issue.I am running a very low load, a single LED operating at about 8mA. I simple fed the 595 VCC pin via a 100 ohm resistor to drop the voltage. My circuit is now working flawlessly.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 22, 2014, 08:49:13 pm
content: You weren't sending data and clock at the same time, were you..?Buffering one signal would easily account for setup time; toggling the bits in two separate instructions (sbi PORT, CLOCKBIT; sbi/cbi PORT, DATABIT; cbi PORT, CLOCKBIT) would do better.Supply bypass? Lead lengths?I've found high speed SPI on breadboard can be tricky; a series 47-100 ohm resistor and/or ferrite bead at the driving pin (MCU's MOSI, SCK, and chip selects; device's MISO) helps signal quality. Any signal bounce means extra clock edges for your flip-flops.Tim

author: krivx
author_rank: Frequent Contributor
timestamp: March 22, 2014, 08:49:53 pm
content: Quote from: T3sl4co1l on March 22, 2014, 08:49:13 pmI was just about to ask...

author: dannyf
author_rank: Super Contributor
timestamp: March 22, 2014, 09:28:08 pm
content: QuoteYeah, right.QuoteYeah, right.

author: sleemanj
author_rank: Super Contributor
timestamp: March 22, 2014, 10:39:06 pm
content: I'd say a lack of bypassing is the problem.Go back to the original, and put a cap between the 595's VCC and Gnd pins, probably doesn't need much, a 100nF ceramic is traditional. See if that changes things.

author: miceuz
author_rank: Frequent Contributor
timestamp: March 22, 2014, 11:05:51 pm
content: Quote from: chipwitch on March 22, 2014, 08:16:30 pmThat is NOT correct. Look at the datasheet of 595 - it says it can operate correctly on 5V supply.My guess would be either a missing bypass cap or problems with high speed SPI over a breadboard. Try lowering the SPI speed to see if it makes a difference.

author: chipwitch
author_rank: Frequent Contributor
timestamp: March 22, 2014, 11:46:46 pm
content: Okay... so you're all telling me the resistor didn't fix my circuit. My bad.

author: krivx
author_rank: Frequent Contributor
timestamp: March 23, 2014, 12:26:26 am
content: Quote from: chipwitch on March 22, 2014, 11:46:46 pmI think some of the replies here are a little harsh, but it's very likely that the resistor isn't fixing your circuit for the reasons that you think.

author: daedalus
author_rank: Regular Contributor
timestamp: March 23, 2014, 12:39:06 am
content: i would say that you have found a hack to solve your problem, but perhaps you haven't found the root cause, or a a solution that addresses that cause well. it would help to see a circuit diagram, photo of your breadboard setup, and possibly some sample code in order to provide better advice.Many of us have used 595s in all kinds of projects, and treated right they are very reliable. That said there a lot of things you can do accidently to get garbage out.If you post these things, then i'm sure people here will be able to give more constructive advice.

author: dannyf
author_rank: Super Contributor
timestamp: March 23, 2014, 12:42:54 am
content: QuoteI will give you a golden rule of debugging pretty much anything: make a list of things that you least suspect and start from there.Works wonders.

author: chipwitch
author_rank: Frequent Contributor
timestamp: March 23, 2014, 01:14:22 am
content: yeah.... I get it, krivx. No worries. I'm trying to find an equivalent schematic. TI datasheet just has the logic layout and doesn't show power rails. The circuit continues to work in spite of disconnecting all jumpers to vcc. I'm pretty tired, so I might have missed something. I'll attack this tomorrow with fresh eyes and report in. I'll post pictures then.

author: chipwitch
author_rank: Frequent Contributor
timestamp: March 23, 2014, 01:18:28 am
content: Quote from: dannyf on March 23, 2014, 12:42:54 amI prefer more scientific methods, but I can see why someone may prefer the method you suggest.

author: sleemanj
author_rank: Super Contributor
timestamp: March 23, 2014, 01:21:13 am
content: Quote from: chipwitch on March 22, 2014, 11:46:46 pmThere are many ways to skin a cat, some of them are not as good as others. "Reducing the voltage" to the IC is very unlikely to be the reason it's working, that's a side-effect, not the remedy.If (as many here suspect) it's not having a bypass cap that's the problem, then adding a bypass cap is the proper solution - and you'll have to learn about bypass caps at some point, so might as well be now.In brief; Fluctuations in the current drawn by all components (and noise in general) will cause fluctuations in the voltage seen at VCC, if the fluctuations are too great, strange things will happen. Adding a small cap from VCC to GND of each IC is effective to "prop up" the VCC so that the IC sees a much cleaner supply.

author: dannyf
author_rank: Super Contributor
timestamp: March 23, 2014, 01:24:18 am
content: QuoteA resistor or a diode or an inductor can also decouple two circuits, sometimes more effectively than a capacitor can.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 23, 2014, 01:27:09 am
content: Quote from: chipwitch on March 23, 2014, 01:14:22 amCMOS takes so little average current draw that it can be powered parasitically from incoming logic signals.Of course, along comes a little output load, or an unlucky combination of transitions, and the whole thing just falls to pieces.Tim

author: sleemanj
author_rank: Super Contributor
timestamp: March 23, 2014, 01:32:48 am
content: Quote from: dannyf on March 23, 2014, 01:24:18 amMaybe but that doesn't help the OP's understanding of the problem and what her resistor solution is actually doing.