Pages: [1]   Go Down
Author Topic: Help With LED Driver  (Read 797 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have recently been working with TI's TLC59116F LED driver chips. Here is the datasheet... http://www.ti.com/lit/ds/symlink/tlc59116f.pdf. I have been trying to interface it with my Arduino Mega (I2C) with no luck so far. I am using the code found here for driving the chip... http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1295346037. I have the chip hooked up to +5V.

My main issue is that I have no way to know if the chip is even receiving my I2C communication. I have read through the code and the datasheet and everything seems to line up. Does anyone have any suggestions?

Thanks,

Patrick

(I have attached my code)

* TLC59116F.ino (1.48 KB - downloaded 2 times.)
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code reproduced below:

Code:
#include <Wire.h>

char allModuleAddress = 104;
char module1Address = 96;

void setup()
{
  Serial.begin(9600);
  Serial.println("Serial Initialized");
  Wire.begin();
  Serial.println("Wire Initialized as Master");
  initModule(allModuleAddress);
  Serial.println("InitModules Completed");
}

void loop()
{
  setGlobalBrightness(module1Address,5);
//  Serial.println("Brightness Set");
}

// Initialise all outputs for pwm and global dimming, switch off sleep mode
void initModule(char address)
{
  Wire.beginTransmission(address);
  Wire.write(0x80);
  Wire.write(0x01);
  for (char i=0; i<17; i++) {
    Wire.write(byte(0x00));
  }
  for (char i=0; i<6; i++) {
    Wire.write(0xFF);
  }
  Wire.endTransmission();
}

// Set the global brightness to dim all lit leds
void setGlobalBrightness(char address, char brightness) {
  Wire.beginTransmission(address);
  Wire.write(0x12);
  Wire.write(brightness);
  Wire.endTransmission();
}

// Set the brightness of one output
void setLedBrightness(char address, char lednum, char brightness) {
  Wire.beginTransmission(address);
  Wire.write(0x02 + lednum);
  Wire.write(brightness);
  Wire.endTransmission();
}

// Set the brightness for 3 outputs at once (for rgb leds)
void setGroupBrightness(char address, char groupNum, char brightness_r, char brightness_g, char brightness_b) {
  Wire.beginTransmission(address);
  Wire.write(0xA2 + (3*groupNum));
  Wire.write(brightness_r);
  Wire.write(brightness_g);
  Wire.write(brightness_b);
  Wire.endTransmission();
}

Have you got the right I2C address? Please run the I2C scanner on this page:

http://www.gammon.com.au/i2c

Just confirm that it is responding to the expected address (or at all).
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I ran the I2C program and it found no devices. Is it possible that I burn out the chip when soldering it onto the breakout board? What other explanations are there for this not working?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31477
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Using the wrong pins, not having external pull up resistors.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No luck with the pull up resistors. And I'm pretty sure I'm using the right pins. Its pretty explicit in the datasheet
« Last Edit: April 27, 2012, 06:46:20 pm by accel » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think I figured it out...

There was a pin called RESET that was active low that I had to pull high. After that I am getting 3 different devices. Problem solved
Logged

Offline Offline
Sr. Member
****
Karma: 7
Posts: 266
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is some good information here http://arduino.cc/forum/index.php/topic,68816.0.html if you follow the links in the post.

This bit of info relates to the pull up resistors specifically
http://www.dsscircuits.com/articles/effects-of-varying-i2c-pull-up-resistors.html

Aside from the obvious (wrong pins and no pull up resistors) Are you sure both ends are operating ath the same voltage either bothe at 5v or both at 3.3 v ?
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I have been able to see the chip using the program mentioned above. However, beyond that, I am having trouble doing anything. I am new to I2C so I have no idea if the code that I am borrowing actually works. Does anyone know if the commands that I am sending are correct?

Datasheet: http://www.ti.com/lit/ds/symlink/tlc59116f.pdf

Code:
#include <Wire.h>

char allModuleAddress = 111;
char module1Address = 111;

void setup()
{
  Serial.begin(115200);
  Wire.begin();
  initModule(allModuleAddress);
  pinMode(13,OUTPUT);
}

void loop()
{
  //setLedBrightness(module1Address, 0, 255);
  setGlobalBrightness(module1Address,255);
  digitalWrite(13,HIGH);
}

// Initialise all outputs for pwm and global dimming, switch off sleep mode
void initModule(char address)
{
  Wire.beginTransmission(address);
  Wire.write(0x80);
  Wire.write(0x01);
  for (char i=0; i<17; i++) {
    Wire.write(byte(B00000000));
  }
  for (char i=0; i<6; i++) {
    Wire.write(0xFF);
  }
  Serial.print("SetupErrorCode:");
  Serial.println(Wire.endTransmission());
}

// Set the global brightness to dim all lit leds
void setGlobalBrightness(char address, char brightness) {
  Wire.beginTransmission(address);
  Wire.write(0x12);
  Wire.write(brightness);
  Wire.endTransmission();
}

// Set the brightness of one output
void setLedBrightness(char address, char lednum, char brightness) {
  Wire.beginTransmission(address);
  Wire.write(0x02 + lednum);
  Wire.write(brightness);
  //Serial.print("SetBrightnessErrorCode:");
  //Serial.println(Wire.endTransmission());
}

// Set the brightness for 3 outputs at once (for rgb leds)
void setGroupBrightness(char address, char groupNum, char brightness_r, char brightness_g, char brightness_b) {
  Wire.beginTransmission(address);
  Wire.write(0xA2 + (3*groupNum));
  Wire.write(brightness_r);
  Wire.write(brightness_g);
  Wire.write(brightness_b);
  Wire.endTransmission();
}
 
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31477
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Two points:-
1) Your code does not do anything apart from mess about with the global brightness. You need to turn the individual LEDs on.
2) How have you wired up the LEDs. The outputs are open drain so the resistor should be connected to the output, then to the cathode of the. LED , finally the anode of the LED should be connected to the +ve supply.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have connected the LED's up that way and here is the updated code w/o any luck...

