Ground Loop Issue

Hello Everyone,

I am a hobbyist who has a fair bit of experience with Arduino but not as much with electronics and I have come across a problem that seems to be impeding my progress. In short, I believe I have a ground looping problem with my system.

I wanted to create a back-up system for my main PCB (STM32) that would change valve angles depending on the input. The valve was attached to a servo (Tower Pro MG90S) and that was connected to the main PCB. This part worked fine but I wanted to add a backup system that would move the valve to the specific position if the power was cut from the main PCB. So devised a second system (atmega328p) that would be battery-powered and read the voltage level from the power supply (dropped down to a manageable 5v with a regulator). When it reads 0, the atmega tells the servo to move in the closed position.

Problem: The servo vibrates when the main PCB is powered and the atmega is also connected to the servo motor. I did a bit of research and it seems the main problem is that there is a voltage difference between the grounds of the battery (9v) that is powering the atmega and the 12v supply that is powering the main PCB (the potential difference is about 5v). I cannot use the 12v for the atmega as it's main purpose is to function when the main PCB is down. Current also seems to be leaking to the power supply from the Arduino even though I have placed diodes at all power connections. I know a typical solution is to separate the power sources but I am unsure how to do that since the PCB and the atmega both need to have access to the same servo.

Another issue is that there seems to be a lot less power going to the servo motor when then the atmega tries to turn the valve when the main PCB is off. I have checked the voltage and current and they both seem normal so I am unsure as to why the servo has less power when both MCU's are operational. It only happens when both MCU's are on; if either is turned off, the servo works fine.

I am curious to know your thoughts on this.

Arduino Code:
<

#include <Servo.h>
#include "LowPower.h"


Servo servo;  // create servo object to control a servo
// twelve servo objects can be created on most boards




int trigger = 11;
int angle = 90;
int current_angle = 0;
int state = 0;
bool fixed = true;
int led = 13;


void setup() {
  servo.attach(9);  // attaches the servo on pin 9 to the servo object
  pinMode(trigger, INPUT);
  pinMode(led, OUTPUT);


}




void loop() {


  state = digitalRead(trigger);


  if (state == 0) {
    if (!fixed) {
      servo.attach(9);
      current_angle = servo.read();
      servo.write(current_angle + 45);
      delay(30);
      digitalWrite(led, HIGH);
      servo.detach();


      fixed = true;
    }
  }
  else {
    digitalWrite(led, LOW);
    servo.detach();
    fixed = false;
  }




}

Schematic of system.jpg

Schematic of system.jpg

One problem you're likely to have is that the Arduino can't provide sufficient current to power the servo, especially if it is doing real work. All it can do is control it.

Is there a way to increase the amount of current without adding an additional power supply?

Create one single point and name it GND. Then connect all GNDs from PCB, servo, controller, power sources to that point.
What kind of pwr source is that 9 volt supply?

Briskgotmethrough:
Is there a way to increase the amount of current without adding an additional power supply?

Yes. You can add a driver.

@Railroader, It's just a 9v energizer battery (off the shelf).

If that battery is the kind that goes in a smoke detector, it's too puny for this purpose.

Hmm ok. Is there an alternative way to power the atmega that is as compact as a 9v? I want to stay away from using wall outlets for the backup board.

Briskgotmethrough:
@Railroader, It's just a 9v energizer battery (off the shelf).

Tha cell will tun the controller but not any servo, nor valve etc.

Railroader Do you have any recommendations for current drivers?

Also, I want to clarify that the valve will only move 90 degrees (at most). and will not have to do any further operation until the main PCB is turned on and off again. The atmega shouldn't be doing a tone of work.

Finally, is there any concern with connecting GRDs of different power sources that have a potential difference between those grounds? It kind of seems like it would create a short circuit.

A logic level N-channel MOSFET connected between the negative of the load and to GND.

Ir does not matter how small movement is. That 9 volt cell doesn't work.

Why, how, is there a potentional difference?

Not as compact as a 9V battery but this can dump 5V1A if need be. Is the 9V power output required?

Battery shield

I don't know why you would think that you have a ground loop. You simply don't have enough power to move the servo as evidenced by the servo vibrating.

"I did a bit of research and it seems the main problem is that there is a voltage difference between the grounds"
Did you measure this with your DMM? If you have ANY potential between grounds, then one of them is floating. Except for vanishingly rare circuits, you want ALL grounds connected together.

What is the mystery PCB?
What is the 5V block between the battery and Vin?

SteveMann,
would simply attaching these grounds together get rid of that difference? Also, I did use a DMM to measure.

The PCB is simply an stm32f103c8t6 on a board that opens closes an air valve when a pushbutton is engaged. The back-up board was just in case the power was cut and really just an after thought.

The block is a 5v regulator

Where did You measure, how, to think there is a difference betwee grounds?

Aren't ground loops something that happens to beginning pilots?

Paul

Paul_KD7HB:
Aren't ground loops something that happens to beginning pilots?

Paul

Only in tailwheel aircraft.