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:
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
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
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.
Well i only need the OE/Output enable pin, if i wanna turn off the TLC chip 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 its the first time i ever used the SPI.
#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);
}
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
#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);
}
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.
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
This thread really helped me get my TLC5916 working but I needed to look in a lot of other places too.
This is the code I put together (with help) to finally get everything working:
/*
Adapted by: d6stringer
Adapted from: Zeecue
June, 8 2018
This test program uses a TLC5916 shift register:
http://www.ti.com/lit/ds/symlink/tlc5916.pdf
Pins in this configuration are wired from an Arduino Nano to the IC in the following configuration:
ArdN---IC
D8-----13 This can be any arduino output wired to the IC's "OE" (output enable) pin
D10----04 This is the arduino's SS (Slave Select) pin wired to the IC's "LE" (latch enable) pin.
D11----02 This is the arduino's MOSI (Master out, slave in) pin wired to the IC's "SDI" (Serial Data In) pin.
D13----03 THis is the arduino's SCK(Serial Clock) pin wired to the IC's "CLK" (Clock) pin.
Current sinks through the TLC5916 pin # 15 (R-EXT). Use a resistor to set the current through the chip.
*/
#include "SPI.h" //library for using SPI
const int ss=10; // using digital pin 10 for SPI slave select
const int OE=8; //Output Enable Pin
void setup()
{
pinMode(ss, OUTPUT); // we use this for SS pin
pinMode(OE, OUTPUT); // we use this for OE pin
digitalWrite(OE, LOW); //enable/disable the OE pin
SPI.begin(); // wake up the SPI bus.
}
void setValue(byte value)
{
digitalWrite(ss, LOW);
SPI.transfer(value); // send value (0~255)
digitalWrite(ss, HIGH);
}
void loop()
{
int deleigh = 100; //set delay time
//Cycle thru each pin and then turn them all on.
setValue(0); // 00000000
delay(deleigh);
setValue(1); // 00000001
delay(deleigh);
setValue(2); // 00000010
delay(deleigh);
setValue(4); // 00000100
delay(deleigh);
setValue(8); // 00001000
delay(deleigh);
setValue(16); // 00010000
delay(deleigh);
setValue(32); // 00100000
delay(deleigh);
setValue(64); // 01000000
delay(deleigh);
setValue(128); // 10000000
delay(deleigh);
setValue(255); // 11111111
delay(deleigh*10);
}