Code:
#include <Wire.h>

char allModuleAddress = 111;
char module1Address = 111;

void setup()
{
  Serial.begin(115200);
  Wire.begin();
  initModule(allModuleAddress);
  pinMode(13,OUTPUT);
}

void loop()
{
  setLedBrightness(module1Address, 0, 5);
  //setGlobalBrightness(module1Address,255);
  digitalWrite(13,HIGH);
}

// Initialise all outputs for pwm and global dimming, switch off sleep mode
void initModule(char address)
{
  Wire.beginTransmission(address);
  Wire.write(0x80);
  Wire.write(0x01);
  for (char i=0; i<17; i++) {
    Wire.write(byte(B00000000));
  }
  for (char i=0; i<6; i++) {
    Wire.write(0xFF);
  }
  Serial.print("SetupErrorCode:");
  Serial.println(Wire.endTransmission());
}

// Set the global brightness to dim all lit leds
void setGlobalBrightness(char address, char brightness) {
  Wire.beginTransmission(address);
  Wire.write(0x12);
  Wire.write(brightness);
  Wire.endTransmission();
}

// Set the brightness of one output
void setLedBrightness(char address, char lednum, char brightness) {
  Wire.beginTransmission(address);
  Wire.write(0x02 + lednum);
  Wire.write(brightness);
  //Serial.print("SetBrightnessErrorCode:");
  //Serial.println(Wire.endTransmission());
}

// Set the brightness for 3 outputs at once (for rgb leds)
void setGroupBrightness(char address, char groupNum, char brightness_r, char brightness_g, char brightness_b) {
  Wire.beginTransmission(address);
  Wire.write(0xA2 + (3*groupNum));
  Wire.write(brightness_r);
  Wire.write(brightness_g);
  Wire.write(brightness_b);
  Wire.endTransmission();
}
 

I have tried changing the 5 to 255 and un-commenting the global brightness line with no luck as well.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31477
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You haven't got a reset command.
You don't finish the setLEDbrightness function with an end transmission call.
I am also not convinced you are writing to it correctly but it is late here and I am on my iPad so I can't check.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got everything working. Here is the code...

Code:
#include <Wire.h>

char allModuleAddress = 104;
char module1Address = 111;

void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  Serial.println("Serial Initialized");
  Wire.begin();
  Serial.println("Wire Initialized as Master");
  initModule(allModuleAddress);
  Serial.println("InitModules Completed");
  digitalWrite(13,HIGH);
  randomSeed(analogRead(0));
}
boolean a[] = {true,true,true,true,true};
void loop()
{
  int r = int(random(0,5));
  Serial.println(r);
  a[r] = !a[r];
 
  if(a[r]) setLed(r,255);
  else setLed (r,0);
  delay(50);
}

// Initialise all outputs for pwm and global dimming, switch off sleep mode
void initModule(char address)
{
  Wire.beginTransmission(address);
  Wire.write(0x80);
  Wire.write(0x01);
  Wire.write(byte(0x00));
 
  for (char i=0; i<16; i++) {
    Wire.write(byte(0xFF));
  }
  Wire.write(byte(0xFF));
  Wire.write(byte(0x00));
  for (char i=0; i<4; i++) {
    Wire.write(B10101010);
  }
  Wire.endTransmission();
}
// Set the brightness of one output
void setLed(char lednum, char brightness) {
  Wire.beginTransmission(module1Address);
  Wire.write(lednum+2);
  Wire.write(brightness);
  Wire.endTransmission();
}

The next part of my project that I am trying to figure out is how to interface it with this Darlington Transistor Array...http://www.ti.com/lit/ds/symlink/uln2803a.pdf Does anyone know how to do this. I got the array working by itself by attaching GND to GND, nothing to COM and then +5v to the inputs to connect output and ground. The problem is that the LED driver is a sink, so how do I control the darlington array which requires +volts. And what does the common do?

Thanks for the help

Patrick
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31477
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
so how do I control the darlington array which requires +volts.
You connect a pull up resistor from the input of the darlington to +5V, 3K3 should do.
Logged

Pages: [1]   Go Up
Jump to: