Power supply common ground crashes Arduino

Hello All,

I've been working on a hardware project with my Arduino, and I'm running in to an issue for which I simply cannot find an answer. My project involves the use of two power supplies; one to run a stepper motor, and another to power the Arduino through the barrel connector. I had my project up and running, but occasionally the Arduino would stop responding to commands and block the serial port.

After a bit of Googling (which landed me on this forum), I found several similar questions that all suggested that the problem may lie in how the supply grounds were connected as a common ground. I looked in to star grounding and mitigating ground loops, but despite my efforts I still couldn't get my design working reliably. Confused, I started unplugging components until I was left with attached circuit (apologies for the poor drawing skills).

I uploaded the following minimalist sketch to the board:

void setup() {
    Serial.begin(9600);
}

void loop() {
    unsigned int counter = 0;
    
    while(1){
        Serial.print("Alive: ");
        Serial.println(counter);
        counter++;
        delay(1000);
    }
}

I have both power supplies plugged into the same power bar. When I start the serial monitor with the power bar switched off, the serial monitor shows an incrementing counter as expected. As soon as I switch the power bar on, the serial output immediately stops and the Arduino does not reset when the reset button is pressed. I should clarify that the Arduino is connected via USB to my computer as well.

Is there some basic principle that I'm missing here? An advice would be greatly appreciated!

groundcircuit.PNG

Are all these supplies mains-isolated?

Is there some basic ....

Yes you are missing what exactly you are trying to do and also an adequate explanation of what you have done. That "circuit " is not adiquate to explain anything.

All power supply grounds must be connected together. That normally means the negitave connection of each power supply. Forget ground loops and star connections, they won't stop something working they might stop something working quite correctly if you don't do it but you will still get a function.

MarkT:
Are all these supplies mains-isolated?

Hmm...fair question! To be honest, I'm not entirely sure, they are a couple of wall-wart style adapters that I had lying around. They appear to be in working order, but in terms of isolation, I can't say with certainty.

Grumpy_Mike:
Yes you are missing what exactly you are trying to do and also an adequate explanation of what you have done. That "circuit " is not adiquate to explain anything.

Well, I'm not sure what else I can tell you. That "circuit" is literally all that I have connected to the Arduino. The sketch I posted is all that's uploaded to the board. I gave you the hardware and software, if there's some other explanation that would make my post a more "adequate explanation", please elaborate.

I read through your guide on power supplies, since I noticed that doing so was a common recommendation on these forums. But based on the guide, my understanding was that hooking all the negative connections together should not pose an issue.

If the serial monitor is on a different house circuit than the "power bar" you could have a ground loop problem in the house wiring.

The supply that you connect to the DC jack. Is it regulated (universal mains voltage).
An old/heavy/transformer based 12volt unregulated supply could output more than 17volt unloaded.
12volt is already high for an Arduino. 7.5volt(minimum) or 9volt regulated would be better.
Or use a 5volt cellphone charger with USB socket/lead if/when you're not using the computer.

Not sure what your code does.
"while()" is blocking. Stops the loop().
Leo..

jremington:
If the serial monitor is on a different house circuit than the "power bar" you could have a ground loop problem in the house wiring.

Jremington, you are fantastic. I decided to test your theory by modifying my sketch to blink the onboard LED tied to pin 13. I uploaded the new sketch, unplugged the USB cable and switched on the power bar. As I write this, it's still blinking away happily.

Armed with this new information, I decided to try some different USB ports on my PC. My PC has mostly USB 3.0 ports, but there are a couple of USB 2.0 ports on the back (for some reason). Oddly enough, connecting both power supplies while the serial monitor is hooked to a USB 2.0 port works just fine...I can't help but wonder if perhaps the USB 2.0 and USB 3.0 ports are grounded in a different manner internally?

In any case, thanks for the suggestion! I was hoping that people would throw out some ideas, I'd run with them and eventually I'd sort out the issue...I just didn't think it would happen so quickly!

