This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TLC59116 is not driving LEDs please help

Other Parts Discussed in Thread: TLC59116, TLC59116F

Hi Everyone,

I am driving TLC59116 chip with Ardunio DUE board. My connection scheme correclty connects Arduino I2C Pins (SDA/20, and SCL/21) with TLC59116 LED Custom designed Driver Board.

In short I am unable to light any led. In detail please see my schematics, code and the register values that i read back by modifying an arduino example code:

In this schematic I mistakenly had used TLC59116 device instead of TLC59116F (which does not requires pull down on pin1). I corrected my scheme to match TLC59116 and added a 150 resistor that now pulls down pin1.

I have made sure that both 3.3V and 5V power supplies are good. I also made sure that SCL and SDA are correclty toggling and are not exchanged. I then ran two Arduino Example codes:

1. github.com/.../TLC59116.ino

This is a sample code which should dim leds in a loop.

2. I also tried burning examples from following Arduino Library:

github.com/.../TLC59116

This library has 2 examples :

  1.   GlowingNumbers
  2.   SineWave

All the three examples do not turn on any LED. 

i then modified the code from first example : TLC59116.ino and added a code to read back and print values of TLC59116 registers. 

Here is the print on console I can see (the first value 0x80 is at register address 0x00):

80
0
FF
FF
FF
FF
FF
FF
FF
FF
FF
FF
FF
FF
FF
FF
FF
FF
FF
0
0
0
0
0
D2
D4
D8
D0
FF
0
0
0

-----------------------

Here you can see that i never see any error reported in EFLAG1 and EFLAG2 registers.

I request everyone to suggest what is wrong that I dont see any LED turned ON ever? I also had tried different values of PWM (0x7F and some other)

Following is my modified code that reads all registers as well as writes to them in continous loop as in TLC59116.ino example code:

// Using Arduino to control LEDs using the TI TLC59116
// Written by Peter Easton (whizoo.com 2013)
// Distributed under Open Software License v3.0


#include <Wire.h>

// I2C bus addresses (excludes the R/W bit)
#define ADDRESS                        0b1100000  // Assumes A0 to A3 are connected to ground
#define ALLCALL_ADDRESS                0b1101000
#define RESET_ADDRESS                  0b1101011

// I2C R/W
#define I2C_READ                       1
#define I2C_WRITE                      0

// Control register (three MSB control auto-increment)
#define NO_AUTO_INCREMENT              0b00000000
#define AUTO_INCREMENT_ALL_REGISTERS   0b10000000
#define AUTO_INCREMENT_BRIGHTNESS      0b10100000
#define AUTO_INCREMENT_CONTROL         0b11000000
#define AUTO_INCREMENT_BRIGHT_CONTROL  0b11100000

// TLC59116 registers
#define TLC59116_GRPPWM                0x12
#define TLC59116_LEDOUT0               0x14

// LED output state for LEDOUT0 to LEDOUT3
#define LED_OUTPUT_OFF                 0b00
#define LED_OUTPUT_GROUP               0b11


void setup()
{
  Wire.begin();
  Serial.begin(9600);
  
  Serial.println ("TLC69116");
  
  //reset();        // added by aoc
  // Transmit to the TLC59116
  Wire.beginTransmission(ADDRESS);
  // Send the control register.  All registers will be written to, starting at register 0
  Wire.write(byte(AUTO_INCREMENT_ALL_REGISTERS));
  // Set MODE1: no sub-addressing
  Wire.write(byte(0));
  // Set MODE2: dimming
  Wire.write(byte(0));
  // Set individual brightness control to maximum
  for (int i=0; i< 16; i++)
    Wire.write(byte(0xff));  //0XFF 
  // Set GRPPWM: Full brightness
  Wire.write(byte(0xff));  //0XFF
  // Set GRPFREQ: Not blinking, must be 0
  Wire.write(byte(0));
  // Set LEDs off for now
  for (int i=0; i< 4; i++)
    Wire.write(byte(0x00));
  // Set the I2C all-call and sub addresses (if needed)
  Wire.endTransmission();

  delay(100);
  
  //setLEDs(0xAAAA);
  //setBrightness(0xAA);
  
  read_registers();
  
}


void loop()
{
  // reads all registers
  read_registers();
  
  // Loop through LEDs from 0 to 15
  for (int i=0; i<16; i++) {
    setLEDs(1<<i);
    delay(100);
  }
  
  // Light all LEDs and slowly dim them
  setLEDs(0xFFFF);
  for (int i=255; i > 0; i--) {
    setBrightness(i);
    delay(20);
  }
  setLEDs(0);
  setBrightness(0xFF); 
  
}


// Turn the LEDs on or off.  LEDs is a 16-bit int corresponding to OUT0 (LSB) to OUT15 (MSB)
void setLEDs(int LEDs)
{
  int registerVal=0;
  int registerIncrement = LED_OUTPUT_GROUP;
  
  Wire.beginTransmission(ADDRESS);
  // Write to consecutive registers, starting with LEDOUT0
  Wire.write(byte(AUTO_INCREMENT_ALL_REGISTERS + TLC59116_LEDOUT0));
  
  // Write the value for LEDs
  for (int i=0; i< 16; i++) {
    if (LEDs & 0x01)
      registerVal += registerIncrement;
    // Move to the next LED
    LEDs >>= 1;
    // Are 4 LED values in the register now?
    if (registerIncrement == LED_OUTPUT_GROUP<<6) {
      // The register can be written out now
      Wire.write((byte) registerVal);
      registerVal = 0;
      registerIncrement = LED_OUTPUT_GROUP;
    }
    else {
      // Move to the next increment
      registerIncrement <<= 2;
    }
  }
  Wire.endTransmission();
}


// Set the brightness from 0 to 0xFF
void setBrightness(int brightness)
{
  Wire.beginTransmission(ADDRESS);
  // Write to the GRPPWM register
  Wire.write(byte(NO_AUTO_INCREMENT + TLC59116_GRPPWM));
  Wire.write(byte(brightness));
  Wire.endTransmission();
}

// Reset all TLC59116's on the I2C bus
void reset()
{
  Wire.beginTransmission(RESET_ADDRESS);
  Wire.write(byte(0));
  Wire.endTransmission();
}

// reads all registers and prints them over serial console
void read_registers (void)
{
  Wire.beginTransmission(ADDRESS);
  // Write to consecutive registers, starting with LEDOUT0
  Wire.write(byte(AUTO_INCREMENT_ALL_REGISTERS + 0));
  Wire.endTransmission();
  
  Wire.requestFrom(ADDRESS, 32);    // request n bytes from slave device #ADDRESS


  while(Wire.available())    // slave may send less than requested
  { 
    char c = Wire.read();    // receive a byte as character
    Serial.println(c, HEX);         // print the character
  }  
  Serial.println ("-----------------------------");  
  delay (3000);  
}