Table of Contents

OctoBrite DEFILIPPI

ASCII The OctoBrite DEFILIPPI is a unique product that allows independent control of eight RGB LEDs or 24 individual LEDs. It is based on a Texas Instruments TLC5947 24-channel PWM LED driver. Each channel has an independent 12-bit PWM, for very smooth color control. Since each channel has an independent PWM and current control, there is no reduction in brightness often found in strobed matrix methods of driving larger numbers of LEDs.

Features

Controller: Texas Instruments TLC5947
LED Current: 20mA per channel
Current: 500mA maximum (all channels on)
Power Supply: 5.5V to 30V (depending on LED forward voltage)
Inputs: DI, LI, EI, CI
Outputs: DO, LO, EO, CO, 24 current sinks
PCB Size: 2.15 x 2.15 inches
Pin Spacing: 0.1 inches

Power Connections

The OctoBrite Defilippi contains an internal 5V regulator that supplies operating current for the TLC5947 IC. External power should be 5.5 to 30V, input on the GND and V+ terminals either on the data connectors or the solder pads. External power is fed directly to the + marked pins on the LED output connectors, so the power supply should have a voltage no more than 3 volts higher than the LED forward voltages. The BYPASS jumper can be used to connect external power from the V+ bus directly to the IC logic voltage supply. This should only be attempted when an external 5V supply will be used.

As is true of most digital electronics, if you connect power backwards or short contacts with metal objects or other modules on the chain, you WILL destroy the logic chip. Please triple-check all cables and make sure the modules are not in contact with anything conductive BEFORE applying power.

Data Connections

The data IN and OUT ports are designed to be hardware compatible with the ShiftBrite connection scheme. This means the Octobrite DEFILIPPI can be plugged into a ShiftBrite Shield or a Shifty VU Shield. However, the data protocol is different, so the software will need to be changed. All pins except DI and DO are wired in parallel. This allows multiple Octobrite DEFILIPPI to be chained together with six-pin cables to control many LEDs from the same four data pins.

Data (DI / DO)

The DI pin accepts clocked serial data input to a 288 bit shift register inside the TLC5947. Each of the 24 LED outputs uses 12 bits of the shift register to control the PWM levels individually. The DO pin outputs the overflow bit from the shift register, so that if multiple Octobrites are chained, the array can be treated as a single N x 288 bit shift register.

Latch (LI / LO)

The LI and LO pins are connected in parallel on the two headers. Pulsing the latch signal causes the current contents of the shift register to be moved into the LED PWM registers.

Enable (EI / EO)

When the Enable signal is brought high, it turns off all of the LED outputs. This can be useful for disabling the LED array without losing all of the existing data, but more importantly the PWM cycle will restart when the Enable signal is brought low again. Since the TLC5947 has an internal oscillator, pulsing the Enable signal can be useful to synchronize the PWM cycles with software and across multiple Octobrites.

Clock (CI / CO)

The Clock signal is used in conjunction with the Data signal to shift data into the Octobrite. Every time the Clock line is brought high, the current state of the DI line is sampled and shifted into the first bit on the 288 bit shift register. At the same time, the last bit of the shift register is output on the DO line.

LED Outputs

Each LED output can sink 20mA with a voltage up to 30V. This means that in order to cluster LEDs together for higher brightness, they can be placed in series. At 30V, approximately 9 LEDs could be wired in series on each output pin. At 12V, 3 or 4 LEDs could be powered from each pin. The LED output pins are configured in 8 groups of three channels each, designed to fit 2×3 0.1“ ribbon cable connectors. On each set of six pins, three LED channels and three connections to V+ power are available. LEDs should be wired with the anode connected to the + mark, and the cathode connected to the numbered LED channel. Naturally this means that if RGB LEDs will be used, they need to be common-anode, not common-cathode.

Example Code

The following Arduino code generates a scanning pattern in any color across any number of connected OctoBrites. It uses direct port access instead of the Arduino digitalWrite functions, which are significantly slower.

