User Tools

Site Tools


octobrite

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
octobrite [2009/07/27 05:28]
macegr
octobrite [2010/10/22 06:46]
macegr
Line 7: Line 7:
  
 {{octobrite_both_sm.png?nolink  }} {{octobrite_both_sm.png?nolink  }}
-^  Controller: | Texas Instruments TCL5947  |+^  Controller: | Texas Instruments TLC5947  |
 ^  LED Brightness: | 6000mcd per color  | ^  LED Brightness: | 6000mcd per color  |
 ^  LED Viewing Angle: | 120 Degrees  | ^  LED Viewing Angle: | 120 Degrees  |
Line 17: Line 17:
 ====== Power Connections ====== ====== Power Connections ======
 {{octobrite_closeup.png?nolink  }} {{octobrite_closeup.png?nolink  }}
-The 5V pad is the logic power supply for the [[http://focus.ti.com/lit/ds/symlink/tlc5947.pdf|TLC5947 LED controller]]. Maximum voltage is 5.5. The VLED pads connect to the common anode terminals of the RGB LEDs. The 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.+The 5V pad is the logic power supply for the [[http://focus.ti.com/lit/ds/symlink/tlc5947.pdf|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) ====== ====== SI (Serial In) ======
Line 33: Line 35:
 ====== SO (Serial Out) ====== ====== 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. 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.
 +
 +<html><pre><span style="color: #777755;">/* Ports and Pins</span>
 +<span style="color: #777755;"> Direct port access is much faster than digitalWrite.</span>
 +<span style="color: #777755;"> You must match the correct port and pin as shown in the table below.</span>
 +<span style="color: #777755;"> </span>
 +<span style="color: #777755;"> Arduino Pin        Port        Pin</span>
 +<span style="color: #777755;"> 13 (SCK)           PORTB       5</span>
 +<span style="color: #777755;"> 12 (MISO)          PORTB       4</span>
 +<span style="color: #777755;"> 11 (MOSI)          PORTB       3</span>
 +<span style="color: #777755;"> 10 (SS)            PORTB       2</span>
 +<span style="color: #777755;"> 9                 PORTB       1</span>
 +<span style="color: #777755;"> 8                 PORTB       0</span>
 +<span style="color: #777755;"> 7                 PORTD       7</span>
 +<span style="color: #777755;"> 6                 PORTD       6</span>
 +<span style="color: #777755;"> 5                 PORTD       5</span>
 +<span style="color: #777755;"> 4                 PORTD       4</span>
 +<span style="color: #777755;"> 3                 PORTD       3</span>
 +<span style="color: #777755;"> 2                 PORTD       2</span>
 +<span style="color: #777755;"> 1 (TX)            PORTD       1</span>
 +<span style="color: #777755;"> 0 (RX)            PORTD       0</span>
 +<span style="color: #777755;"> A5 (Analog)        PORTC       5</span>
 +<span style="color: #777755;"> A4 (Analog)        PORTC       4</span>
 +<span style="color: #777755;"> A3 (Analog)        PORTC       3</span>
 +<span style="color: #777755;"> A2 (Analog)        PORTC       2</span>
 +<span style="color: #777755;"> A1 (Analog)        PORTC       1</span>
 +<span style="color: #777755;"> A0 (Analog)        PORTC       0</span>
 +<span style="color: #777755;"> */</span>
 +
 +<span style="color: #777755;">// Defines for use with Arduino functions</span>
 +#define clockpin   13 <span style="color: #777755;">// CL</span>
 +#define enablepin  10 <span style="color: #777755;">// BL</span>
 +#define latchpin    9 <span style="color: #777755;">// XL</span>
 +#define datapin    11 <span style="color: #777755;">// SI</span>
 +
 +<span style="color: #777755;">// Defines for direct port access</span>
 +#define CLKPORT PORTB
 +#define ENAPORT PORTB
 +#define LATPORT PORTB
 +#define DATPORT PORTB
 +#define CLKPIN  5
 +#define ENAPIN  2
 +#define LATPIN  1
 +#define DATPIN  3
 +
 +<span style="color: #777755;">// Number of OctoBrites / TLC5947 devices</span>
 +#define NumOctoBrites 2
 +
 +<span style="color: #777755;">// Array storing color values</span>
 +<span style="color: #777755;">//  BLUE: LEDChannels[x][0]   Range: {0 to 4095}</span>
 +<span style="color: #777755;">// GREEN: LEDChannels[x][1]   Range: {0 to 4095}</span>
 +<span style="color: #777755;">//   RED: LEDChannels[x][2]   Range: {0 to 4095}</span>
 +uint16_t LEDChannels[NumOctoBrites*8][3] = {0};
 +
 +<span style="color: #777755;">// Variables for sample function</span>
 +<span style="color: #996600;">float</span> offset = 0;
 +
 +
 +<span style="color: #777755;">// Set pins to outputs and initial states</span>
 +<span style="color: #CC6600;">void</span> <span style="color: #993300;"><b>setup</b></span>() {
 +  <span style="color: #996600;">pinMode</span>(datapin, <span style="color: #CC0000;">OUTPUT</span>);
 +  <span style="color: #996600;">pinMode</span>(latchpin, <span style="color: #CC0000;">OUTPUT</span>);
 +  <span style="color: #996600;">pinMode</span>(enablepin, <span style="color: #CC0000;">OUTPUT</span>);
 +  <span style="color: #996600;">pinMode</span>(clockpin, <span style="color: #CC0000;">OUTPUT</span>);
 +  <span style="color: #996600;">digitalWrite</span>(latchpin, <span style="color: #CC0000;">LOW</span>);
 +  <span style="color: #996600;">digitalWrite</span>(enablepin, <span style="color: #CC0000;">LOW</span>);
 +}
 +
 +<span style="color: #777755;">// Read all bits in the LEDChannels array and send them on the selected pins</span>
 +<span style="color: #CC6600;">void</span> WriteLEDArray() {
 +
 +  <span style="color: #CC6600;">unsigned</span> <span style="color: #996600;">int</span> tempOne = 0;
 +
 +  <span style="color: #CC6600;">for</span> (<span style="color: #996600;">int</span> i = 0; i < (NumOctoBrites * 24); i++) {
 +
 +    tempOne = *(&LEDChannels[0][0] + i);
 +
 +    <span style="color: #CC6600;">for</span> (<span style="color: #996600;">int</span> j = 0; j < 12; j++) {
 +      <span style="color: #CC6600;">if</span> ((tempOne >> (11 - j)) & 1) {
 +        DATPORT |= (1 << DATPIN);
 +      } 
 +      <span style="color: #CC6600;">else</span> {
 +        DATPORT &= ~(1 << DATPIN);
 +      }
 +      CLKPORT |= (1 << CLKPIN);
 +      CLKPORT &= ~(1 << CLKPIN); 
 +    } 
 +
 +  }
 +  LATPORT |= (1 << LATPIN);
 +  LATPORT &= ~(1 << LATPIN);
 +}
 +
 +<span style="color: #777755;">// Sample function to draw a scanning pattern with fading</span>
 +<span style="color: #CC6600;">void</span> LEDscan(<span style="color: #996600;">int</span> red, <span style="color: #996600;">int</span> green, <span style="color: #996600;">int</span> blue, <span style="color: #996600;">float</span> degreeoffset) {
 +
 +  <span style="color: #996600;">float</span> brightnessfactor = 0;
 +  
 +  <span style="color: #996600;">float</span> scanindex = (1.0 + <span style="color: #996600;">sin</span>(degreeoffset*3.14159/180.0)) * ((<span style="color: #996600;">float</span>)(NumOctoBrites * 8) / 2.0);
 +  
 +    <span style="color: #CC6600;">for</span>(<span style="color: #996600;">int</span> LEDindex = 0; LEDindex < (NumOctoBrites * 8); LEDindex++) {
 +      
 +      brightnessfactor = <span style="color: #996600;">exp</span>(0.0 - fabs(scanindex - ((<span style="color: #996600;">float</span>)LEDindex + 0.5)) * 1.3);
 +      
 +      LEDChannels[LEDindex][0] = blue * brightnessfactor;
 +      LEDChannels[LEDindex][1] = green * brightnessfactor;  
 +      LEDChannels[LEDindex][2] = red * brightnessfactor;  
 +    }
 +    
 +    WriteLEDArray();  
 +
 +}
 +
 +<span style="color: #CC6600;">void</span> <span style="color: #993300;"><b>loop</b></span>() {
 +
 +  <span style="color: #777755;">// Scan across whole array with fading, in red, green, and blue</span>
 +  
 +  <span style="color: #CC6600;">for</span> (offset = 0; offset < 360; offset += 0.5) {
 +    LEDscan(4095, 0, 0, offset);
 +    <span style="color: #996600;">delay</span>(2);
 +  }
 +
 +  <span style="color: #CC6600;">for</span> (offset = 0; offset < 360; offset += 0.5) {
 +    LEDscan(0, 4095, 0, offset);
 +    <span style="color: #996600;">delay</span>(2);
 +  }
 +  <span style="color: #CC6600;">for</span> (offset = 0; offset < 360; offset += 0.5) {
 +    LEDscan(0, 0, 4095, offset);
 +    <span style="color: #996600;">delay</span>(2);
 +  }
 +
 +}</pre></html>
/home/macetec/public_html/docs/data/pages/octobrite.txt · Last modified: 2015/05/22 00:50 by macegr