how to use power supply from wall sockets for servos

Hey,

I am trying to find a way to connect 4 servos to AC current coming from wall sockets (that is what is available, plus the motors are going to placed near the ceiling and will be running +12hrs, for 3 days).

The arduino will be powered separately (I have an adapter for that). Is there something that can work for all 4 motors together?
they are metal geared servos, 9-10kg torque, 4.8V to 6V.
What kind of adapter can I use? would a 6V suffice? or should I go for 5V?

Also, can some one help me understand how to wire this? Is there any way, where I don’t need to cut the end of plug and connect the motors, perhaps a special contraption that can help me avoid this?

I have searched everywhere online and I can’t figure this out. Can someone please guide me regarding this, preferable in simple english (Not from engineering background, tech jargon confuses me).

Thank you in advance.

aksbonsra: What kind of adapter can I use? would a 6V suffice? or should I go for 5V?

or should it be 24 V adapter.. really confused right now.

You can buy 6V DC adapters on Ebay, I don’t know what your mains AC power is, either 110V or 220V. but go to Ebay.com and do a search for either 110V to 6V DC or 220V to 6V DC. You will need to know how many Amps your power supply will have to provide, how much current your servos are gonna need. If they are small servos a few Amps will be ok.

Regarding your questions about wiring the servos, have a look here.

Servo Wire

You def do not need a 24Volt power supply.

You can find almost everything on Ebay or Amazon or other sites, everything possible is out there.
And the more info you share with us, the better we can help you. In this case we might even be possible to only use one power supply.

Have a look around on Ebay

You can plug a 6v adaptor into the 5mm barrel plug right into the Arduino. But that I think of it that won't help you. But you can use a motor shield on your Arduino. The motor shield can use a separate power source to power the servos. But another problem arises you can only hook up two servos but the way I understand it, is that the motor shields are stackable. In that case you will be able to hook up 4 servos. Do some research in Arduino motor shields it should help you out. With the motor shield you can hook up 4 DC motors, 2 servo motors and two stepper motors.

You don't want a motor shield. If you really don't want to do any cutting and soldering the thing to search for is "Arduino servo shield" e.g. https://www.adafruit.com/product/1411 but there are others.

For the servos I suggest a 6V regulated power supply which can supply at least 5A because they sound like fairly powerful servos. The power supply plugs into the shield and powers all the servos.

Steve

I agree Slipstick is right about the servo shield, I didn't realize they made one. I did a little research on the subject and I feel the Adafruit servo shield would be your best bet they are a little pricey but worth all the bells and whistles that come with it. The cheap ones don't seem to have the safety voltage regulator.

What if I put a capacitor and a diode in the circuit?

I had to use a diode earlier with an h bridge and 2 dc motors, cos somehow the electricity was flowing to arduino too when connected, through the h bridge. Was going to use the same practice here as well.

I have to agree, I am keener with just the adapter, as a lil on the tight budget.

But if shield is necessary, then i will buy that too, along with the adapter.

6V will give you more torque and speed.

Hobby servos require a clean DC supply. They are designed for planes, cars etc which run on batteries.