/* Ports and Pins
 Direct port access is much faster than digitalWrite.
 You must match the correct port and pin as shown in the table below.
 
 Arduino Pin        Port        Pin
 13 (SCK)           PORTB       5
 12 (MISO)          PORTB       4
 11 (MOSI)          PORTB       3
 10 (SS)            PORTB       2
 9                 PORTB       1
 8                 PORTB       0
 7                 PORTD       7
 6                 PORTD       6
 5                 PORTD       5
 4                 PORTD       4
 3                 PORTD       3
 2                 PORTD       2
 1 (TX)            PORTD       1
 0 (RX)            PORTD       0
 A5 (Analog)        PORTC       5
 A4 (Analog)        PORTC       4
 A3 (Analog)        PORTC       3
 A2 (Analog)        PORTC       2
 A1 (Analog)        PORTC       1
 A0 (Analog)        PORTC       0
 */

// Defines for use with Arduino functions
#define clockpin   13 // CI
#define enablepin  10 // EI
#define latchpin    9 // LI
#define datapin    11 // DI

// Defines for direct port access
#define CLKPORT PORTB
#define ENAPORT PORTB
#define LATPORT PORTB
#define DATPORT PORTB
#define CLKPIN  5
#define ENAPIN  2
#define LATPIN  1
#define DATPIN  3

// Number of OctoBrites / TLC5947 devices
#define NumOctoBrites 2

// Array storing color values
//  BLUE: LEDChannels[x][0]   Range: {0 to 4095}
// GREEN: LEDChannels[x][1]   Range: {0 to 4095}
//   RED: LEDChannels[x][2]   Range: {0 to 4095}
uint16_t LEDChannels[NumOctoBrites*8][3] = {0};

// Variables for sample function
float offset = 0;


// Set pins to outputs and initial states
void setup() {
  pinMode(datapin, OUTPUT);
  pinMode(latchpin, OUTPUT);
  pinMode(enablepin, OUTPUT);
  pinMode(clockpin, OUTPUT);
  digitalWrite(latchpin, LOW);
  digitalWrite(enablepin, LOW);
}

// Read all bits in the LEDChannels array and send them on the selected pins
void WriteLEDArray() {

  unsigned int tempOne = 0;

  for (int i = 0; i < (NumOctoBrites * 24); i++) {

    tempOne = *(&LEDChannels[0][0] + i);

    for (int j = 0; j < 12; j++) {
      if ((tempOne >> (11 - j)) & 1) {
        DATPORT |= (1 << DATPIN);
      } 
      else {
        DATPORT &= ~(1 << DATPIN);
      }
      CLKPORT |= (1 << CLKPIN);
      CLKPORT &= ~(1 << CLKPIN); 
    } 

  }
  LATPORT |= (1 << LATPIN);
  LATPORT &= ~(1 << LATPIN);
}

// Sample function to draw a scanning pattern with fading
void LEDscan(int red, int green, int blue, float degreeoffset) {

  float brightnessfactor = 0;
  
  float scanindex = (1.0 + sin(degreeoffset*3.14159/180.0)) * ((float)(NumOctoBrites * 8) / 2.0);
  
    for(int LEDindex = 0; LEDindex < (NumOctoBrites * 8); LEDindex++) {
      
      brightnessfactor = exp(0.0 - fabs(scanindex - ((float)LEDindex + 0.5)) * 1.3);
      
      LEDChannels[LEDindex][0] = blue * brightnessfactor;
      LEDChannels[LEDindex][1] = green * brightnessfactor;  
      LEDChannels[LEDindex][2] = red * brightnessfactor;  
    }
    
    WriteLEDArray();  

}

void loop() {

  // Scan across whole array with fading, in red, green, and blue
  
  for (offset = 0; offset < 360; offset += 0.5) {
    LEDscan(4095, 0, 0, offset);
    delay(2);
  }

  for (offset = 0; offset < 360; offset += 0.5) {
    LEDscan(0, 4095, 0, offset);
    delay(2);
  }
  for (offset = 0; offset < 360; offset += 0.5) {
    LEDscan(0, 0, 4095, offset);
    delay(2);
  }

}