extending battery life on Arduino uno servo control setup

Hello,

I am trying to extend the battery run time of my servo setup on an uno board running 6 servos.

I only need power to the servos when I ask them to move. After that they stay in the same place with very little load on them. I would like to put them in sleep mode until they get a command and after a set amount of time go to sleep.

Here is the code I’m using as crude as it may seem its been working great for the last 6 months 24 hours a day.

Also, I started getting a chatter from the servos after a few days of running this code. I tried running a nice strong 6V bus with a 220uV cap in line and that didn’t do anything. I tried 8 different servos (with or w/out load) and they all have noise in them on the uno board. I can plug them into my R/C radio and they are perfect. ANY else I can try?

[/// controls SIX servos via IR remote at set positions returning back to 0 when OFF or any other servo is called

#include <Servo.h>
#include <IRremote.h>



unsigned long Value1 = 0xFD00FF; // 21 channel IR remote 
unsigned long Value2 = 0xFD80DF; // not in use
unsigned long Value3 = 0xFD40BF; // not in use
unsigned long Value4 = 0xFD20DF;
unsigned long Value5 = 0xFDA05F;
unsigned long Value6 = 0xFD609F;
unsigned long Value7 = 0xFD10EF;
unsigned long Value8 = 0xFD906F; 
unsigned long Value9 = 0xFD50AF;
unsigned long Value10 = 0xFD30CF;
unsigned long Value11 = 0xFDB04F;
unsigned long Value12 = 0xFD708F;
unsigned long Value13 = 0xFD08F7;
unsigned long Value14 = 0xFD8877;
unsigned long Value15 = 0xFD48B7; 
unsigned long Value16 = 0xFD28D7;
unsigned long Value17 = 0xFDA857;
unsigned long Value18 = 0xFD6897;
unsigned long Value19 = 0xFD18E7;
unsigned long Value20 = 0xFD9867;
unsigned long Value21 = 0xFD58A7;

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;

// the setup routine runs once when you press reset:
void setup() {              

  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  

  servo1.write(0);
  servo2.write(0);
  servo3.write(0);
  servo4.write(0);
  servo5.write(0);
  servo6.write(0);
  
  servo1.attach(2); 
  servo2.attach(3); 
  servo3.attach(4); 
  servo4.attach(5);
  servo5.attach(6); 
  servo6.attach(7);
}

// the loop routine runs over and over again forever:
void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);

    if(results.value == Value1) {
      servo1.write(0);
      servo2.write(0);
      servo3.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(0);
    }
    else if  (results.value == Value4){ // servo 1-180
      servo2.write(0);
      servo3.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(0);
      servo1.write(180);
    }
    else if  (results.value == Value5){ // servo 1-110
      servo2.write(0);
      servo3.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(0);
      servo1.write(110);
    }
    else if  (results.value == Value6){ // servo 1-90
      servo2.write(0);
      servo3.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(0);
      servo1.write(90);
    } 
    else if  (results.value == Value7){ // servo 2-180
      servo1.write(0);
      servo3.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(0);
      servo2.write(180);
    }
    else if  (results.value == Value8){ // servo 2-110
      servo1.write(0);
      servo3.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(0);
      servo2.write(110);
    }
    else if  (results.value == Value9){ // servo 2-90
      servo1.write(0);
      servo3.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(0);
      servo2.write(90);
    } 
    else if  (results.value == Value10){ // servo 3-180
      servo1.write(0);
      servo2.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(0);
      servo3.write(180);
    }
    else if  (results.value == Value11){ // servo 3-110
      servo1.write(0);
      servo2.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(0);
      servo3.write(110);
    }
    else if  (results.value == Value12){ // servo 3-90
      servo1.write(0);
      servo2.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(0);
      servo3.write(90);
    }
    else if  (results.value == Value13){ // servo 4-180
      servo1.write(0);
      servo2.write(0);
      servo3.write(0);
      servo5.write(0);
      servo6.write(0);
      servo4.write(180);
    }
    else if  (results.value == Value14){ // servo 4-110
      servo1.write(0);
      servo2.write(0);
      servo3.write(0);
      servo5.write(0);
      servo6.write(0);
      servo4.write(110);
    }
    else if  (results.value == Value15){ // servo 4-90
      servo1.write(0);
      servo2.write(0);
      servo3.write(0);
      servo5.write(0);
      servo6.write(0);
      servo4.write(90);
    }
    else if  (results.value == Value16){ // servo 5-180
      servo1.write(0);
      servo2.write(0);
      servo3.write(0);
      servo4.write(0);
      servo6.write(0);
      servo5.write(180);
    }
    else if  (results.value == Value17){ // servo 5-110
      servo1.write(0);
      servo2.write(0);
      servo3.write(0);
      servo4.write(0);
      servo6.write(0);
      servo5.write(110);
    }
    else if  (results.value == Value18){ // servo 5-90
      servo1.write(0);
      servo2.write(0);
      servo3.write(0);
      servo4.write(0);
      servo6.write(0);
      servo5.write(90);
    }
    else if  (results.value == Value19){ // servo 6-180
      servo1.write(0);
      servo2.write(0);
      servo3.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(180);
    }
    else if  (results.value == Value20){ // servo 6-110
      servo1.write(0);
      servo2.write(0);
      servo3.write(0);
      servo4.write(0);
      servo5.write(0);
      servo6.write(110);
    }
    else if  (results.value == Value21){ // servo 6-90
      servo1.write(0);
      servo3.write(0);
      servo4.write(0);
      servo5.write(0);
      servo5.write(0);
      servo6.write(90);
    }
    irrecv.resume(); // Receive the next value
  }
}



need help mating them togethercode]

I think that the first thing to ask is how you are powering the servos. Can you provide a circuit diagram ? A hand drawn one will suffice.

This is the setup I have been running for the last 6 months. I also tried wiring it 5 other ways with no better or worse results. I’m planning on using a relay to cut power to the servos after a given amount of time. Or maybe the board can do this for me? Can I use power from the analog pins to power the servo without the need of a relay.

Any thoughts?

Please don't post such large pictures. 640x480 would probably be fine.

I suspect 6v is a little too low for powering the Arduino and I wonder is that causing problems?

You could save power by getting the Arduino to disconnect the positve connection from a servo that does not need to move - use a relay or a suitable transistor. I believe it is not a ood idea to disconnect the ground connection.

...R

sorry about the pic size..

I am going to try 1.5 more volts and see what that does

In the mean time, I am making another setup. I lost the code when my laptop got stolen a few months back. However, I posted the code on the forum and was able to copy it again. Since then I have not been able to upload it. I checked it over and it all makes sense and from what I remember it seems the same.

Can I copy the code that is on the working UNO?

I get a pop up when I verify that says ('IRrecv' does not name a type) And it highlights IRrecv irrecv(RECV-PIN);

Can anyone help me with this?

I tried 6, 7.5 and 9 volts to the board direct clean battery power. It did nothing. In fact I can take it down to 3 volts without seeing any change. I may try another board to see if that works. However, I am having a hard time with the code and cant seem to get past the pop up message state in my last post

I did however buy a small 6 volt relay and will be placing in front of the + side of the power bus. How long do you think I should have for a delay? It will need to latch before the signal is sent to the servo and close after enough time has gone by for it to reach it's position.

Does your setup have the same issues with only one servo connected? Under load, servos can pull as much as 1A or more each. You only give the voltage for the batteries and not the amp rating.

When you power the servos from your R/C radio what angle do they move thru from exrteme stick movement?

Now when you do it thru your uno what angle do they move ?

Maybe you are pushing them into their stops and maybe they don't like that.

I get a pop up when I verify that says ('IRrecv' does not name a type) And it highlights IRrecv irrecv(RECV-PIN);

The library is not installed, installed in the wrong place, named wrongly or you did not stop/start the IDE after the installation.

Thanks for the info!

The battery I am and have been using is a 6V lantern Battery with around 18AH. I can get around 45 days running 24hours a day out of one of them with the setup I have now. After I install the relay to kill the servo power I imagine it will last at least 6 months as the servos only work a few times a day. I was even thinking about a small solar cell to charge when it's in standby.

I am still having an issue with the code.

I get a pop up when I verify that says ('IRrecv' does not name a type) And it highlights IRrecv irrecv(RECV-PIN);

I've been messing with it for the last 8 hours and still can't seem to get it to work. I even used code direct form other sites and it still didn't work. If someone would look at my code and help me with this it would be great!

As I said in my previous post

The library is not installed, installed in the wrong place, named wrongly or you did not stop/start the IDE after the installation.

Where is the library installed ? Please give the full path of the folder and its name.

It should be in the libraries folder of the folder holding your programs, not the libraries folder where the Arduino executable is located. If the problem is with the library location then looking at your code will not help.