Wawa:
The supply that you connect to the DC jack. Is it regulated (universal mains voltage).
An old/heavy/transformer based 12volt unregulated supply could output more than 17volt unloaded.
12volt is already high for an Arduino. 7.5volt(minimum) or 9volt regulated would be better.
Or use a 5volt cellphone charger with USB socket/lead if/when you're not using the computer.

Not sure what your code does.
"while()" is blocking. Stops the loop().
Leo..

Hmm...fair point! I've measured the voltage drop across my 12V wall wart, and it's closer to 11.4V. According to the Arduino Mega page, the recommended input voltage range is 7-12V, so I think I should be OK on that front. In terms of the code, the while(1) loop is there so that I can declare my counter variable within the scope of the loop() function. The rationale for doing so is to avoid globally scoped variables when possible.

Thanks to all who tried to help!

CtrlAltDeplete:
I have both power supplies plugged into the same power bar. When I start the serial monitor with the power bar switched off, the serial monitor shows an incrementing counter as expected. As soon as I switch the power bar on, the serial output immediately stops and the Arduino does not reset when the

What happened to the green power LED during this incident? If that also went out, you were probably shorting 5V to GND somehow when you turned the power bar on or accidentally applying the 12V to a place where it shouldn't be. If some of the experimentation in #6 involved rewiring some things in the project, you might have fixed the problem by accident without knowing. Fixing it by moving from a 2.0 to a 30 USB port certainly doesn't make much sense.

If your 12V supply has only 2 mains pins (no earth pin), it is mains isolated and cannot cause any ground loop issue. It's more likely that you accidentally miswired something.

Hi,
Welcome to the forum.

Can you please post a picture of your project?
Can you tell us your electronics, programming, arduino, hardware experience?
Can you please post a copy of your full circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
The diagram you supplied does not even show how or what the Arduino does or is connected to?
What model Arduino do you have?

Thanks.. Tom.. :slight_smile:

Jiggy-Ninja:
What happened to the green power LED during this incident? If that also went out, you were probably shorting 5V to GND somehow when you turned the power bar on or accidentally applying the 12V to a place where it shouldn't be. If some of the experimentation in #6 involved rewiring some things in the project, you might have fixed the problem by accident without knowing. Fixing it by moving from a 2.0 to a 30 USB port certainly doesn't make much sense.

If your 12V supply has only 2 mains pins (no earth pin), it is mains isolated and cannot cause any ground loop issue. It's more likely that you accidentally miswired something.

The green power LED remains on, oddly enough. A possible short was my first thought too, which is why I started disconnecting components until I was left with the circuit in my original post. I'm quite confident that I didn't miswire something, as the only connection was to the ground pin of my Arduino.

To thicken the plot, I've found that if I plug my computer power supply into the same power bar as the Arduino, the Arduino locks up again. If I plug my computer power supply into another outlet, everything is fine. Both power supplies I use for my Arduino are two prong, but my PC power supply is three-pronged (i.e., with a ground pin). Regardless of where the PC power supply is plugged in to, the Arduino always locks up if it's plugged into the USB 3.0 port.

Now, admittedly, my understanding of ground loops isn't particularly strong, but I'm curious about your statement "If your 12V supply has only 2 mains pins (no earth pin), it is mains isolated and cannot cause any ground loop issue". Are you sure that's correct? My understanding is that the negative terminal would be "ground" in this case. Are you certain that the absence of an earth ground negates the possibility of a ground loop? That seems to contradict some of the reading that I've done on the subject.

TomGeorge:
Hi,
Welcome to the forum.

Can you please post a picture of your project?
Can you tell us your electronics, programming, arduino, hardware experience?
Can you please post a copy of your full circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
The diagram you supplied does not even show how or what the Arduino does or is connected to?
What model Arduino do you have?

Thanks.. Tom.. :slight_smile:

Thanks for the welcome! I'm an engineer, although I've been out of school for a while so most of hardware knowledge that I have is a little fuzzy. I write embedded software for aeronautics now, so I would say that my software knowledge is very strong, but my hardware knowledge is pretty poor.

