Servo's not working when connected to mains power.

Hello all,

Working on my first real project. I am trying to control two servos using an uno with push buttons. One button for one direction and one for the other, two buttons per servo. At the moment I am just working with one servo. Everything works fine when I have it connected through the USB's on my computer but when I change to mains power, the servo freaks out under the slightest of loads and does not operate properly.

When using mains, I am powering the uno with the 9V barrel plug that came with my uno and am powering the servo through a modified iPhone USB charger.

Any ideas on what is going on here? - Thank you

I have attached some photos of my wiring, my code is below?:

#include <Servo.h>

 

#define openButtonPin  2 //pushbutton for open , CW for now, also an INT pin for better prog later.

#define closeButtonPin  3 // pushbutton for closed , CCW.

#define servoPwrSwitch  4 // add a pwr relay or fet for servo power later.

 

Servo blind1; //attach a servo

 

int speedStep = 100; //change x uSec for eash step. make larger to 500max, for increased speed.

int stopPWM = 1492; // set for mid deadband. 1465-1520

int currentPWM = 0; // for handling pwm changes.

 

 

 

void setup()

{

  pinMode(openButtonPin, INPUT_PULLUP);             // set pin to input with pullup res.

  pinMode(closeButtonPin, INPUT_PULLUP);           // set pin to input

  pinMode(servoPwrSwitch,OUTPUT);                 // for servo power control out.

  digitalWrite(servoPwrSwitch, LOW);              //turn it off to start with.

 

  attachInterrupt(digitalPinToInterrupt(openButtonPin),openBlind, FALLING);   // int handler for pin2

  attachInterrupt(digitalPinToInterrupt(closeButtonPin),closeBlind, FALLING); //int handler for pin3

 

  

  blind1.attach(9);                   // blind1 servo pwm on pin 9 of UNO

  blind1.writeMicroseconds(stopPWM);  // set servo to stop-point

  currentPWM = stopPWM;

 

//  Serial.begin(9600);

 

}

 

void loop() {

while(digitalRead(openButtonPin) != 1 || digitalRead(closeButtonPin) != 1){

 

}

 

  blind1.writeMicroseconds(stopPWM);

  digitalWrite(servoPwrSwitch, LOW);

}

 

//interrupts

void openBlind(){

currentPWM = stopPWM + speedStep;

//Serial.println(currentPWM);

    blind1.writeMicroseconds(currentPWM);

 

}

 

 

void closeBlind(){

currentPWM = stopPWM - speedStep;

//Serial.println(currentPWM);

    blind1.writeMicroseconds(currentPWM);

Servos will not run on a little iphone charger.
Run your servos on 4 x decent rechargable AA cells.

Hi,
Have you a DMM to measure the servo power supply?

Tom... :slight_smile:

A circuit diagram would be more useful than those pictures. Do you have a ground connection between the servo supply and the Arduino? What is the current rating of the "modified IPhone charger"? That big servo needs at least 2A and a couple of them will need more than that.

Steve

It might be the angle of the camera or it might be my dodgy eyes, but in your photo 1.jpg it looks to me like there is a black wire from ground on the Uno to the connection marked 10 on your breadboard, then a black wire from there to 20, then a black wire from 20 to 5V on the Uno, shorting out the supply. If this is the case then you have a problem right there.

The first rule of servos is do not power them from the Arduino 5V supply.
The second rule of servos is....do not power them from the Arduino 5V supply!

Separate supply, common the grounds only, assume 1A per servo for small servos,
more for larger ones, do not skimp on power supply current rating or you'll see
the kinds of problem you are doing.

I think you actual problem is an iPhone charger will not produce any significant
current without negotiatiation with the device its connected to.

Hi there,

Yes it appears to be the iPhone usb wall adaptor is not grunty enough. I am using two different power supplies, one for the Ardurino and one for the servo. All grounds are connected together. I'd prefer not to run the servos off of batteries because this is going to be a permanent installation and high up so not easy to get to.

I connected a 15V 100mA AC/DC wall supply and it worked on the bench but when I hooked it to my prototype (Venetian blinds) a small puff of smoke came out of the servo! I quickly unplugged it and tested it on the computer power supply and it still works which is a relief.

Any ideas on what is going on here? I hooked the positive from the power supply tot he red on the servi, negative to black and white to the ardurino. The servo I am using is a SM-S4315R and like I mentioned, I need to run two of these.

I have attached a crudely drawn wiring diagram to show how it is set up for clarification.

Hopefully once this one is going it will be easy to transition to running two servos and 4 buttons?

Thank you in advance.

The spec on that servo is 6V max so 15V seems a bit high. I would suggest a 5V supply that can deliver several amps. Connect the ground to your arduino and the 5V supply to your servos

The servo is rated for 4.8V to 6V and your problem is that you didn't have enough CURRENT (that's Amps not Volts). What made you think it was a good idea to give it 15V and very low current? If the servo still works you're amazingly lucky.

