To Build a Robot Part 4
April 9, 2010
I received my TLC 5940 NT from Texas instruments and immediately set it up to do a quick test with some LEDs which is always fun: LED Video
I was working on the initial setup while I was sick so I missed something very obvious about the design of my circuit. The TLC actually uses the Ground to produce the PWM wave where the Arduino uses the +. This means to have it turn on the H-Bridge you need to do a pull-up resistor so you can feed it with the 5v.
I used 2k resistors for the Pull-up and things worked well, when I went to 10k the motor slowed in reverse (no idea why right now ill investigate later)
Using this setup you can drive a very large number of motors. You can put the TLC5940 chips in series and control hundreds of motors. For the setup I have here you could control 2 motors per H-Bridge if you use the L293B (but get the L293D) like I have here. Since each motor only requires 2 pins you can control a maximum of 8 motors per TLC5940 chip if you also have 4 h-bridges. If you only need the DC Motor to spin in one direction you only need 1 Pin to control it and could then control 16 motors with variable speed.
Keep in mind the amperage when driving motors with the L293 series they all allow up to about 1 amp. Some motors are very powerful and can reach this limit quickly. Choose your H-Bridge wisely.
Docs and Datasheets:
The sketch uses the TLC library for the Arduino available here: TLC5940 Arduino Library
The sketch just spins a motor forward for 1 second then breaks and backward for a second.
#include "Tlc5940.h" boolean forward = false; void setup() { Tlc.init(); } void loop() { Tlc.clear(); forward = !forward; if (forward) { // Brake Tlc.set(1, 0); Tlc.set(2, 0); Tlc.update(); delay(500); // Go Tlc.set(1, 0); Tlc.set(2, 4095); } else { // Brake Tlc.set(1, 0); Tlc.set(2, 0); Tlc.update(); delay(500); // Go Tlc.set(1, 4095); Tlc.set(2, 0); } Tlc.update(); delay(1000); }
hey
what pins do you hook it up to on the arduino
and if i want 4 motor controllers do i need 4 arduinos or will it work with 1 arduino
It is using the TLC5940 to control the L293B which controls the speed and direction of the motor while acting as a bridge for the external power source. You would just need to hook it to a second pin on the TLC5940 (there are 15 available). Since the L293B can power two motors at the same time you could use that to run two motors and just add a second L293B for the next two.
Also the pins on the schematic are correct pinouts for the arduino board itself not the chip. So pins 6, 9, 10, 11, 13 are used to control the TCL5940 which is all you will need because the code controls the rest of the pins on that chip.