2

I posted this on the electrical side of stack exchange and they said it was off topic, so I think it will be on topic here and they confused me even more. So if you guys could clear up my confusion, that would help.I know there are sources for this, but I am still lost. Anyways, here is the run down. I want to control multiple servos (12 of them) using a sensor shield. I need to know what kind of power supply I need. Here is the servo's I am using:

https://www.amazon.com/gp/product/B01NA80LUR/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1

Here is the sensor shield I am using:

https://www.amazon.com/gp/product/B01ACKVPTW/ref=oh_aui_detailpage_o01_s00?ie=UTF8&psc=1

The servos run at 3-7.2V and 750ma-1000ma full load or another person said they ran only 100-150ma. Also, another question is do I plug that power supply, when I get the right one according to what you say, into the dc jack or the external power on the sensor shield board?

Thank you for your time.

2 Answers 2

0

Arduino.cc forum topic 229646, “Arduino Sensor Shield v5 (APC220) manual”, is a thread about lack of documentation for that shield. However, post #10 in that thread states that pulling off the SEL jumper allows you to use an external power supply to power the devices you attach to the shield. Also see Sensor Shield (Version 5X) Separate 5V for Servos at yourduino.com.

The Robotics Stackexchange question Wiring & driving TowerPro SG90 servos agrees with the 750–1000 mA current draw of SG90 servos. You could go with a 5 or 6 V power supply, with say 12 A rating if you expect to drive 12 servos at the same time. However, as a 12 A supply might be expensive, you probably should attach two or three servos to the shield and measure the current draw. If, for example, your application rarely draws over half an amp per servo, you might scale back to a 10 A or 8 A supply.

Note that an Arduino Uno or Nano (in general, any based on ATmega328-like MCUs) has six pins that support hardware PWM, so you may need to use a Mega instead, or two Uno or Nano Arduinos. (Software-generated PWM signals are another possibility but I doubt it would work well enough if your app is at all complicated.)


Edit 1: If the system is battery operated, you probably should use a 2S LiPo RC battery, that is, a battery with the voltage of two lithium polymer cells in series (so, 7.4 volts) and whatever number of cells you wish to pay for in parallel, as often used in radio controlled devices.

Some LiPo batteries support 25C discharge rates, ie, can discharge at 25 times their one-hour-discharge rating. Thus, a 500 mAh battery might work fine – since 25 times .5 A is 12.5 A – if you only need to run your system for up to 2.4 minutes between battery charges. Or, for example, a $13.49 Turnigy 1000mAh 2S 20C Lipo Pack HobbyKing RC Battery would work ok, even though only rated for 20C. It could power a 12 A draw for 1/12 hour, or 5 minutes.


For the SEL jumper, look in the lower left corner of one of the pictures from your amazon.com link, as below. With the jumper (the short-metal-strap-and-black-plastic-shell assembly, next to the letters SEL) removed, connect battery+ and battery- to the screw-down terminals at bottom left in the photo. Battery+ goes to Vcc, battery- to Gnd.

top view of shield


Regarding a second Arduino, you could split the processing across two of them so that each one only needs to know the current time; or could communicate between them by an SPI, I2C, or RS232 interface; or could move up to a Mega2560 Arduino, which has a lot more PWM channels.

Edit 2: If battery weight is an issue, you may be able to use lower-capacity (hence lighter-weight) batteries if your software only moves a few of the servos at the same time. For example, if you move three or four at a time, and if most of the servos are idle most of the time, you might be able to use a light-weight cellphone battery.

Addicore.com has some useful current measurements for the SG90:

Voltage                        4.0V to 7.2V, 4.6V - 5.2V nominal
Running current with 5V supply (no mechanical load)    220 ±50mA
Stall current with 5V supply (horn locked)             650 ±80mA
Idle current with 5V supply                              6 ±10mA
Weight                                                0.32oz (9g)

However, you probably need to make current measurements on your own to see how big the battery needs to be.

7
  • Ok, that is kinda what I thought as regards to the power supply. Problem is I can't find a battery with 6v and 12 amps that is not a car battery size...so if you guys can tell me what I can do about that would be appreciated. Secondly, my project is a spider robot, so I kinda need it to be one arduino unless the both communicate somehow? Third, I can't find a "SEL jumper" so could you explain that?
    – Sean.D
    Feb 9, 2017 at 0:46
  • I did mention that I am building a spider robot with these servos that are kinda small, that battery is heavy as I personally do RC cars myself so I know they are too heavy for this project. There must be another way. How do people build a spider robot? Like seriously, this is hard for getting a power supply that is correct and not to heavy. About the other things, I will change to the mega and for the sel, I have to pull the jumper or what am I suppose to do with that? I can see like a "pin" kinda that might be able to be pulled out? Again, thanks for all the help. I know I'm a noob at this.
    – Sean.D
    Feb 9, 2017 at 1:33
  • @Sean.D, see edit 2 and slight change to Edit 1. Note, please upvote answer or mark as accepted Feb 9, 2017 at 2:18
  • I might be able to get it to only run 6 at a time, but have no idea until i build it. I really think it will use at least 6. I will do some measuring on my own and see. I will continue looking for a battery that is suitable. Thanks for your help.
    – Sean.D
    Feb 9, 2017 at 2:53
  • I upvoted but says i need like 15 rep or something, I then hit the check mark and it turned green.
    – Sean.D
    Feb 9, 2017 at 2:54
0

two things make servos fairly easy to control:

  1. they take a slow pwm input; generating pwm is fairly easy on a mcu;
  2. they are generally not that sensitive to the duration of the off state: I have tried from 5ms to 40ms (the longest) and they are fine with that.

so if you combine the two attributes together, it is easy to control multiple servos with from one timer interrupts.

I wrote a few pages on this recently: 1. driving multiple servos on AVR Timer2: https://dannyelectronics.wordpress.com/2017/02/08/driving-multiple-servos-with-avr-timer2/

  1. driving multiple servos on PIC: using TIMER0 (https://dannyelectronics.wordpress.com/2017/02/08/driving-multiple-servos-with-pic-timer0/) or TIMER1 (https://dannyelectronics.wordpress.com/2017/02/07/driving-multiple-servos-with-pic-timer1/).

The following is a combination of the two: driving 8 servos independently on PORTB with TIMER1 and another 8 servos independently on PORTD with TIMER2.

enter image description here

the user code is quite simple:

//set up servo controller 1
srvo1_init();                           //reset the servo module
srvo1_setpr(1, 1000);                   //for 1ms
srvo1_setpr(2, 1200);                   //for 1.2ms
srvo1_setpr(3, 1400);                   //for 1.4ms
srvo1_setpr(4, 1500);                   //for 1.5ms
srvo1_setpr(5, 1800);                   //for 1.8ms
srvo1_setpr(6, 2000);                   //for 2ms
srvo1_setpr(7, 2500);                   //for 2.5ms
srvo1_setpr(8, 4000);                   //for 4ms

//set up servo controller 2
srvo2_init();                           //reset the servo module
srvo2_setpr(1, 1000);                   //for 1ms
srvo2_setpr(2, 1100);                   //for 1.1ms
srvo2_setpr(3, 1200);                   //for 1.2ms
srvo2_setpr(4, 1300);                   //for 1.3ms
srvo2_setpr(5, 1400);                   //for 1.4ms
srvo2_setpr(6, 1500);                   //for 1.5ms
srvo2_setpr(7, 2000);                   //for 2ms
srvo2_setpr(8, 4000);                   //for 4ms

Once it is set-up, you can just leave it alone and no addition attention is required. You can change the duration of course, or disable / re-enable output on a given channel.

Total CPU drain is about 150K ticks in a second for 16 channel controller.

works on Arduino as well.

edit: if you port the code to TIMER0 (easily done), you can control 32 servos independently.

and if you combine this code with making timers out of the output compare functionality, you can shrink them all on one timer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.