SOLVED - Possible power issue with additional servo

NOTE - Fixes in last post by me.

Noob question about power and how to identify power issues when you only have a cheap radio shack multimeter and no clue.

My robot is a rover, I've been building it over the past few weeks. I had it operating with 4 small motors (like these, sorry no info http://www.amazon.com/Smart-Robot-Wheel-Motor-Yellow/dp/B00EBRLE7G), off an L298 dual stepper motor bridge board, along with an arduino uno r3, a SainSmart v5 Sensor Shield and 2 HC-SR04 ultrasonic sensors. It is powered by 6 AA's (new for this project). There is a power switch. The four motors are actually wired in pairs, so its not 4WD, but left side/right side (technically not 2WD).

Previous to this servo addition, and related code change, the robot works fine. I can revert it without issue as well.

I have updated the code to account for the new servo, used to rotate one of the ultrasonic sensors. The setup function is the normal pin setup stuff, followed by a series of statements activating the servo, and turning it a few times.

When I have this powered on by battery (USB not connected, turning power switch to ON), the robot appears to get stuck in the Setup phase. It kinda turns and repeats this, and the servo jiggles as it tries to perform the rotations. But it never moves past this.

When I plug in the usb from my computer (battery is still connected, power switch is off), it seems to behave as expected. It performs the setup procedure and then the serial monitor indicates it is moving on and behaving normally. (FYI - the motors will not turn in this setup, but a noise is heard likely when they try to draw power)

I know NOTHING about power, and I'm suspecting that I have exceeded the abilities of my power source (6 AA's). Is this a correct statement based on the info I've provided?

If I disconnect the new servo and disable the servo setup code, it works normally. So that tells me the issue is either with my servo control code, or the power. The pin under question is pin 4. ( HeadServopin)

Here is my related servo/pin code:

#include <Servo.h> 
Servo headservo;

const int EchoPin = 2; // Ultrasonic 1 signal input
const int TrigPin = 3; // Ultrasonic 1 signal output

const int RearEchoPin = 13; // Ultrasonic rear signal input
const int RearTrigPin = 12; // Ultrasonic rear signal output

const int HeadServopin = 4; // signal input of headservo

const int leftmotorpin1 = 9; //signal output of DC geared motor
const int leftmotorpin2 = 10;
const int rightmotorpin1 = 5;
const int rightmotorpin2 = 6;


void setup() {
  Serial.begin(9600); // Serial begin texting
  pinMode(EchoPin, INPUT);
  pinMode(RearEchoPin, INPUT);
  //   for (int pinindex = 3; pinindex < 8; pinindex++) {
  for (int pinindex = 3; pinindex < 13; pinindex++) {
    pinMode(pinindex, OUTPUT); // set pins 3 to 13 as outputs
  }
  Serial.println("Head servo activating.");
  // headservo interface
  headservo.attach(HeadServopin);
  //start buffer movable head
  headservo.write(90);
  delay(1000);
  Serial.println("Head servo 90 done.");
}

I think your diagnosis is plausible, Doctor.

Perhaps you could perform a test: Power the servo off it's own battery source (common ground with the Arduino) and see if that makes things go. If it does, I would think that would confirm things.

Have you tried a brand new set of batteries?

Also, you may find that AA alkaline batteries have plenty of volts but can't deliver current (Amps) as quickly as you need. If you try to draw too much current the voltage will fall temporarily and may be too low to drive the Arduino. Rechargeable AA batteries can deliver much more current for short periods but their voltage is lower (1.2v per cell rather than 1.5v).

And I presume you realize that if you draw current faster the battery will discharge more quickly.

...R

All that plus:-
You need to add decoupling capacitors accross the supplies.

Thanks for the responses. Of course it leads to more questions. :slight_smile:

I have no other power power source setup right now, so I need to buy something. I'm not interested in more AA cases as I view them as the devil. I've heard of folks using Lithium batteries (LiPo), but I have no clue the compatibility concerns that could exist with them and wiring concerns (like required capacitors). Same goes with ANY battery (I'm clueless here). :~

I have more AA batteries to test with, I just don't know how I can connect them without a case. Is a jumper wire in series of (how many AA's?) batteries sufficient? :blush: (And I need help on the capacitor point too)

So if I need/want to buy another battery "pack" that is more powerful than the 6 AA's, but not so much so that I need to become a guru at EE what would you all suggest? (Kind of the next step up in portable battery power). I have money, and no true urgency.

(And I need help on the capacitor point too)

http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

fr33z0n3r:
I'm not interested in more AA cases as I view them as the devil.

Give in to the Dark Side and get one just for testing. Give it away later if it offends you. $2 at Radio Shack.

Can't you put new batteries in the existing case to see if it makes a difference?

LiPo batteries need extra care. Each cell produces 3.7v so you can't replace 4 x 1.5v AA batteries with 4 LiPos. And LiPos need to be charged carefully or they may go on fire. You can get special LiPo chargers.

Using 4 x rechargable NiMh batteries in your battery case might be a simpler solution. You can also get cases for 6 AA cells.

Don't dismiss these battery cases they can be very useful as a quick source of power for testing even if you eventually decide on another solution for the long term.

...R

ok, for these prices, I'll get one.

But should I get a 4 or 8 AA case? Not sure what the concerns are, with having MOAR POWUR yet. help?

Or a C battery case (how many)?

MOAR POWUR HNGRY! :wink:

I think you need to do a little reading about volts and amps - they are very different.

Adding more batteries in series (i.e. + connected to -) increases the voltage. This is the usual arrangement in those AA battery cases.

Adding batteries in parallel (i.e. + connected to + and - to -) increases the capacity (amp hrs) but not the voltage.

The amount of instantaneous current (amps) you can get from a cell depends to a large extent on the cell chemistry and the size of the cell. Generally speaking rechargeable batteries can provide more instantaneous current than alkaline batteries. However if you draw too much current from a rechargeable battery you may damage it or cause a fire.

If something is designed for (say) 6v which can be provided by 4 alkaline AA cells it will be damaged if you connect a higher voltage, but not if you connect a lower voltage.

If something needs (say) 2 amps at 6v and you connect a battery that can only provide 1 amp it just won't work properly.

...R

Thanks for the info Robin2. I have started looking into it, and it'll take me some time to figure out next steps.

Went to a local makerspace and got the same suggestion to separate the power sources.

They suggested a 9V, so I'll have to buy a battery holder for that.

Finally solved the issues. Phew. Learned a bit here. My rover would act fine with one change, and then break with the next. I tried all sorts of code changes until :

Issues -
a) servo was not working properly.
b) Motors driven by pins 9 and 10 were not properly activating.

Notes and Fixes:

  • 1 - PWM on pin 9 and 10 cannot be used on the UNO if a servo is attached. (Servo - Arduino Reference) I had a servo attached. I have updated my code to detach it when not being used, but it STILL didn't completely solve the motor issue. So I switched to a Arduino Mega 2560. PWM just works on pins 2-13. Motor issue solved.
  • 2 - Separated power source in case it was the cause of the servo startup problem. Using a 9V to DC for the Arduino (Mega). Removed Power connection from Motor shield to Sensor shield. Bought parts at Radio Shack, soldered (for the FIRST TIME EVER! woot)
  • 3 - To ensure that the motors were properly connected, I soldered their wires to them. Didn't appear to be a problem, but wanted to eliminate it now that I've soldered a couple of times.