Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Extend Arduino PWM with TLC5940: A Complete 16‑Channel LED Driver Guide

In this Arduino Tutorial we will learn how to use the TLC5940 PWM Driver using the Arduino Board. The TLC5940 is a 16-Channel LED Driver which provides PWM outputs and it’s perfect for extending the Arduino PWM capabilities. Not just LEDs, but with this IC we can also control servos, DC Motors and other electronics components using PWM signals.

Extend Arduino PWM with TLC5940: A Complete 16‑Channel LED Driver Guide

Basic Features

  •  VCC = 3V to 5V
  • 16 Channels
  • 12 bit (4096 Steps) PWM Control
  • Driving Capability
        – 0 mA to 120 mA (VCC > 3.6V)
        – 0 mA to 60 mA (VCC < 3.6V)
  • Serial Data Interface
  • 30 MHz Data Transfer Rate
  • Daisy chaining

Daisy chaining is a great feature which means that we can connect multiple TLC5970 ICs together in series. With this we can extend the Arduino’s PWM capabilities to more than 16 outputs, for example 32, 48, or 64 PWM outputs and still use the same 4 pins used by the Arduino Board as for controlling one TLC5940 IC.

You can get the components for this tutorial from any of the sites below:

  • Arduino Nano………………………..
  • Ultra Bright Red LEDs…………… 
  • TLC5940 LED Drivers…………… 

Arduino and TLC5940 Wiring

For controlling the TLC5940 we need to occupy 4 pins of your Arduino Board. As we will use the TLC5940 Arduino Library made by Alex Leone we need to connect the IC to the Arduino according to his library configuration or using the following circuit schematics:

Extend Arduino PWM with TLC5940: A Complete 16‑Channel LED Driver Guide

The circuit schematics above is using external power supply for powering the LEDs, but also it can be connected just using the Arduino VCC itself if the total amount of drawn current doesn’t exceed the limit of the Arduino (Absolute Maximum Rating, DC Current VCC and GND Pins – 200 mA).

We also need to note that the TLC5940 is a constant-current sink, so the current flow towards the output pins. This means that when connecting LEDs we need to connect the negative lead (Cathode) to the output pin of the IC and the positive lead (Anode) to the 5V VCC.

We also need 2 capacitors for decoupling and a resistor for controlling the amount of current that flow through the outputs. The value of the resistor depends on the component that we want to control and it can be selected using the following diagram from the datasheet of the TLC5940.

Extend Arduino PWM with TLC5940: A Complete 16‑Channel LED Driver Guide

So according to the diagram, for controlling LEDs which require 20mA current we need a 2K resistor.

Source Code

Once we download and install the TLC5940 Arduino Library made by Alex Leone we can use his “BasicUse” demo example for understanding how the control the outputs of the IC.

Here’s a simple code that I made for this tutorial for controlling 16 LEDs using this library. Read the comments in the code for understanding how the functions works.

/*
 * Arduino and TLC5940 Tutorial - Simple Example
 * by Dejan Nedelkovski, www.HowToMechatronics.com
 */

#include "Tlc5940.h" 

void setup() {
  Tlc.init(0); // Initiates the TLC5940 and set all channels off
}
 
void loop() {
  Tlc.set(0,4095); //(Output Pin from 0 to 15,PWM Value from 0 to 4095)
  // Note: The previous function doesn't activates the output right away. The output will be activated when the Tlc.update() function will be executed!
  
  Tlc.update(); // Activates the previously set outputs
  delay(1000);

  // For activating all 16 outputs at the same time we can use a for loop for setting all of them to be set to PWM value of 4095. Then  the Tlc.updata() function will active them all at the same time.
  for (int i = 0; i < 16; i++) {
    Tlc.set(i, 4095);
  }
  Tlc.update();
  delay(1000);

  //The Tlc.clear() function clears all the outputs, or sets the PWM value of all outputs to 0
  Tlc.clear();
  Tlc.update();
  delay(1000);

  // This for loop will active all 16 LEDs one by one
  for (int i = 0; i < 16; i++) {
    Tlc.set(i, 4095);
    Tlc.update();
    delay(200);
    Tlc.clear();
    Tlc.update();
    delay(200);
  }
}Code language: Arduino (arduino)

Controlling more then one TLC5940

For connecting more then one of these ICs in series we can use the same circuit schematics as shown above. The only difference is that the SOUT (Signal Output – pin 17) of the the first IC needs to be connected to the SIN (Signal Input – pin 26) of the second IC and so on.

Extend Arduino PWM with TLC5940: A Complete 16‑Channel LED Driver Guide

As for the programming part we need to make some modifications. In the TLC5940 library folder we need to modify the tlc_config.h file and change the value of the variable NUM_TLCS to the number of TLC5940 ICs connected in series and in our case that value is 2. With this done, now we can easily address all the LEDs from 0 to 31 and use the same method of programming as previously described.

Extend Arduino PWM with TLC5940: A Complete 16‑Channel LED Driver Guide

As an example, on the following link, you can check out my DIY LED Heart Photo Frame – Arduino Project where I use 2 TLC5940 ICs for controling 32 LEDs.


Manufacturing process

  1. Create a Secure Arduino RFID Lock – Step‑by‑Step Guide
  2. Build a Universal IR Remote with Arduino: Step‑by‑Step Guide
  3. Arduino Nano Fingerprint Sensor Project – Step‑by‑Step Tutorial
  4. Build JARVIS v1 Home Automation with Arduino Nano – Step‑by‑Step Tutorial
  5. Master Arduino Multithreading with Protothreading: A Step‑by‑Step Tutorial
  6. Mastering I2C Communication with Arduino: A Practical Tutorial
  7. Mastering RGB LEDs with Arduino: A Step-by-Step Tutorial
  8. Master Arduino & MATLAB Integration: Step‑by‑Step Serial Communication Tutorial
  9. Arduino Tutorial 06: Connecting Arduino to Processing via Serial Communication
  10. Arduino Tutorial 02: Buttons & PWM – Master Digital I/O & LED Control