User Tools

Site Tools


octobrite

This is an old revision of the document!


Introduction

octobrite_med.jpg The OctoBrite CYANEA is a full-color LED bar with eight individually-controlled 6000mcd RGB LEDs, spaced 1/2“ apart. The heart of the Octobrite is the Texas Instruments TLC5947 24-channel 12 bit PWM controller and current sink driver. Using a very simple shift register interface, each of the red, green, and blue LEDs can be controlled to 4096 levels of brightness. The OctoBrite is suitable for straight-line full color displays such as bar graphs, multiple status indicators, and decorative lighting.

Features

Controller: Texas Instruments TLC5947
LED Brightness: 6000mcd per color
LED Viewing Angle: 120 Degrees
Current: 500mA maximum (all channels on)
Power Supply: Logic: 5V; LED: 3.3-4.0V
PCB Size: 4.0 x 0.5 inches
Pin Spacing: 0.1 inches

Power Connections

The 5V pad is the logic power supply for the TLC5947 LED controller. Maximum voltage is 5.5. The VLED pads connect to the common anode terminals of the RGB LEDs. The GND pads should be connected to the ground of the LED power supply and the 5V logic power supply. The VLED power supply should be selected to keep the voltage drop across the TLC5947 within a volt or two above the LED drop voltage. The ideal supply voltage would typically be between 3.3V and 4.5V. The OctoBrite can in fact handle higher voltages, such as 5V, but the issue becomes one of heat dissipation. The OctoBrite controller will have to expend more energy as heat than is used to light the LEDs. All LEDs on full power (PWM 4095) at 5V will quickly cause the TLC5947 to become too hot to touch. Reducing the PWM settings or changing the number of LEDs active will reduce the heating. Another possibility is to mount the OctoBrite with the TLC5947 in contact with a heat sink.

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.

SI (Serial In)

The SI pin receives serial data from the microcontroller. Each time the CL pin pulses, the current logic level of the SI pin will be added to the LSB (least significant bit) of the OctoBrite internal shift register. Each LED PWM register requires 12 bits of data, each OctoBrite requires 288 total bits, shifted in MSB (most significant bit) first.

CL (Clock)

The CL pin latches the state of the SI pin into the LSB of the shift register. The maximum clock rate is 30 MHz for a single device, and 15 MHz for cascaded devices. The CL pin is not buffered and passed through the device, all OctoBrites must be wired to the same clock source.

BL (Blank)

The BL pin turns off all of the LED control channels on the OctoBrite. It also resets the PWM counter, meaning that the BL pin can be used to synchronize the PWM cycles of several OctoBrites (useful in cases where multiple OctoBrites will be updated at high rates). The BL pin is also passed through the TLC5947, each OctoBrite must be wired to the same BL control signal.

XL (Latch)

The XL pin latches the current shift register data into the PWM counter registers. After shifting 288 bits per OctoBrite, pulse the XL pin to actually display the desired colors. The XL pins of all OctoBrites should be wired to the same control signal.

SO (Serial Out)

The SO pin is the output of the TLC5947 shift register. When the CL pin is pulsed, the MSB of the 288 bit register is written to the SO pin. Attach the SO pin to the SI pin of the next OctoBrite. This will allow a chain of OctoBrites to appear as a shift register with 288 bits times the number of OctoBrites.

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 // CL
#define enablepin  10 // BL
#define latchpin    9 // XL
#define datapin    11 // SI

// 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);
  }

}

/home/macetec/public_html/docs/data/attic/octobrite.1287730003.txt.gz · Last modified: 2010/10/22 02:46 by macegr