Since you're the second person to ask for more information on my posted circuit, I'm going to clarify this point: the circuit in my original post is all that is connected to the Arduino. Just the negative terminal from the power supply, that's it. There are no other connections or hardware connected to the Arduino, just the single wire into the GND pin. Which is why I came here, as everything I knew about grounding suggested that it should work. As I mentioned in my reply to Grumpy_Mike, I'm happy to provide more information about the circuit if you elaborate on what that might be in this case, because what I posted is all that's connected.

I should have mentioned in my first post that I'm using an Arduino Mega.

RE; you original circuit-

what you have drawn will not work with a standard led. The 90K resistor is in parallel with the led, which really serves no purpose. The led needs a current limiting resistor based upon the Vf and current requirement of that particular led. Then that resistor needs to be placed in series, unless you are using a current regulated supply, in which the resistor is still not doing anything.

I also won't go common ground unless the power from both units (led circuit and arduino) are tied to the same circuit.

Perhaps draw up the circuit you are trying to create and then it can be solved. A bad connection on the ground circuit can cause funny and odd things to happen. The ext supply could be junk too.

I'm still not clear what's going on.

Pretty much all of the low-power wall warts that produce a regulated voltage to charge phones or power some other piece of consumer electronics (like your router or something) will use a flyback convertor to step down the mains AC voltage to the appropriate DC. The outputs of these will be completely electrically isolated from the mains input. If you check for continuity between any of the mains pins and any of the barrel contacts, you should find an open circuit.

Transformer isolation is the way that ground loops are fixed. Ground loops are only possible when there is a continuous path for current to flow through between the different grounds. Transformers break that, and a 2-pin DC adapter will already have such a transformer in it. It is simply not physically possible for that kind of power supply to cause a ground loop through the mains wiring unless it is faulty.

You might call the negative terminal "ground" for the purpose of your circuit, but it will not be connected in any way, shape, or form the earth, neutral, or hot lines in the mains plug. It will be almost as isolated as if you had powered that part of your circuit with a battery.

Your problem statement is too ambiguous for me to try and figure things out.

  1. What exactly is in that extra circuit connected to your Mega? As tinman mentioned, an LED in parallel with a resistor hooked to 14V just doesn't make sense.

  2. Are you sure that single ground wire is all that's connected the Mega and the extra circuit?

  3. Exactly what power supplies are you using? Be as specific as you can (pictures won't hurt), and if you bought them online link to the product page. You have an unknown 14V supply and a 12V barrel supply in the original schematic, but also mention a "computer power supply" in the replies. Are you using this as a supply for the project, or is it referring to the PC with the USB 2.0 and 3.0 ports you're testing?

To thicken the plot, I've found that if I plug my computer power supply into the same power bar as the Arduino, the Arduino locks up again. If I plug my computer power supply into another outlet, everything is fine. Both power supplies I use for my Arduino are two prong, but my PC power supply is three-pronged (i.e., with a ground pin). Regardless of where the PC power supply is plugged in to, the Arduino always locks up if it's plugged into the USB 3.0 port.

That doesn't sound like a ground loop. I'm not sure what exactly it sounds like, but it doesn't sound like a ground loop.

Your reporting of this issue has been a bit haphazard so far. When you are troubleshooting an issue like this it is extremely important to be thorough in recording the situations you have tested and what works and what didn't in each situation. Make a table explicitly recording what is plugged in where, and whether the Serial and LED worked. I've attached an excel file as an example of what I'm talking about, and filled in one row to represent this situation so you know the kind of thing I'm talking about:

Jremington, you are fantastic. I decided to test your theory by modifying my sketch to blink the onboard LED tied to pin 13. I uploaded the new sketch, unplugged the USB cable and switched on the power bar. As I write this, it's still blinking away happily.

Power Supply Troubleshooting Table.zip (6.63 KB)

From what I gather, you have 3 supplies. Two for the Arduino (5V USB and 12V wall wart) and one for the stepper motor.

I think the problem is that there is a small period of time during switch-over from Vin to USB power (or vice-versa) that the Arduino has no power but the stepper motor circuit is still powered. Is this condition delt with in your circuit? (please show).

Does the problem go away if you disconnect the stepper power, then test the transfer form USB to Vin or Vin to USB?