Pages: [1]   Go Down
Author Topic: How to wire up a TLC5916 led driver chip  (Read 5507 times)
0 Members and 1 Guest are viewing this topic.
Denmark
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
zeecue.dk - DK Forum
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

Just got me some TLV5916 chips, and im having some hard time to figure out to how to wire it to my arduino megas(actually a seeeduino mega) SPI pins, because the datasheet kinda confuses me, especially the LE(ED1) and OE(ED2) pins on the TLC5916 chip.
This is what i have figured out on my own, please correct me if they are wrong.
Arduino pin - TLC5916 pin
51 MOSI - 2 SDI
52 SCK - 3 CLK
And here is a breadboard drawing and some data over the chip:

And the datasheet if you need that:
http://focus.ti.com/docs/prod/folders/print/tlc5916.html

Best regards
Morten
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the two pins you listed are correct.
and SDO, only if you need it, should go to the MISO pin 50 on the mega (but you probably don't need to connect SDO because it's only for error detection on this chip).

OE is just a pin to let you enable/disable the output. In order to control it, you'd hook it up to one of the I/O pins on the arduino, and digitalWrite(HIGH / LOW) in the code when necessary in the sequence.

to get a better idea about OE and, more importantly, about LE, look at the truth table (Table 3 on the datasheet):
I'd hook up LE to one of the I/O pins on the arduino as well and, in my code, send it the appropriate HIGH or LOW signal as necessary... how exactly you use this depends on your application/what you are aiming to do with this chip and the LEDs.

And the R-ext pin is connected to a resistor so as to set the current for all the outputs to the LEDs
Logged

Denmark
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
zeecue.dk - DK Forum
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you, i think i understand it now.

I allready knew the R-ext, to change the current.
Next problem is to understand how to send a "command" to the TLC chip, because i cant seem to understand how to do that :-D
Code:
/*
#include "SPI.h" // necessary library
int ss=10;
int oe=11;

void setup()
{
  pinMode(ss, OUTPUT);
  pinMode(oe, OUTPUT);
  SPI.begin(); // wake up the SPI bus.
  SPI.setBitOrder(LSBFIRST);
}

void setValue(int value)
{
  digitalWrite(ss, LOW);
  SPI.transfer(0); // send command byte
  SPI.transfer(value); // send value (0~255)
  digitalWrite(ss, HIGH);
}

void loop()
{
    setValue(1111111);
    delay(1000);
    setValue(00000000);
    delay(1000);
    setValue(00000001);
    delay(1000);
    setValue(00000011);
    delay(1000);
    setValue(11000000);
    delay(1000);
    setValue(10101010);
    delay(1000);
    setValue(1000000);
    delay(1000);
    setValue(1000);
    delay(1000);
}

This code makes the LEDs blink like crazy, but its a crude code, i know, im a beginner.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You are not doing anything with the output enable pin. Take it high, load the data in and then put it low.
Logged

Denmark
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
zeecue.dk - DK Forum
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I know, but it didnt really change anything doing so, guess ill have to mess around with it some more :-D
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but it didnt really change anything doing so
Therefore you are doing something else wrong. It needs to be in. Just because it did nothing doesn't mean that when you have corrected all your mistakes it will continue to do something. Can you be a bit clearer about what is going wrong than just a vague "makes the LEDs blink like crazy".

Cut down on what the LEDs do to just one pattern, say 0x55 (every other one on), then you can see what it actually does and compaire it with what you expect.
Logged

Denmark
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
zeecue.dk - DK Forum
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well i only need the OE/Output enable pin, if i wanna turn off the TLC chip :-D so nothing i wanna mess with right now.
And i figured out how to change the leds now, and i have cleaned up my code a bit.
Thanks alot for helping me on my way :-D its the first time i ever used the SPI.
Code:
#include "SPI.h"
int ss=10; // using digital pin 10 for SPI slave select

void setup()
{
  pinMode(ss, OUTPUT); // we use this for SS pin
  SPI.begin(); // wake up the SPI bus.
  SPI.setBitOrder(LSBFIRST);
  }

void setValue(int value)
{
  digitalWrite(ss, LOW);
  SPI.transfer(0); // send command byte
  SPI.transfer(value); // send value (0~255)
  digitalWrite(ss, HIGH);
}

void loop()
{
      setValue(255); // Turn all 8 leds on 11111111
      delay(1000);
      setValue(170); // Turn 4 leds on 10101010
      delay(1000);
      setValue(147); // Turn 4 leds on 10010011
      delay(1000);
}
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
i only need the OE/Output enable pin, if i wanna turn off the TLC chip
No it stops them from flickering during the SPI loading process. It might be only brief but it will be visible under the right light conditions. 

Quote
its the first time i ever used the SPI.
\
Well done.  smiley
Logged

Denmark
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
zeecue.dk - DK Forum
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, well when i only have that one TLC connected it works just fine without the output enable part.
But when i have 2, they both blink the same way, and i have tried to incorporate the OE pins.
The TLC chips, share ground, MOSI, CLK and 5v, they have individual wires to the SS and OE and current limiting resistor.
I must be doing some newbie errors :-)
Code:
#include "SPI.h"
int ss=11; // using digital pin 10 for SPI slave select
int ss2=10; // using digital pin 10 for SPI slave select - 2
int oe=7; // output enable
int oe2=6; // output enable - 2

void setup()
{
  pinMode(ss, OUTPUT); // we use this for SS pin
  pinMode(ss2, OUTPUT); // use use this for SS pin - 2
  pinMode(oe, OUTPUT);
  pinMode(oe2, OUTPUT);
  SPI.begin(); // wake up the SPI bus.
  SPI.setBitOrder(LSBFIRST);
  }

void setBLUE(int Bluevalue)
{
  digitalWrite(oe, HIGH);
  digitalWrite(ss, LOW);
  SPI.transfer(0); // send command byte
  SPI.transfer(Bluevalue); // send value (0~255)
  digitalWrite(ss, HIGH);
  digitalWrite(oe, LOW);
}
 
  void setRED(int Redvalue)
{
  digitalWrite(oe2, HIGH);
  digitalWrite(ss2, LOW);
  SPI.transfer(0); // send command byte
  SPI.transfer(Redvalue); // send value (0~255)
  digitalWrite(ss2, HIGH);
  digitalWrite(oe2, LOW);
}

void loop()
{
      setBLUE(255); // Turn all 8 leds on
      delay(500);
      setBLUE(0); // Turn all 8 leds off
      setRED(255); // Turn all 8 leds on
      delay(500);
      setRED(0); // Turn all 8 leds off
      delay(500);
     
     
     
}
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34725
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Look at page 5 of the data sheet. You will see that LE should be kept low throughout the shifting and then set high and taken immediate low again. You are not doing this in your code.
Logged

Denmark
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
zeecue.dk - DK Forum
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, weird i got it working with one chip without doing that.
But you where right, it did solve my problems by setting it to LOW, send data, HIGH and then LOW again, thanks again :-D
Logged

Pages: [1]   Go Up
Jump to: