no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | tutorials:extending_pwm_output_pins_with_a_texas_instruments_tlc5940_led_driver [2018/11/01 18:55] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Extending PWM output pins with a Texas Instruments TLC5940 LED driver ====== | ||
+ | ===== Introduction | ||
+ | |||
+ | Microcontrollers like the Arduino were designed to facilitate the use of electronics for designers and DIY enthusiasts. The interface provides a great starting points for a variety of elecronic circuit designs. However, as the microcontroller is standardized, | ||
+ | |||
+ | What can you do to extend the PWM capabilities of your Arduino? Just buy a bigger one? That is not necessary anymore after you have read this article. Here it is shown how to connect an Arduino microcontroller to a Texas Instruments TLC5940 LED Driver to connect a large number of LEDs, or even power-intensive devices such as star-mounted high power RGB LEDs or servo motors. | ||
+ | |||
+ | In the design of digital musical instruments (DMIs), this is particularily useful to provide different kinds of feedback to the performer while maintining high extensibility at a lower cost. | ||
+ | |||
+ | <note warning> | ||
+ | |||
+ | ===== Capabilities | ||
+ | The datasheet of the TLC5940 is available from [[http:// | ||
+ | |||
+ | A selection of important features: | ||
+ | | **Number of channels** | ||
+ | | **Resolution** | ||
+ | | **Drive Capability** | ||
+ | |||
+ | |||
+ | ==== Connectable actuators | ||
+ | Many electrical components can be controlled using a PWM signal. Not only LEDs can be dimmed, but also Servo motors can be driven, as well as DC motors. | ||
+ | |||
+ | ==== Daisy chaining | ||
+ | Daisy chaining means that you can wire multplie devices together in series. In our case, we can not only extend the PWM pins with one TLC5940 with 16 pins, but because of the daisy-chain ability even use multiple TLC5940s to output 32, 48 or 64 PWM signals. | ||
+ | |||
+ | ===== Wiring | ||
+ | |||
+ | The wiring of the TLC5940 will occupy 4 PWM pins on the Arduino for the serial communication to the chip. Depending on your Arduino, you will have to look up the according pins that have to be connected. The [[http:// | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Generally, the MOSI pin is connected to the TLC SIN, SCK to SCLK on the TLC, OC1A to XLAT, OC1B to BLANK and OC2B to GSCLK. In addition, the TLC's DCPRG should be connected to V< | ||
+ | |||
+ | In order to daisy chain two or more TLC5940, connect the SOUT of TLC 1 to the SIN of TLC 2, and the SCLK, XLAT, BLANK and GSCLK and proceed in that manner for every additional TLC5940. | ||
+ | |||
+ | A 10k pull-up resistor connects the TLC BLANK to GND. This is necessary in order to turn off all outputs while the Arduino resets, so that they do not ”float“ (it would output the voltage difference between two not ground-referenced signals – basically noise). It is only necessary to add this resistor to the first TLC5940 in the daisy chain, as the BLANK pins are connected. | ||
+ | |||
+ | The IREF pin of every TLC5940 has to be connected to V< | ||
+ | |||
+ | R = V / I \\ | ||
+ | R = 39.06 V / 0.020 A \\ | ||
+ | R = 1,953 ≅ 2k | ||
+ | |||
+ | For those who want to know where the number 39.06 comes from: As the output current of the TLC5940 is set by a current mirror by taking the reference current (that is determined by a resistor from an on-chip 1.24V voltage reference) and multplying it with a nominal gain of 31.5 you get 1.24 x 31.5 ≅ 39.06! | ||
+ | |||
+ | Please study this breadboard layout for connecting 32 LEDs to your Arduino. Note that output pins 0 and 15 of the TLC5940 are on the opposite site of the other output pins. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | ==== Control circuit | ||
+ | An Arduino microcontroller is limited in its output current to 40 mA, while it should probably not be driven at maximum. Overall, you should not draw more than 200 mA current from the Arduino as that is the processor chip package current.\\ | ||
+ | If you need to drive high power consuming devices, you should design a control circuit and a work circuit. The control circuit, which is driven with a low current, will tell the work current when to let current flow to your connected devices. This is accomplished through the use of transistors. For every output pin that you want to control separately, you'll need a PNP transistor. | ||
+ | > **Note**: Don't pick an NPN transistor, as the TLC5940 is a constant-current **sink** and the current has to flow towards the output pins. As a PNP transistor' | ||
+ | Make sure that you get a PNP transistor that switches quickly and operates at the TLC5940' | ||
+ | The work circuit is only connected with the Arduino through the transistors and operates at a higher current auch as 400 mA. If you would connect a star-mounted high power RGB LED such as a [[http:// | ||
+ | |||
+ | R = (supply voltage - diode voltage) / (diode current)\\ | ||
+ | e.g., \\ | ||
+ | R = (5 V - 2.5 V) / (0.4 A) = 6.25 Ohm\\ | ||
+ | |||
+ | You should choose the resistor that is nearest to the off-rounded value of that number. | ||
+ | |||
+ | Choose the power supply according to the amount of Watt needed by the connected devices. You can calculate the power of each device by multiplying the voltage and the current and then sum the results. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | These simplified schematics show a single high power LED connected via a PNP transistor to the TLC5940. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ===== Arduino Code ===== | ||
+ | For the Arduino code, please refer to the well documented [[http:// | ||
+ | The Example file BasicUse.h will guide you through the most important library features. Basically, the TLC has to be initialized in the setup statement of the code (// | ||
+ | An important thing to know is that if you want to use multiple TLC5940s, you have to set their quantity in the file ”tlc_config.h“ in the library' | ||
+ | |||
+ | Servo motors have to be controlled differently than common LEDs. Fortunately, | ||
+ | Be aware that you cannot use LEDs and servo motors with the same TLC5940 (either if daisy-chained), | ||
+ | |||
+ | ==== Applications | ||
+ | The circuit is useful for connecting any large number or actuators to your device. For example, you could imagine giving visual feedback to user interaction on different interaction locations. An array of individually PWM controlled LEDs that can even be faded gradually can be accomplished using the TLC5940. | ||
+ | |||
+ | An array of individually contollable servo motors could be used for many purposes, as servo motors are very accurate, quite fast adjusting their angle and versatile due to the available servo accesoirs such as horns and rods. | ||
+ | |||
+ | ===== Additional Information ===== | ||
+ | |||
+ | Sparkfun sells a [[https:// | ||
+ | |||
+ | ===== Summary | ||
+ | |||
+ | This document provided an introduction to the TLC5940 LED driver, details on its capabilities and applications and practical information on its implementation and use with the Arduino library. | ||
+ | |||
+ | ===== Fritzing files ===== | ||
+ | [[http:// | ||
+ | |||
+ | {{: | ||
+ | |||
+ | The contained Frizing file // |