Fastspi_LED not working correctly for me - now fixed

Having a problem getting Fastspi_LED running and am looking for suggestions.

I downloaded and got the Sparkfun WS2801 code running on my strip of 32 WS2801 LED’s on an Arduino UNO in a 1.0.1 environment. This code uses Pin 3 for the clock and Pin 2 for the data and works like a charm.

I have been unable to get the Fastspi_LED code running though. Only a single LED lights up. My understanding is that pin 13 is for the clock and pin 11 is for the data.

For power, I have a 9V 1A power supply connected to the Arduino with a .1uF decoupling capacitor between Vin and GND.

Here’s the strip I’m using:

Here’s the start of the Fastspi_LED code I’m using:

#include <FastSPI_LED.h>

#define NUM_LEDS 32

// Sometimes chipsets wire in a backwards sort of way
struct CRGB { unsigned char b; unsigned char r; unsigned char g; };
// struct CRGB { unsigned char r; unsigned char g; unsigned char b; };
struct CRGB *leds;

#define PIN 4

void setup()
{
  FastSPI_LED.setLeds(NUM_LEDS);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_TM1809);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_LPD6803);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_HL1606);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_595);
  FastSPI_LED.setChipset(CFastSPI_LED::SPI_WS2801);

  FastSPI_LED.setPin(PIN);
  
  FastSPI_LED.setDataRate(2);
  
  FastSPI_LED.init();
  FastSPI_LED.start();

Have tried a few combinations of pins, setDataRate values, commenting out the .setLed’s or .setPin line and so on to no avail.

Considering that I can get the Sparkfun code moving pretty fast - under 15ms/sequence of 32 LED’s, I’m wondering what the advantage of this library is?

Update: I even tried the patch at http://code.google.com/p/fastspi/issues/detail?id=12 as well as http://code.google.com/p/fastspi/issues/detail?id=4 and again, it’s still not working.

No suggestions on fastspi eh?

In the meantime, I've worked out some code for the Sparkfun version which allows me to define multiple sequence types in an array and then cycle through those sequences, each with different effects and variables for colours, delays and number of LED's affected. A work in progress for sure, but it's moving along quite nicely so far.

How long do you have between SPI transfers? The WS2801 waits for some period of inactivity before updating its output. I haven’t looked at the datasheet recently, I want to say 100 or 500uS.
You only posted part or your code, hard to say if that’s the issue.

In the case of FastSPI, I adapted his stock example for a 2801, and his library handled that timing for you.

With the Sparkfun code, the transfer routine uses 500uS between SPI transfers. I also have other delays for lighting effects.

The code for the FastSPI example is:

#include <FastSPI_LED.h>

#define NUM_LEDS 32

// Sometimes chipsets wire in a backwards sort of way
struct CRGB { unsigned char b; unsigned char r; unsigned char g; };
// struct CRGB { unsigned char r; unsigned char g; unsigned char b; };
struct CRGB *leds;

#define PIN 4

void setup()
{
  FastSPI_LED.setLeds(NUM_LEDS);
//  FastSPI_LED.setChipset(CFastSPI_LED::SPI_TM1809);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_LPD6803);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_HL1606);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_595);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_WS2801);

  FastSPI_LED.setPin(PIN);

  FastSPI_LED.setDataRate(2);
  
  FastSPI_LED.init();
  FastSPI_LED.start();

  leds = (struct CRGB*)FastSPI_LED.getRGBData(); 
}

void loop() { 
  // one at a time
  for(int j = 0; j < 3; j++) { 
    for(int i = 0 ; i < NUM_LEDS; i++ ) {
      memset(leds, 0, NUM_LEDS * 3);
      switch(j) { 
        case 0: leds[i].r = 255; break;
        case 1: leds[i].g = 255; break;
        case 2: leds[i].b = 255; break;
      }
      FastSPI_LED.show();
      delay(10);
    }
  }

  // growing/receeding bars
  for(int j = 0; j < 3; j++) { 
    memset(leds, 0, NUM_LEDS * 3);
    for(int i = 0 ; i < NUM_LEDS; i++ ) {
      switch(j) { 
        case 0: leds[i].r = 255; break;
        case 1: leds[i].g = 255; break;
        case 2: leds[i].b = 255; break;
      }
      FastSPI_LED.show();
      delay(10);
    }
    for(int i = NUM_LEDS-1 ; i >= 0; i-- ) {
      switch(j) { 
        case 0: leds[i].r = 0; break;
        case 1: leds[i].g = 0; break;
        case 2: leds[i].b = 0; break;
      }
      FastSPI_LED.show();
      delay(1);
    }
  }
  
  // Fade in/fade out
  for(int j = 0; j < 3; j++ ) { 
    memset(leds, 0, NUM_LEDS * 3);
    for(int k = 0; k < 256; k++) { 
      for(int i = 0; i < NUM_LEDS; i++ ) {
        switch(j) { 
          case 0: leds[i].r = k; break;
          case 1: leds[i].g = k; break;
          case 2: leds[i].b = k; break;
        }
      }
      FastSPI_LED.show();
      delay(3);
    }
    for(int k = 255; k >= 0; k--) { 
      for(int i = 0; i < NUM_LEDS; i++ ) {
        switch(j) { 
          case 0: leds[i].r = k; break;
          case 1: leds[i].g = k; break;
          case 2: leds[i].b = k; break;
        }
      }
      FastSPI_LED.show();
      delay(3);
    }
  }
}

I haven't been able to get FastSPI_LED to work under 1.0.1, but the same exact code works fine under 0023 ... This is why half of my projects are still only coded under 0023 ...

Take a look here:
http://code.google.com/p/fastspi/issues/detail?id=12

They've updated and released a new zip.

FWIW I'm the one with the initial bug report on this one, and the patch didn't work as an SVN patch, but I was able to modify the referenced line of code, and adding the SPI_A(0); on line 422 worked.

brucethehoon:
Take a look here:
Google Code Archive - Long-term storage for Google Code Project Hosting.

They've updated and released a new zip.

FWIW I'm the one with the initial bug report on this one, and the patch didn't work as an SVN patch, but I was able to modify the referenced line of code, and adding the SPI_A(0); on line 422 worked.

Tried manually adding SPI_A(0) myself, but it didn't work. I probably screwed up somewhere; maybe didn't delete the .swp files or something. . .

Anyways, I just saw the updated code today and re-installed it all from scratch. FastSPI now works like a charm on the WS2801's and is much faster than the bit blasted code. Guess I've got some retrofitting to do. Looks real smooth too.

Bit blasted version looked like this yesterday (and I've added more sequences since):