[NYCR:Microcontrollers] One controller + many servos

93 views
Skip to first unread message

Moto

unread,
Apr 14, 2011, 6:28:51 PM4/14/11
to nycresistormi...@googlegroups.com
Hello,

I am interested in learning some basics in robotics for making small
scale robots. My first challenge here is to find out how to run as
many servos as possible from an arduino or pololu controllers, in case
I have money to build hexapods or humanoids in future. All small
factor controllers seem to be limited in number of motors that can
control (2-12 servos), unless I use arduino mega (48 servos).

I have used daisy chained shift registers to control 32 LEDs using PWM
from a regular Arduino. As far as I understand, servos use PWM but
within a certain range of frequency. Can shift registers or LED PWM
drivers be used for servos, or are there any specific ICs??

Thanks in advance.
Moto

Trammell Hudson

unread,
Apr 14, 2011, 6:48:22 PM4/14/11
to nycresistormi...@googlegroups.com
On Thu, 14 Apr 2011 18:28:51 -0400, Moto wrote:
> [...] Can shift registers or LED

> PWM drivers be used for servos, or are there any specific ICs??

You can use a 4017 decade counter to drive up to 10 servos per 16-bit
PWM output. Here's some code I wrote a few years ago to drive 20 servos
from a Mega163:

http://autopilot.cvs.sourceforge.net/viewvc/autopilot/onboard/rev2/servo.c?revision=1.4&view=markup

--
Trammell

Glen Duncan

unread,
Apr 14, 2011, 6:53:41 PM4/14/11
to nycresistormi...@googlegroups.com

Software PWM should be easier than driving LEDs because the duty cycle it's much lower for servos. The shift-register may work as long as theres no glitch during updates. You could also conceivably use a pwm led driver. Just a matter of getting the pwm clock right and pulling the open collector outputs high through a resistor.

-spec

Trammell Hudson

unread,
Apr 14, 2011, 7:08:38 PM4/14/11
to nycresistormi...@googlegroups.com

Software PWM should be easier than driving LEDs because the duty cycle it's much lower for servos. The shift-register may work as long as theres no glitch during updates.


I don't think a shift register will work here since each servo needs a different pulse width. It isn't pwm, it only cares about the time the signal is high. 

-- Trammell

Trammell Hudson

unread,
Apr 14, 2011, 7:22:50 PM4/14/11
to nycresistormi...@googlegroups.com
Ah, I see how you could do it with a shift register, but you need two pins.  One for data and one to clock it into the register. 

-- Trammell
--
You received this message because you are subscribed to the Google Groups "NYCResistor:Microcontrollers" group.
To post to this group, send email to nycresistormi...@googlegroups.com.
To unsubscribe from this group, send email to nycresistormicrocon...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nycresistormicrocontrollers?hl=en.

Glen Duncan

unread,
Apr 14, 2011, 7:49:35 PM4/14/11
to nycresistormi...@googlegroups.com


On Apr 14, 2011 7:23 PM, "Trammell Hudson" <hud...@osresearch.net> wrote:
>
> Ah, I see how you could do it with a shift register, but you need two pins.  One for data and one to clock it into the register. 

Right. You have to update the word for each count in the pwm cycle.

Also of interest is the open servo project. Servo electronics are replaced with a microcontroller based driver and take position commands via a serial bus.

-spec

Tymm Twillman

unread,
Apr 14, 2011, 8:29:57 PM4/14/11
to Glen Duncan, NYCResistor:Microcontrollers
I believe the Arduino TLC5940 (LED Driver) library also has the ability to control servos.


Russ Hensel

unread,
Apr 15, 2011, 1:22:43 PM4/15/11
to nycresistormi...@googlegroups.com
It is easy to control up to 10 servos because each servo needs a 2 ms
window for control and 20 ms between control pulses. You can do more
but the software requires more effort. After you run out of pins you
need a bigger uc or something like shift registers. Shift registers add
to the timing problems. Using a thru hole pic processor you can build a
board with maybe 20 - 30 output pins for less than 20 bucks.

Hardware pwm does not do a good job for servos in most cases because
there is not enough resolution in the 1 to 2 ms ( 5 to 10 % duty cycle )
control window.

russ

Moto

unread,
Apr 18, 2011, 5:45:58 PM4/18/11
to nycresistormi...@googlegroups.com
Thanks a lot for all your insights. I'd try using TLC5940 PWM
driver first. I also found out about openservo board which has it's
own AVR controller and can be controlled with I2C. Looks interesting,
but it's rather costly.

On a separate note, servos have potentiometer to detect it's own angle
of rotation, right? I am wondering if that can be used to "teach" the
robot movements by moving servo joints by hand. I don't think
existing three wires can be used for that purpose, but adding extra
connections to the pot or the board maybe possible? Does anyone have
an experience on something like that?

Moto

Trammell Hudson

unread,
Apr 18, 2011, 6:09:35 PM4/18/11
to nycresistormi...@googlegroups.com
On Mon, 18 Apr 2011 17:45:58 -0400, Moto wrote:
> On a separate note, servos have potentiometer to detect it's own
> angle of rotation, right? I am wondering if that can be used to
> "teach" the robot movements by moving servo joints by hand.

There are high-end robot servos that do exactly that. HiTec makes a
few "Robot Servos":

http://www.servocity.com/html/hsr-8498hb_hmi_robot_servo.html

You can disable the normal servo PWM and switch them to a multi-drop
bus protocol that allows a single daisy chain to control 128 servos via
a command protocol. One of the commands is a torque-limiting mode that
allows you to move the servos by hand and have it report the position
data. This is great for building humanoid robots where you want to
sequence poses.

The other nice thing about the robot servos is that they have idler
pulleys on the backside so that it is easy to build joints out of them.

> I don't
> think existing three wires can be used for that purpose, but adding
> extra connections to the pot or the board maybe possible?

That is doable to an extent as well. I've made some "four-wire" servos
using that technique, but the data is quite poor and there is no way to
disable the motor drive for normal servos. So it is only useful for
sort of telling if the servos are doing what they have been commanded to
do.

--
Trammell

Marius Kintel

unread,
Apr 29, 2011, 11:46:29 PM4/29/11
to nycresistormi...@googlegroups.com
Hi,

I did smth. like this a few years ago, but didn't finish it.
I believe this is the latest version of my code:
https://whatever.metalab.at/projects/MarbleMadness/Arduino/ServoMatrixInterrupt/ServoMatrixInterrupt.pde

It should, in theory, be able to control 128 servos from an Arduino and 16 shifting registers.
I only tested it with 32 servos, AFAIR.
Due to heavy interrupt usage, you might not have a whole lot of CPU time left though.

-Marius

Reply all
Reply to author
Forward
0 new messages