The wiring looks reasonable and you need a 5V or 6V power supply capable of providing at least 4A. More current (Amps) would be o.k. More voltage definitely would not.

Steve

Hello all,

Rookie mistake on the power supply. I will get another. If I get one that is 6v and 4 amps that should be sufficient to power two servos?

The 15v ps did make the servo turn pretty quick!

Thank you again!

slipstick:
you need a 5V or 6V power supply capable of providing at least 4A. More current (Amps) would be o.k.

I've had a look online and can't seem to find a 5-6V 4A power supply, anyone have any suggestions on where to find it? Thank you!

Google 5v 4a adapter and ebay will give you a lot of ootions.
It alsi depends on how hard your servo needs to work. The more force it needs to use to achieve wat you want the more amps it will use.

Usualy if there is smoke something is burned out. So expect it to fail at some point if it is still working now

Not sure where you were looking but I Googled "6V 5A mains power supply" (more current is always good) and got several thousand results. EBay or Amazon can provide plenty.

Steve

I think I have found a suitable one - https://nz.element14.com/mean-well/gst60a05-p1j/adaptor-ac-dc-5v-6a/dp/2815910?st=ac/dc%20power%20supply

Is this ok?

Thank you

This one at Ebay is a fraction of the price, there are also others.....

https://www.ebay.com.au/itm/AC-to-DC-5V-6A-Regulated-Switching-Power-Supply-Converter-for-LED-Display-SY/252323582262?hash=item3abfa85136:g:XnsAAOSwZQxW6vLB:rk:9:pf:0

bluejets:
This one at Ebay is a fraction of the price, there are also others.....

I am in New Zealand and was hoping to get something that was already here so I can get it soon. When I order from overseas it can take up to a month!

Anyone want to assist me in modifying my code so I can run a second servo to and control two servos independently with two push buttons each? Here is my code:

#include <Servo.h>

 

#define openButtonPin  2 //pushbutton for open , CW for now, also an INT pin for better prog later.

#define closeButtonPin  3 // pushbutton for closed , CCW.

#define servoPwrSwitch  4 // add a pwr relay or fet for servo power later.

 

Servo blind1; //attach a servo

 

int speedStep = 500; //change x uSec for eash step. make larger to 500max, for increased speed.

int stopPWM = 1492; // set for mid deadband. 1465-1520

int currentPWM = 0; // for handling pwm changes.

 

 

 

void setup()

{

  pinMode(openButtonPin, INPUT_PULLUP);             // set pin to input with pullup res.

  pinMode(closeButtonPin, INPUT_PULLUP);           // set pin to input

  pinMode(servoPwrSwitch,OUTPUT);                 // for servo power control out.

  digitalWrite(servoPwrSwitch, LOW);              //turn it off to start with.

 

  attachInterrupt(digitalPinToInterrupt(openButtonPin),openBlind, FALLING);   // int handler for pin2

  attachInterrupt(digitalPinToInterrupt(closeButtonPin),closeBlind, FALLING); //int handler for pin3

 

  

  blind1.attach(9);                   // blind1 servo pwm on pin 9 of UNO

  blind1.writeMicroseconds(stopPWM);  // set servo to stop-point

  currentPWM = stopPWM;

 

//  Serial.begin(9600);

 

}

 

void loop() {

while(digitalRead(openButtonPin) != 1 || digitalRead(closeButtonPin) != 1){

 

}

 

  blind1.writeMicroseconds(stopPWM);

  digitalWrite(servoPwrSwitch, LOW);

}

 

//interrupts

void openBlind(){

currentPWM = stopPWM + speedStep;

//Serial.println(currentPWM);

    blind1.writeMicroseconds(currentPWM);

 

}

 

 

void closeBlind(){

currentPWM = stopPWM - speedStep;

//Serial.println(currentPWM);

    blind1.writeMicroseconds(currentPWM);

}

RookieC:
I am in New Zealand and was hoping to get something that was already here so I can get it soon. When I order from overseas it can take up to a month!

Same on this side of the pond, but so much cheaper! And as best we can determine - the same stuff from the Chinese sweat-shops.

If I get a one outlet AC/DC Enclosed Power Supply, can I simply split the power off to each of my two servos or do I need to buy a two outlet power supply? One outlet are better value than two. Thank you

You can, as long all the servos together dont use more amps then the plug is rated for.

I could not find the specs for the servos telling me how much amps they use on max capacity.

If you have a simple multimeter you can measure how much the things use abd then fihure out how many you can power with your plug.

This f they alltogrther use more power than the plug is rated for you will most likely burn your plug, unless it is an expensive one with a build in cutoff