Let's Make Robots!

How many servos you need to control?

Expands PWM outputs for servo control

     Those who intend to build a more complex project (in this case I mean with more DOFs, like a hexapod, biped humanoid and others) may find dificulties if using a Arduino UNO or similar board, unless they have a Mega. That's what happened with me when I was working on my biped project.

     After researching a lot of alternatives, without changing the board, I found this IC: TLC5940.

     This is sold as a 16 channel LED driver, but with this library it can control 16 servo motors easily as the "sweep servo". But not only that, the IC can be daisy-chained and expand the PWM outputs even more (I haven't yet tried it, but seems to be very easy). What you lose of your board are 5 pins.

     You can find this IC in a breakout board and also in a shield (PWM shield), or make your own with very low cost (less than USD 2,00 per chip). If you live in Brazil you can buy 20 chips for the price of one PWM shield. :)

     Well guys, what you'll need to make this work are below:

  • Arduino board (I utilized UNO);
  • 1x TLC5940 IC (16 channels);
  • 2.2k resistors;
  • jumpers;
  • external power for the servos;
  • jumper wires;
  • protoboard;
  • servos (how many you want to control or your project needs);
  • musics.

 

     In my example, I utilized only 6 servos. But you can easily add more on the remaining channels.

 

     Owwwww... What a mess of wires! It's a bit difficult to understand the connections on the above pic. Because of this I made a schematic in Fritzing. But before it, let's take a look in the IC pins.

 

     Now, let's go to the connections... Follow the color and pins sequence below.

 

 

  • IC pins 1 until 15 and pin 28 are the output channels, where you connect the signal wire of the servo. You got to add a 2.2k pull-up resistor in each channel and connect to 5V to make it possible to control servos.
  • IC pin 16: XERR (non utilized in this case).
  • IC pin 17 - SOUT (non utilized in this case).
  • IC pin 18 - GSCLK: BROWN wire connected to the Arduino pin 3;
  • IC pin 19 - DCPRG: connected to 5V;
  • IC pin 20 - IREF: put on it a 2.2k resistor and connect to GND;
  • IC pin 21 - VCC: connected to 5V;
  • IC pin 22 - GND: connected to GND;
  • IC pin 23 - BLANK: ORANGE wire connected to the Arduino pin 10;
  • IC pin 24 - XLAT: YELLOW wire connected to the Arduino pin 9;
  • IC pin 25 - SCLK: BLUE wire connected to the Arduino pin 13;
  • IC pin 26 - SIN: GREEN wire connected to the Arduino pin 11;
  • IC pin 27 - VPRG: connected to GND.

 

     As you will utilize a bunch of servos, you'll need an external power supply for them. Don't forget to connect the ground of the servo power to the Arduino power, to make a common GND.

     Note: In the begin I was having troubles to make the servos turn from 0 to 180º, they only turned from 0 to 90º. I researched in many forums and found some guys with the same problem. But nobody had the solution. After changing some values in the tlc_servos.h file, I solved this trouble. So, if someone have this same problem, change the SERVO_MIN_WIDTH from 204 to 120 and the SERVO_MAX_WIDTH from 410 to 475.

     For now, that's all guys.

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

At first I thought this was the same chip used here: http://www.adafruit.com/products/815

Same thing but a different chip.

Specially because it uses only 2 pins, and the pins are the analogs. The cost of this is around $15. But there will always be better things and worse things. There are guys that buy the TLC5940 in a breakout board or a shield and pay the same $15 or more, and for this guys I think this way to make your own pwm expansion solution is interesting. For me this chip is very valuable, and I think that for other guys should be too. Matter of personal preference. I think this still a valid solution.