Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 12 of 12

Thread: Teensy 2 + Adafruit WS2801 Led Strip bullet + FastSPI example = LED OFF

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Location
    France
    Posts
    8

    Teensy 2 + Adafruit WS2801 Led Strip bullet + FastSPI example = LED OFF

    Hi,
    My name is Romain, i'm not a programmer, only tester for MediaPortal Team. (HTPC project)
    an French Dealer ( MediaHD.fr) has lent me Adalight Ambilight "Teensy 2 + WS2801 Led 12mmBullet (+5V)" for test with MediaPortal, but Adalight is not supported by AtmoWin (work with Atmolight plugin made for MP)

    i would try to use Atmoduino https://bitbucket.org/RickDB/atmoduino/overview on Teensy 2, made by an user of MediaPortal.

    I have tested to flash Atmoduino on Teensy 2, with Teensyduino 1.11 (Arduino IDE 1.03) without problem for Vreify - Compil - Flash eeprom, only one issue is when Teensy reboot, Windows detect Teensy as "Unknow device", i must unplug -> plug many times, for detect it as "Abstract ... COMX"

    After Many test, with Atmoduino, i have tried FastSPI example, for test if LED works with it !
    and i can't turn LED ON, with "Testled" example, maybe i don't know how configure it !
    and i have the same issue as AtmoDuino Flashing about "unknown device " in Windows when Teensy reboot.

    i have posted an Issue on FastSPI Google code http://code.google.com/p/fastspi/issues/detail?id=26
    and send email to M. Garcia, maybe Adafruit WS2801 is not supported or Teensy . ... i don't know

    Please, Help Me ! i'm limited with programming and english

    Led Stip is connected to
    Data PIN : B2
    Clock PIN : B1
    Ground : Common GND
    (+5V) directly on LED

    StandTest working From Adafruit WS2801 library https://github.com/adafruit/Adafruit-WS2801-Library.

    [SPOILER]
    Code:
    #include "SPI.h"
    #include "Adafruit_WS2801.h"
    
    /*****************************************************************************
    Example sketch for driving Adafruit WS2801 pixels!
    
    
    Designed specifically to work with the Adafruit RGB Pixels!
    12mm Bullet shape ----> https://www.adafruit.com/products/322
    12mm Flat shape ----> https://www.adafruit.com/products/738
    36mm Square shape ----> https://www.adafruit.com/products/683
    
    These pixels use SPI to transmit the color data, and have built in
    high speed PWM drivers for 24 bit color per pixel
    2 pins are required to interface
    
    Adafruit invests time and resources providing this open source code,
    please support Adafruit and open-source hardware by purchasing
    products from Adafruit!
    
    Written by Limor Fried/Ladyada for Adafruit Industries.
    BSD license, all text above must be included in any redistribution
    
    *****************************************************************************/
    
    /********************************************
    MODIFICATION Romain :
    Data PIN TEENSY : 2
    Clocl PIN TEENSY : 1
    
    ***********************************************/
    
    // Choose which 2 pins you will use for output.
    // Can be any valid output pins.
    // The colors of the wires may be totally different so
    // BE SURE TO CHECK YOUR PIXELS TO SEE WHICH WIRES TO USE!
    int dataPin = 2; // Yellow wire on Adafruit Pixels
    int clockPin = 1; // Green wire on Adafruit Pixels
    int NumLED = 50; // Number of LED
    
    // Don't forget to connect the ground wire to Arduino ground,
    // and the +5V wire to a +5V supply
    
    // Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a row
    //Adafruit_WS2801 strip = Adafruit_WS2801(25, dataPin, clockPin);
    Adafruit_WS2801 strip = Adafruit_WS2801(NumLED, dataPin, clockPin);
    
    // Optional: leave off pin numbers to use hardware SPI
    // (pinout is then specific to each board and can't be changed)
    //Adafruit_WS2801 strip = Adafruit_WS2801(25);
    //Adafruit_WS2801 strip = Adafruit_WS2801(NumLED);
    
    // For 36mm LED pixels: these pixels internally represent color in a
    // different format. Either of the above constructors can accept an
    // optional extra parameter: WS2801_RGB is 'conventional' RGB order
    // WS2801_GRB is the GRB order required by the 36mm pixels. Other
    // than this parameter, your code does not need to do anything different;
    // the library will handle the format change. Examples:
    //Adafruit_WS2801 strip = Adafruit_WS2801(25, dataPin, clockPin, WS2801_GRB);
    //Adafruit_WS2801 strip = Adafruit_WS2801(25, WS2801_GRB);
    
    void setup() {
    
    strip.begin();
    
    // Update LED contents, to start they are all 'off'
    strip.show();
    }
    
    
    void loop() {
    // Some example procedures showing how to display to the pixels
    
    colorWipe(Color(255, 0, 0), 50);
    colorWipe(Color(0, 255, 0), 50);
    colorWipe(Color(0, 0, 255), 50);
    rainbow(20);
    rainbowCycle(20);
    }
    
    void rainbow(uint8_t wait) {
    int i, j;
    
    for (j=0; j < 256; j++) { // 3 cycles of all 256 colors in the wheel
    for (i=0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, Wheel( (i + j) % 255));
    }
    strip.show(); // write all the pixels out
    delay(wait);
    }
    }
    
    // Slightly different, this one makes the rainbow wheel equally distributed
    // along the chain
    void rainbowCycle(uint8_t wait) {
    int i, j;
    
    for (j=0; j < 256 * 5; j++) { // 5 cycles of all 25 colors in the wheel
    for (i=0; i < strip.numPixels(); i++) {
    // tricky math! we use each pixel as a fraction of the full 96-color wheel
    // (thats the i / strip.numPixels() part)
    // Then add in j which makes the colors go around per pixel
    // the % 96 is to make the wheel cycle around
    strip.setPixelColor(i, Wheel( ((i * 256 / strip.numPixels()) + j) % 256) );
    }
    strip.show(); // write all the pixels out
    delay(wait);
    }
    }
    
    // fill the dots one after the other with said color
    // good for testing purposes
    void colorWipe(uint32_t c, uint8_t wait) {
    int i;
    
    for (i=0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
    }
    }
    
    /* Helper functions */
    
    // Create a 24 bit color value from R,G,B
    uint32_t Color(byte r, byte g, byte b)
    {
    uint32_t c;
    c = r;
    c <<= 8;
    c |= g;
    c <<= 8;
    c |= b;
    return c;
    }
    
    //Input a value 0 to 255 to get a color value.
    //The colours are a transition r - g -b - back to r
    uint32_t Wheel(byte WheelPos)
    {
    if (WheelPos < 85) {
    return Color(WheelPos * 3, 255 - WheelPos * 3, 0);
    } else if (WheelPos < 170) {
    WheelPos -= 85;
    return Color(255 - WheelPos * 3, 0, WheelPos * 3);
    } else {
    WheelPos -= 170;
    return Color(0, WheelPos * 3, 255 - WheelPos * 3);
    }
    }
    [/SPOILER]
    Last edited by Azzuro; 01-14-2013 at 05:04 PM.

  2. #2
    Junior Member
    Join Date
    Jan 2013
    Location
    France
    Posts
    8
    @dgarcia42 : FastSpi creator ? if is you, can you help me ?

  3. #3
    Senior Member
    Join Date
    Jan 2013
    Posts
    124
    For the 5v ws2801 try changing the data rate value to something slower, e.g. 2, 3, or 4. There may still be slight problems with the teensy 2.0 - i haven't had a chance to spend any time with those devices yet.

  4. #4
    Junior Member
    Join Date
    Jan 2013
    Location
    France
    Posts
    8
    Hi dgarcia42 ...
    After long nights of search, and many days ...
    it's working !
    the bad key is Teensy PIN defined : DATA_PIN CLOCK_PIN
    the data rate mini is "2" ("1" made problem with color).
    i post later, Fastlib library for teensy 2 !
    Thx you for the reply !

  5. #5
    Junior Member
    Join Date
    Jan 2013
    Location
    France
    Posts
    8
    Hi,

    testedLEd.ino
    Code:
    // 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 { unsigned char r; unsigned char b; unsigned char g; }; adafruit WS2801
    struct CRGB *leds;

    FastSPI_LED.cpp
    Code:
    // Leonardo, teensy, blinkm 
    #elif defined(__AVR_ATmega32U4__)
    
    #define SPI_PORT PORTB
    #define SPI_DDR  DDRB
    #define SPI_PIN  PINB
    #define SPI_MOSI 2       // Arduino pin 10.
    #define SPI_MISO 3       // Arduino pin 11.
    #define SPI_SCK  1       // Arduino pin 9.
    #define SPI_SSN  0       // Arduino pin 8.
    	// Replace  Teensy 2 PB2 = 2 , ... , ...
    #define DATA_PIN 2      // PB2, pin 10, Digital16
    #define SLAVE_PIN 3     // PB3, pin 11, Digital14
    #define CLOCK_PIN 1     // PB1, pin 9, Digital15
    #define LATCH_PIN 0     // PB0, pin 8, Digital17
    #define TIMER_AVAILABLE 1
    Attached Files Attached Files

  6. #6
    Junior Member
    Join Date
    Jan 2013
    Location
    France
    Posts
    8
    Hi, @dgarcia42
    i try to do working FastSPi_LED2 - RC2 with same device as above.

    i think pin connection is breaked. i can't send more info for now, but working on 1st FastSpi with my change.

    Also, my goal is to use it as Ambilight system look here : https://code.google.com/p/ambilight-4-mediaportal/
    Atmoduino code :
    https://code.google.com/p/ambilight-...ino%20Firmware

  7. #7
    Senior Member
    Join Date
    Jan 2013
    Posts
    124
    What pins do you have the hardware hooked up to - and is this the teensy 2 or the teensy++ 2?

  8. #8
    Junior Member
    Join Date
    Jan 2013
    Location
    France
    Posts
    8
    Thanks for your reply, it's TEENSY 2 (not 2++)

    LED PicPin -> TeensyBoard{BoardPin} (AtmelPin)
    Clock input (Ci) -> B1{1} (9)
    Data input (Di) -> B2{2} (10)
    Ground -> GRD
    5V leds Strip

    when i use
    - LEDS.addLeds<WS2801>(leds, NUM_LEDS); -> Nothing work
    - LEDS.addLeds<WS2801, 11, 13, BGR, DATA_RATE_MHZ(1)>(leds, NUM_LEDS); -> only LED on Teensy Board has activity

    if i understand the lines :
    - LEDS.addLeds<WS2801, DATA PIN , CLOCK PIN , RBG ORDER , DATA_RATE_MHZ(1)>(leds, NUM_LEDS);

    So for Teensy 2
    - LEDS.addLeds<WS2801, 2 ,1 , BRG , DATA_RATE_MHZ(1)>(leds, NUM_LEDS); -> don't working

    but when i invert CLock and Data ( i don't remember good) i have activity only the 1st LED, nothing else, and activity is strange
    * LEDS.addLeds<WS2801, 1 ,2 , BRG , DATA_RATE_MHZ(1)>(leds, NUM_LEDS)

    RGB order can have impact ? We can have RGB order, without Datarate in line setting ?

  9. #9
    Senior Member
    Join Date
    Jan 2013
    Posts
    124
    For your second line, the reason why "only LED on teensy board has activity" is because pin 13 is also the pin that the teensy's led is on.

    The teensy 2's hardware SPI should be on pins 2 (data) and 1 (clock) - though because I do bit banging any pair of pins should, in theory, work - as long as the pin you declare as data is hooked up to data-input on your strip, and clock is hooked up to clock-input.

    You can have RGB order without data rate - but not the other way around (a quirk in how template resolution is done in C++) - RGB order is mostly for chipsets that get their color data in an order other than R then G then B (red, then green, then blue).

    I'm not entirely sure why it isn't working for you - and I don't have a teensy 2 board handy that I can test with. I can look around tomorrow to see whether or not I have one around here and if not, order a new one to test with. However, I won't have it for a few days in that case.

  10. #10
    Junior Member
    Join Date
    Jan 2013
    Location
    France
    Posts
    8
    I can test for you, all your changei know, it's not the best and many time are lost with transfert.
    i'm not sure, but i think SPI for Teensy2 is broken, working fine with last FastSPi ( with small change from me) ( maybe related to leonardo changes).
    Ask me for test everything, for now i test only with your example ( for to be sure)

  11. #11
    Senior Member
    Join Date
    Jan 2013
    Posts
    124
    Trying to test/debug via message board posts/email isn't something I really have time to juggle doing - it'll be quicker/easier/more efficient for me to just test it locally with my own hardware once I find and/or order it.

  12. #12
    Junior Member
    Join Date
    Jan 2013
    Location
    France
    Posts
    8
    So,
    Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •