Author Topic: Solved - Microcontroller resets when power is shared  (Read 7641 times)

0 Members and 1 Guest are viewing this topic.

Offline rodcastlerTopic starter

  • Regular Contributor
  • *
  • Posts: 98
  • Country: cl
Solved - Microcontroller resets when power is shared
« on: July 03, 2014, 07:14:00 pm »
Hi, I have an ATMEGA 328 with a very simple code running. Let's call this Circuit A.
 
It shares the 5v rail with another circuit called Circuit B, in parallel.

As soon as the current requirements of Circuit B exceeds 200mA (IL), the ATMEGA on Circuit A resets itself, every time.

Questions before I continue my troubleshooting:

- Am I missing anything very basic here?. I would expect to not see this issue at all. If the Power supply can deliver, I would expect each parallel circuit to consume whatever they need without interfering with each other.

- How can I isolate the two circuits without using independent power supplies?

What I have tried so far to troubleshoot:

1) Try different power supplies, all capable of delivering 2A, same issue.
2) Replace Circuit B for a simple electronic load. It works well until I hit 200mA, it then resets the Atmega.
3) Measured the voltage drop at the supply. It is constant at 5v and delivers clean 200mA. Also measured the Atmega, it only draws 13mA (Im).
4) I added a series resistor to CIRCUIT B to limit its current. That allows me to get up to 600mA without experiencing the issue. This is great, BUT now the voltage drops too much on Circuit B when using the limiting resistor so this won't fly.
5) Checked the reset pin. I'm pulling it up with a resistor but I also tried by connecting it directly to 5V to be sure there was not a voltage drop at the reset pin.

Pending:

More testing and troubleshooting, probably capacitors here and there and more measuring, use the scope and see if there is noise or something.


Edit: Added image for clarity. uC is Circuit A and "load" is Circuit B.
The two resistors in series and stuff in light blue are NOT part of the current circuit but stuff I have tried.
« Last Edit: March 04, 2015, 02:03:19 am by rodcastler »
 

Offline madworm

  • Frequent Contributor
  • **
  • Posts: 371
  • Country: de
Re: Microcontroller resets when power is shared
« Reply #1 on: July 03, 2014, 07:50:57 pm »
Read the contents of MCUSR and see what reset source was specified (POR / BOR).

http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=96314&start=0

Did you look at the signal with a scope? Maybe your power supply starts oscillating or sagging, which you may not see using a DMM. Add the usual capacitors to the supply lines. Ideally use a different supply for the high(er) current part. If circuit B uses PWM switching high currents on and off, the supply voltage may suffer and cause the micro to reset. Especially if there is insufficient capacitance on the supply lines.

Increase the capacitor next to the microcontroller.
« Last Edit: July 03, 2014, 07:52:30 pm by madworm »
 

Offline rob77

  • Super Contributor
  • ***
  • Posts: 2085
  • Country: sk
Re: Microcontroller resets when power is shared
« Reply #2 on: July 03, 2014, 08:13:23 pm »
probably not enough decoupling ?

just add decoupling caps everywhere 100nF ceramic + 10uF tantalum (or low ESR electrolyte) for every chip (as close as possible).

it might be caused by ringing as well -  minimize the ringing if there is any (better decoupling might help a bit)

and actually recently it happened to me that i killed an atmega with ringing - shared the 5V rail with a DDS board and a 74HC14 as a output stage for square wave - at few MHz the ringing was so bad it killed the atmega.

so definitely  check the rail with a scope as it was suggested already.
 

Offline rodcastlerTopic starter

  • Regular Contributor
  • *
  • Posts: 98
  • Country: cl
Re: Microcontroller resets when power is shared
« Reply #3 on: July 04, 2014, 03:36:54 am »
Good job! you guys nailed it.

It's nastier than I thought. After adding some decoupling caps to the 5v rail, I can still see a full 5v drop there although it only lasts 1ms.

Circuit B is a larger board with caps and stuff. It runs perfectly on the same power supply but seems like the ATMEGA is too sensitive to run alongside.
Using a separate power supply for the Atmega on Circuit A solves it but I was hoping I could still run these two on the same power supply.

Any way to get rid of that large drop?
« Last Edit: July 04, 2014, 01:12:47 pm by rodcastler »
 

Offline rodcastlerTopic starter

  • Regular Contributor
  • *
  • Posts: 98
  • Country: cl
Re: Microcontroller resets when power is shared
« Reply #4 on: July 04, 2014, 03:55:22 am »
This is what I see at the RESET line (previous image shows the main 5v rail).

It drops a volt and it seems to be enough to reset the chip.
If I use a relay, it gets worse at the reset line.

I did add a .1uF ceramic cap from Reset to GND but seems like it's not enough.
 

Offline ludzinc

  • Supporter
  • ****
  • Posts: 506
  • Country: au
    • My Misadventures In Engineering
Re: Microcontroller resets when power is shared
« Reply #5 on: July 04, 2014, 04:07:55 am »
Hi

This is a common problem we all run into while learning.

Ideally, if you can run extra regulators for each sub-circuit off a higher rail, that helps, even better if you can isolate each rail with a diode.

(See example here: http://ludzinc.blogspot.com.au/2013/04/cutting-out-middle-man.html  - ignore the 'current limit' circuit, it's more smoke machine than current limiter).

The idea with the diodes is that if you put bulk storage on your supply (C VERY BIG in the pic) if something (for example) depletes C1 on VOUT 1 (i.e. heavy load just switched on) C2 on VOUT 2 still has enough charge to keep devices on that rail operating.

Of course, if your switched load can deplete C1 *and* C Very Big you then need to beef up the capacity of your 5V supply (more power).


 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 4228
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: Microcontroller resets when power is shared
« Reply #6 on: July 04, 2014, 06:04:00 am »
If you've tried two completely separate power supplies, and still have the problem, then no amount of fiddling with separate regulators, diodes or whatever is going to help.

I think the problem is grounding. When your load draws current from its supply, that current goes back through a common ground path and raises the ground potential at the uC. Since every other pin voltage at the uC is measured with respect to that ground, the uC sees a voltage dip.

Check your physical layout carefully. Are you using a PCB / stripboard / breadboard?

Try to ensure that the heavier load has a return path back to the power supply that is NOT shared with the uC, so any voltage drop in the ground leads caused by that current is not seen by the uC.

Also try connecting your scope probe ground lead to the point where your power supply connects to the board, then probe the ground pin of the uC and see what's going on. In an ideal world you'd see exactly 0V, but I bet you don't.

Offline ludzinc

  • Supporter
  • ****
  • Posts: 506
  • Country: au
    • My Misadventures In Engineering
Re: Microcontroller resets when power is shared
« Reply #7 on: July 04, 2014, 06:22:55 am »
If you've tried two completely separate power supplies, and still have the problem, then no amount of fiddling with separate
regulators, diodes or whatever is going to help.

OP actually said:

Using a separate power supply for the Atmega on Circuit A solves it

I think the problem is grounding. When your load draws current from its supply, that current goes back through a common ground path and raises the ground potential at the uC. Since every other pin voltage at the uC is measured with respect to that ground, the uC sees a voltage dip.

Check your physical layout carefully. Are you using a PCB / stripboard / breadboard?

Try to ensure that the heavier load has a return path back to the power supply that is NOT shared with the uC, so any voltage drop in the ground leads caused by that current is not seen by the uC.

Also try connecting your scope probe ground lead to the point where your power supply connects to the board, then probe the ground pin of the uC and see what's going on. In an ideal world you'd see exactly 0V, but I bet you don't.

But none the less, your point about ground returns is very valid.  Ah, good old ground bounce...
 

Offline rodcastlerTopic starter

  • Regular Contributor
  • *
  • Posts: 98
  • Country: cl
Re: Microcontroller resets when power is shared
« Reply #8 on: July 04, 2014, 01:12:18 pm »
Agreeed: I actually tried diodes instinctively at some point but then removed them. My next task is to go for this clear diode arrangement proposed which makes a lot of sense.

Using two parallel power supplies solves the problem 100%. I didn't realize that at the time of the original post, but I found out later on.
I'm still trying to get it to work on a single power supply just because I like what I am learning with this exercise.

That doesn't change the fact that grounding could possible be a big issue here and I will take a good look at that as well...

I have the impression that the micro controller can keep up with the huge drop at the main rail, but can't keep up with the ring at the reset line. Would this be a wrong assumption? From a troubleshooting perspective it seems like I should definitely go for solving the large drop at the main rail first but maybe some of you may think that it would be better to stabilize the reset line first? what are your thoughts on that?
 
« Last Edit: July 04, 2014, 01:15:38 pm by rodcastler »
 

Offline madworm

  • Frequent Contributor
  • **
  • Posts: 371
  • Country: de
Re: Microcontroller resets when power is shared
« Reply #9 on: July 04, 2014, 02:22:15 pm »
Fix your GND issue and you'll be good. The ringing on the reset line is probably a direct consequence of the GND bouncing around, which is what the micro sees locally. You can try measuring the reset line on the micro in two ways. 1) connect the DSO's GND clip directly to the chip itself. 2) connect the GND clip directly to the power supply. You might see a difference. Number 1) is what matters to the chip.

Star-grounding may help. Essentially route / wire your board in such a way that all the high current paths run separately from your logic components (including GND of course). Think high-way vs. bike-lane. You want to keep them separate till the very last point. Connect both power-ground and logic-ground at the point where your power-supply connects to the big storage capacitor for the rails. Assuming your power-supply can actually cope with the load, this should improve things. If the 5V rail still dips down, use a bigger supply + caps.
 

Offline rodcastlerTopic starter

  • Regular Contributor
  • *
  • Posts: 98
  • Country: cl
Re: Microcontroller resets when power is shared
« Reply #10 on: July 06, 2014, 04:19:02 pm »
thank you all. I got it working after implementing your suggestions.

Great exercise to realize the importance of diodes, proper grounding and decoupling in this kind of circuit.

Also proves that even for beginners and simple circuits, an oscilloscope can make the difference between success and frustration.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf