Monday, July 27, 2015

Interfacing TL5955 Using Arduino

You know those YouTube videos that make you think “Awsome… I want one?” well check this reactive LED table out:

YouTube LED Reactive Table

Now,… to build an improved version:

Requirements:

  • Multi Mode
    • Clock Mode showing digital clock
    • X&O Game
    • Snake Game
    • Sound Equalization’s
    • Ping Pong Game
  • More LEDs!!!
  • Finer Resolution
  • Fade Effect, Variable brightness Control

Yes the list may be ambitious, but lets see how it goes.

First up, Based on my donor table I can accommodate 48×27 (1296!!!) White LEDs Driving this array will require some thinking. I stumbled across the DADDY of all LED drivers made by TI the TLC5955. This bad boy can drive 48 LEDs using a single chip.

Hmmm… I have 27 Rows of 48 LEDs, I wonder if this one chip can be multiplexed to drive all 1296 LEDs! Let the games begin.

A breakout board was created as these (TLC5955) buggers only come in teeny tiny surface mount packages.

The TLC5955 is interfaced over serial communications, It has a single input register of 769 bits that must be written and latched.

If the MSB is 0 then the remaining bits are used to code the brightness of each LED using 2 Bytes (16bits) per LED. This means 0×0000 is off and 0xFFFF is full on.

If the MSB is 1 then when latched data is transferred to the “control” register, this needs to be done only once in most cases as this register sets global brightness and features.

Implementing the Arduino Code ( Why Arduino you ask?… because I got out voted by my team(I like PIC)):
There exists a library for the TLC5940 that I tried to use initially but soon after abandoned that Idea for code from scratch, come on how hard can it be to write serial data?

Turns out there are multiple ways of achieving serial communications

  • Using the standard Serial.begin(); <-- maximum 115.2kHz
  • Using software based bit bang, toggling a digital pin <-- CPU intensive
  • Using SPI library on MOSI,MISO,SCK,SS pins <-- Can reach speeds of Fosc/2 (10Mhz for the ATmega2560)

It was easy enough to setup a new Arduino project that imported the SPI library. This can then be used to transfer data byte by byte. This was the problem… byte by byte? The guys over at TI have made my life hard by firstly not having a register that is a multiple of 8bits, forget that, each setting in the control data is either 3,5 or 7 bit combinations???

We therefore need a way to build up the bytes to be transferred. The register of 769 in code was increased to 776bits (97bytes) with the first byte 0000 000X where X is the control bit of the 769 bit register.

Using this method, the Control data was first written once on bootup followed by LED control data.

Now for the challenge… Can we multiplex this one IC to drive all 1296 LEDs? I got hold of a few 74HC595 serial in parallel out shift registers and have interfaced them to the arduino. each output of this shift register will enable a 48LED line therefore I need 4 of these ICs (8*4=32 >> 27).

That’s as far as I have got for now.