The connectors are at a standard 2.54mm (0.1") pitch. If you don't want to cut the connectors off use Futaba extension leads to connect the board to the servo lead.

When running the current is in the mAmps but if stalled can rise to a couple of amps. The above two points also depend on the servo make size and model of which you don't mention

The connectors are rated for 3 Amps.

Digital servos will have a constant buzz as they are permanently keep position

I thought I had shared this before, but seems it never got posted.

These are metal geared servos 9kg/cm torque. 6V

And going to have some load in forms of pulling up or pulling in things.

Yes but what MAKE and MODEL of servo are they? You've shared just part of the specification but not the important parts. It sounds like they may be Tower Pro MG995s but they could also be many other things.

You don't need the shield but you do need some way of connecting the servos. There are lots of possibilities, I sometimes use vero board/stripboard and 0.1" pitch headers like https://www.pololu.com/product/965

Steve

They probably need 1.5 to 2A each with that spec, so 8A supply?

Note that torque is not a ratio. Torque is a product. kgf-cm is how to say kilogram-force times cm. (although the hyphen is a bit confusing, its not a subtract!) But SI units are much simpler to work with, the correct unit is the newton-metre, ie Nm. 9kgf-cm is 0.88Nm

Power = torque x angular velocity, and standard servos have an angular velocity around 6 rad/s, so that servo is capable of about 6 x 0.88 watts mechanical = 5.3W, and typical efficiency from electric power to mechnical is 50% perhaps, so allowing 10W electrical power at 6V suggests 1.7A peak current requirements - measure this for a more accurate value...

WOW!! thank you so much.. I was looking for the Watts readings, couldn't find it or fig it as there was limited info in the data sheet.

Unfortunately, the main market place was out of driver/servo shields AND the adapters. SO I bought something called as SMPS , for 5-7V (it can regulate the Volts) and 5amphs. (I REALLY hope this works, as I have to setup tommorow).

ALso, Could anyone tell me what DIODE to use? I have a IN4007, but I can't understand the calculation needed :( and my brain has given up on understand these calculations now.. too foggy to get it.

Ok I tried every combination I could think of, But the motors are not working. Even when only 1 servo is hooked up to the system, it’s not working.

I have rechecked and replaced every component.
Rechecked and compared various code for servos, and wirings.

I even tried different strength capacitators, removed them, Diode, removed it, but the motor hasn’t moved once. The PIR code registers on the digital serial monitor. I am guessing then the issue is with the power supply(SMPS).

It’s plugged right for the electricity to flow in (the inbuilt green led glows), but i guess current isn’t going right to the motor (I don’t know how to describe this any better).

This is the main code below. I tried making a diagram to show my circuit, but the Autodesk website isn’t working right for me tonight unfortunately.

#include <Servo.h>

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

// the time we give the sensor to calibrate (10-60 secs)
int calibrationTime = 10;
long unsigned int lowIn; //the time when sensor outputs a low impulse
long unsigned int pause = 3000; // the amount of millisecounds the sensor has to be low to assume all motion has stopped

boolean lockLow = true;
boolean takeLowTime;

int PIR = 2; // digital pin 2 has a PIR attached to it. Give it a name:
int angle = 0; //servo position in degrees

////////////
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600); //initialize serial communication at 9600 bits per second:
pinMode(PIR, INPUT);
servo1.attach(5); // servo machine 1 on pin 5
servo2.attach(6); // servo machine 2 on pin 6
servo3.attach(7); // servo machine 3 on pin 7
servo4.attach(8); // servo machine 4 on pin 8
digitalWrite(PIR, LOW);  // PIR starts with low

Serial.print("calibrating sensor ");
 for(int i = 0; i < calibrationTime; i++) {
  Serial.print(".");
  delay(3000);
 }
 Serial.println(" done");
 Serial.println("SENSOR ACTIVE");
 delay (10);
}

void loop() {
  // put your main code here, to run repeatedly:

if(digitalRead(PIR)==HIGH) {{{ //if PIR output is HIGH, turn servo on

//scan from 0 to 180 degrees
for(angle = 0; angle < 180; angle++)
{
  servo1.write(angle);
  delay(100);
  servo2.write(angle);
  delay(100);
  servo3.write(angle);
  delay(100);
  servo4.write(angle);
  delay(100);
}
//now scan back from 180 to 0 degrees
for(angle = 180; angle > 0; angle-- )
{
  servo1.write(angle);
  delay(100);
  servo2.write(angle);
  delay(100);
  servo3.write(angle);
  delay(100);
  servo4.write(angle);
  delay(100);
}
}
if(lockLow){ //make sure we wait for a transition to LOW before further output is made
  lockLow = false;
  Serial.println("---");
  Serial.print("motion detected at");
  Serial.print(millis()/1000);
  Serial.println ("sec");
  delay(50);
}
}
takeLowTime = true;
}

if(digitalRead(PIR)==LOW){
  if(takeLowTime){
    lowIn = millis(); //save the time of the transition from HIGH to LOW
    takeLowTime = false; // make sure this only done at the stat of a LOW phase
  }
  // if PIR is low for more than a given pause, we assume motion has stopped
  if(!lockLow && millis() - lowIn > pause){ //make sure this block of code is executed again after a new motion is detected
    lockLow = true;
    Serial.print("motion ended at"); // output
    Serial.print((millis() - pause)/1000);
    Serial.println("sec");
    delay(50);
  }
}

}

