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.

TLC5951: Driving daisy chained TLC5951s with arduino

Part Number: TLC5951
Driving 3 daisy chained TLC5951s with a arduino. Is it possible to do this ? Is the spi clock of the arduino mega 2560 fast enough to do this ? Is there any sample code available to achieve this ? ( I have seen the "limb" code in GitHub , but this is only for one devices have 3 daisy chained .... ) I have tried the above code on the first device in the chain ... But it only lights 6 of the 8 LEDs ? Is there someone I could chat to to get a better understanding of the workings of this device ?
  • Hi, Gowen,

    The post has been assigned to proper engineer, will reply as soon as possible .

    Regards,
    Kenneth
  • Hi Gowen,

    Could you please let me know how much is the fastest frequency of your arduino? Is there any crystal integrated to generate the clock signal, how much frequency is it? It would be better if you could share the schematic or simple block diagram of your design.

    As you mentioned, there is only one device used with that code, I suspect the data was not correctly sent to all the three devices.

    Best regards,
    Jason
  • Hi Jason,

    Attached is a Block diagram and schematic.

    1. the GSCK for red green and blue are all tied together and all linked back to Pin 13 of Arduino.  (Modified from Pin 9 of the Limb example) 

    2. Xblink are all tied together and connected to Pin 23 of arduino

    3. GSLAT  are all tied together and connected to Pin 22 of arduino

    4. all GSSCK pins are tied together and connected to Pin 52 arduino

    5. all GSSIN pins of each bank are tied together and connected to  Pin 51 arduino.   ( 7 X data-in lines driving 7 banks )

    The arduino has a 16mhz clock the SPI bus is set to half that ( 8mHz)  we are using this clock to send data to our led Board.

    We clock in the data to the first chip of Bank 1, we then sent the same data again expecting it to shift into the second chip of bank 1... we repeat this a third time to shift the data into the third chip of bank.

    the data we send to Chip # 1 seems to work correctly, ( All LEDS light).

     We then send the same data again expecting to see the same data shifted to Chip # 2.. we see all leds lighting from Chip # 1 as expected , but  Chip#2 does not consitantly light all leds. we do the same again and expect the data to be shifted accross to chip#3 ... but we see the same issue ... it seems that some of the data is not shifted accross correctly. always the first Chip # 1 is correct, but subsequent shifts from this to # 2 and 3 seems to not work correctly.

    We see a similiar issue with bank 2 etc.. the first chip of each bank gets the correct data and lights all LEDS, but subsequent shifts to Chip # 2 and 3 do not always light all the LEDS.

    Sometime the shift works correctly but other times some LEDS on Chip # 2 and 3 do not light.

    Here is the code we modified to lshift to next chip and light all banks

    // GSSCK and GSSIN are connected to SPI Clock and MOSI pins respectively
    // GSLAT is on pin 22 and XBLNK to 23
    // All the Grayscale clocks for Green, Red, and Blue (GSCKG, GSCKR, GSCKB)
    // are connected to the same arduino pin (9)
    //-------------------------------------------

    #include "TLC5951.h"
    #include <SPI.h>

    #define GSLAT 22
    #define XBLNK 23
    #define GSCKGRB 13
    #define start_color "red"
    TLC5951 tlc;

    void setup() {
    // Set the timer to max speed for fastest PWM generation
    // This is required so that the Grayscale clocks on the TLC5951 are fast enough to prevent visible jittering in the LEDS
    // The current values are for a Arduino Mega 2560
    // Link to find values for you arduino/pins: playground.arduino.cc/.../TimerPWMCheatsheet
    TCCR0B = TCCR0B & 0b11111000 | 0x01; // Pins 9 & 10 @ 31250 Hz

    // Now set the GSCKGRB to an output and a 50% PWM duty-cycle
    // For simplicity all three grayscale clocks are tied to the same pin
    pinMode(GSCKGRB, OUTPUT);
    analogWrite(GSCKGRB, 127);

    // The library does not ininiate SPI for you, so as to prevent issues with other SPI libraries
    SPI.begin();
    SPI.setClockDivider(SPI_CLOCK_DIV2);

    // init(GSLAT pin, XBLNK pin, default grayscale values for all LEDS)
    tlc.init(GSLAT, XBLNK, 0);

    // setLED(Output number, Red value, Green value, Blue value)
    // The next lines set all LED's to the brightest blue setting (0-4095)
    // tlc.setLED(0, 0, 0, 4095);
    // tlc.setLED(1, 0, 0, 4095);
    // tlc.setLED(2, 0, 0, 4095);
    // tlc.setLED(3, 0, 0, 4095);
    // tlc.setLED(4, 0, 0, 4095);
    // tlc.setLED(5, 0, 0, 4095);
    // tlc.setLED(6, 0, 0, 4095);
    // tlc.setLED(7, 0, 0, 4095);

    // We must set dot correction values, so set them all to the brightest adjustment
    tlc.setAllDCData(127);

    // Set Function Control Data Latch values. See the TLC5951 Datasheet for the purpose of this latch.
    // Data is input LSB first, ie bit 192 (for red DC range) is first, a 1
    // bit 198 (0) is last, for the grayscale counter mode
    tlc.setFunctionData(B1111100);
    Serial.begin(115200);

    for(int i = 0; i <= 7; i++){
    tlc.setLED(i,0,0,0);
    //Serial.println (i);
    }
    // set all brightness levels to max (127)
    tlc.update();

    delay(100000);
    for(int i = 0; i <= 7; i++){
    tlc.setLED(i,4095,4095,4095);
    Serial.println (i);
    }

    // Finally, call the function to send the data to the TLC5951
    // tlc.update();

    // blue,x red
    tlc.setBrightness(8,0,0);
    tlc.update();
    delay(100000);
    tlc.setBrightness(0,8,0);
    tlc.update();
    delay(100000);
    tlc.setBrightness(0,0,8);
    tlc.update();

  • Hi Gowen,

    The function control data should be written through the DSSIN and DSCLK pin, but both these two pins are connected to GND in your schematic. I think this should be the problem.

    There is no default value for DC/BC/FC/UC, the data in the register is random. So sometimes the LED driver would work, but sometimes, it would not.

    Best regards,
    Jason
  • Thanks for your response,

    We are sending the Functional Control data to the device via the GSSIN pin. As I understand it  - doing it this way is possible.

    We were formatting the Functional Control data ( 216 bits) , and sending it to the device  ( via the GSSIN pin ), and then formatting the GSdata ( 288 bits)and then sending it to ( via the GSSIN pin ) latching each by clocking glat pin.

    However I think our issue was that, because we have 3 devices daisy chained, we initially sent the Control data then the Device data to the first device, latched it, then did the exact same for the second, latched it, and then the same for the third.

    What we should have done was format all the Control data ( 648 bits), send this to the 3 devices, then format the  GSdata ( 864 bits) and send this to the 3 devices .. by doing this it now seems to work correctly.

    Does this make sense ?

    regards

  • Hi Gowen,

    Correct, that's the reason.
    If latch signal after only 216 bits data, then only device 1 get the correct data, but device 2 and device 2 does not.
    All the data should be sent to all 3 devices, and then send the latch signal.

    Best regards,
    Jason
  • Thanks Jason,



    One further thing...

    We have one Data line and one clock ( MOSI to GSSIN and Spi clk to SCLK) which we use to send Control data ( 648 bits), and GSdata ( 864 bits) to bank # 1.

    We then connected all the data lines of the other banks to the same MOSI and this allows to send the same data to each bank .. all at the same time.

    We would now like to set a different brightness on , say bank 7 and 8 only ... is it possible to do this ?

    we thought if we switched in the different bank GSSIN lines to our MOSI ( using maybe relays) we could send different Control Data to different banks .. But I'm thinking the fact that we have the SCLK tied together on all banks ... will not allow us to do this ?

    thanks