APA102/SK9822 LED Strips in Parallel?

Status
Not open for further replies.

NewLinuxFan

Well-known member
I'm wondering how many LED strips can be in parallel with the output of a Teensy prop shield LC. The level shifters are so tiny, they are hard to read. I think it says "BEG" or "8FQ" on them. Searching isn't bringing up anything. For this application I can lower the clockspeed to about 500 kHz, so I could add series resistors. Testing would reveal what works but not whether the level shifters are getting too warm internally for longevity. A datasheet would be great, if anybody knows.

That's the end of my question. Thought I'd share some general SPI code for APA102 and clones:
Code:
#include <SPI.h>
#define NUM_LEDS 60
byte current_5bits[NUM_LEDS];
byte RGB_PWM[NUM_LEDS][3];
int extra_zero_bytes = (NUM_LEDS / 2 + 1) / 8 + 1; // Based on Tim's blog discussion of SK9822 chip.

void setup()
{
  Serial.begin(9600);
  pinMode(7, OUTPUT);
  digitalWrite(7, HIGH);  // enable access to LEDs
  SPI.begin();
  delay(1000);
  sendSPI();
  delay(1000);
}

void loop() {
  // Type an LED number into Serial Monitor and hit enter.
  while (Serial.available() > 0) 
  {
    for (int i = 0; i < NUM_LEDS; i++)
    {
      updateLEDvalues(i, 1, 0, 0, 0);
    }

    int LEDindex = Serial.parseInt();

    if (Serial.read() == '\n')
    {
      updateLEDvalues(LEDindex, 1, 255, 0, 0); // That LED number lights up red with lowest current setting, making it easy to find.
      sendSPI();
    }
  }
}

void updateLEDvalues(int light_num, byte LED_current, byte red_PWM, byte green_PWM, byte blue_PWM)
{
  current_5bits[light_num] = LED_current; // 0 to 31. Only the least significant 5 bits are used.
  RGB_PWM[light_num][0] = red_PWM;
  RGB_PWM[light_num][1] = green_PWM;
  RGB_PWM[light_num][2] = blue_PWM;
}

void sendSPI(void) 
{
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0)); // Adjust clock speed according to data needs or wire lengths.
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  for (int i = 0; i < NUM_LEDS; i++)
  {
    SPI.transfer(B11100000 | current_5bits[i]);
    SPI.transfer(RGB_PWM[i][2]); // adjust order according to manufacturer and year
    SPI.transfer(RGB_PWM[i][1]); // adjust order according to manufacturer and year
    SPI.transfer(RGB_PWM[i][0]); // adjust order according to manufacturer and year
  }
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  SPI.transfer(0x00);
  for (int i = 0; i < extra_zero_bytes; i++)
  {
    SPI.transfer(0x00);
  }
  SPI.endTransaction();
}

Advantages over the FastLED library:
- Clock speed can be lowered which allows longer wires in noisy environments.
- Adjusting global brightness in the chips looks and films way better than the temporal dithering of FastLED library.
- Easier to use the other SPI or both SPI's in Teensy 3.5 and 3.6.

Also, I found a good source for SK9822:
http://www.atqueen.com/product/apa102-led-strip-dual-signal-transmission-line-control/
Only ~$8/meter for 60 LED's/meter. ~$30 shipping (for 7m) to ~$60 shipping (for 70m), arrives in about a week.
 
Status
Not open for further replies.
Back
Top