Current stolen by motor?

Hi all,

I have a motor and a servo hooked up to my uno r3, they both work fantastically independently, but when I turn them both on at the same time, the motor is fine but the servo turns as far as it can and stops.

The motor and servo are powered by 4x 1.5v AA batteries (6v total).

What I think is happening is the motor is stealing the power, as it is of lower resistance than the servo?

If so, how can I stop this? My first thought are resistors but I don't have any high enough, I have up to 10M.

Thanks all!

(deleted)

But surely there is a way other than that? :wink: thanks though!

Or at least power them adequately!

A multimeter attached to the supply while they are operating would show if the
voltage is dipping. If it isn't dipping then the issue might be noise or EMI from
the motor.

My first thought are resistors but I don't have any high enough, I have up to 10M.

Your first thought is wrong in two respects:-

  1. You don't use resistors for this
  2. 10M is a very high value of resistor

Do the voltage measurement, get back to us and we can tell you how to fix it.

Hi thanks for your answers!!

I've measured the voltage going to the servo, it is around 5.38V when the motor isn't running, and 4.9V when the motor is running. It's very strange, its as if I have set the servo to go to 0 degree's, but I haven't. Here is a pic of circuit and my code.

#include <Servo.h>;

Servo myServo;

const int motorPin = 9;
const int servoPin = 10;
int currentPos;
int desiredPos = 85;
int submitPos = 250;
long previousMillis = 0;
long interval1 = 20;
unsigned long currentMillis;

void setup(){
  Serial.begin(9600);
  myServo.attach(servoPin);
  pinMode(motorPin, OUTPUT);
}

void loop(){
  
  currentMillis = millis();
  
  currentPos = myServo.read();
  
  smoothTurn();
  
  autoMated();
  
  myServo.write(desiredPos);
  
}

void smoothTurn(){
  
  if(submitPos == 250){
  } else {
   if(currentPos < submitPos){
     if(currentMillis - previousMillis > interval1){
       previousMillis = currentMillis;
       desiredPos++;
     }
   }else if(currentPos > submitPos){
     if(currentMillis - previousMillis > interval1){
       previousMillis = currentMillis;
       desiredPos = desiredPos - 1;
     }
   }
  }
}

void turnLeft(){
  submitPos = 55;
}

void turnRight(){
  submitPos = 105;  
}

void turnCenter(){
  submitPos = 85;  
}

void autoMated(){
  
  if(currentMillis == 4000){
    digitalWrite(motorPin, HIGH);
  }
  
  if(currentMillis == 8000){
    turnLeft();
  }
  
  if(currentMillis == 12000){
    turnRight();
  }
  
  if(currentMillis == 16000){
    turnCenter();
  }
  
  if(currentMillis == 20000){
    digitalWrite(motorPin, LOW);
  }
}

it is around 5.38V when the motor isn't running, and 4.9V when the motor is running.

So that says that your batteries are not supplying enough voltage at the current you are asking of it. So you need a better power supply or two sets of batteries.
This is nothing to do with your software.
Also you have no decoupling capacitors around your motor, this allows a lot of interference to be generated. See attached.

Solder a 0.1uF ceramic capacitors on the motor, and implement a pi filter on the supply to your motor. See the last diagram in the following link for the circuit.
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

solder_caps.pdf (299 KB)

Thank you I will look at your suggestion now! :slight_smile:

Also, I am assuming the servo needs 5v then?

Thanks!

Normally servos run at 6.5V but some run fine all be it a bit slower on 5V.

Thanks Mike,

I've hooked up another 4x 1.5v AA batteries, I'm still at the same voltage which is really strange?

I can run the motor and the servo on separate supplies, but I really don't want to. It's only a small car thing, I don't want loads of batteries to power it where possible!! :stuck_out_tongue:

Marshiewoo

I'm still at the same voltage which is really strange?

Are these fresh batteries? Have you measured them without the load?
Also what type are they? The zinc carbon types can not supply much current.
Better current is from the NiMh type but they tend to be a lower voltage.

Marshiewoo:
I can run the motor and the servo on separate supplies, but I really don't want to. It's only a small car thing, I don't want loads of batteries to power it where possible!

"No such thing as a free lunch."

You need the correct - adequate - batteries to power what you have. Alkaline AA cells would be the absolute minimum to power a small toy car, but even then will only have an hour or so of capacity, if that. NiMH maintain voltage better under load. There is a reason why model cars nowadays tend to use lithium rechargeables.

Yes I've been unfaithful! :.

I have 4x 1.2v ni-MH AA batteries, 4x 1.5v Alkaline AA batteries, and 1x 9v rectangular battery to power the uno (which I've now been told is junk).
All batteries are fresh, checked them all individually and also when they are in the cradle.

Marshiewoo

In that case they are insufficient to drive your loads. You might have to go to C cells or rethink your whole powering stratagy.

Thanks for your help Mike and others!!! I'm very new here and I feel very welcomed.

Marshiewoo