You can draw your circuit on paper and take a picture of it and post that. It will be fine.

But until we know what you're making we have no idea what capacitors and diodes you are talking about. Looking at your code you seem to be using a PIR which you have never mentioned before.

But one thing is while you have all those blocking for loops with delays in there you should realise that you're slowing the main loop right down so you're probably only checking the PIR every few minutes.

Steve

it’s a crude drawing

I wanted to keep the confusion away, hence shared minimal info, but i can see you need more info.

setup is simple

A pir activates 4 servos, which moves with a delay of 10secs each, after the 1st one, and comes back after reaching 180degrees.

(basically, the servos are pulling up a line of fabric and LEDS up and down, trying to make a wake pattern.)

I had placed 5 capacitors (i had only 100uF, and I read i needed 470uF or more) in series as well as parrallel, didn’t work. I removed the Diode too (1N4007), it didnt work.

i even tried removing PIR entirely in the code and circuit, servo isn't moving. Replaced the servo, still no motion, or even any current going through it.

What you call “keeping the confusion away” is what we call not providing enough information for us to be able to help.

Anyway the drawing doesn’t show 4 servos but it does show several things. The capacitors and diodes should not be there and will definitely stop it working. So that’s one reason why the servos haven’t been moving. The adaptor + and - should connect direct to the servo + and -.

Also your code isn’t doing anything like what you think it is. There are no 10 second waits between servos trying to move. And because you’re using the Sweep code like you are, moving only 1 degree at a time with several delay()s in, it will take 180 x 0.4 seconds (so well over a minute) to go from 0 - 180 degrees and then another 1.2 minutes to get back to 0.

For now just comment the if(digitalRead(PIR)==HIGH) {{{ //if PIR output is HIGH, turn servo on out and also all the delay(100)s and get the servos moving. That will prove that they are finally connected correctly. Then we can get them moving as you actually want and after that we can look at putting the PIR back in cause them to move.

But I think to get it working as you describe you’re going to need to get rid of all the delays and rewrite this all using millis() for timing.

Steve

I told you, I already did that.

I still tried it again, removed all the codes for stalling and PIR.

i even changed leonardo to uno

I am using only one servo right now to test! that’s what I said too when putting the pic up.

No motion.

#include <Servo.h>

Servo servo1;
int angle = 0; //servo position in degrees

////////////
void setup() {
  // put your setup code here, to run once:
servo1.attach(5); // servo machine 1 on pin 5
}

void loop() {
  // put your main code here, to run repeatedly:

//scan from 0 to 180 degrees
for(angle = 0; angle < 180; angle++)
{
  servo1.write(angle);
  
}
//now scan back from 180 to 0 degrees
for(angle = 180; angle > 0; angle-- )
{
  servo1.write(angle);
  }
}

the circuit

If it still doesn't work with that latest code there are two major possibilities - the servo is dead or you don't have power to it. You say you've tried more than one of your servos so the first isn't likely. Have you also checked the power supply output with a multimeter?

I don't like driving servos via breadboards because they can't handle the relatively high currents. But that does lead to one other odd possibility - are you certain that the power strips on your breadboard are continuous? Some of the ones with a largish break in the middle are not a single long strip but two separate ones and need to be bridged. When you check the power supply voltage test between the power supply + and the Uno GND terminal. You may not have the grounds connected.

Steve