Show Posts
Pages: [1]
1  Products / Arduino Due / Re: LPD8806 + SPI + Due on: January 08, 2013, 01:17:47 pm
I would recommend using the Adafruit library as a starting point.  Nothing wrong with looking at proven code when building your own (IMO).
I am/have.  The Due is slightly different and I need to spend some more time with the datasheet comparing. I'm seeing this code pop up in the library and in a few examples online but I didn't see it in the Due datasheet at first glance so maybe these registers have changed:
Code:
while(!(SPSR & (1<<SPIF)));
Or maybe not. Need to spend more time with it.


BTW, if you're against using prebuilt libraries, then you aren't using the Arduino platform, right? smiley-wink
LoL who said I'm against libraries? It's a simple difference of me sending 3 bytes to a library and having it magically work, OR me taking the time to learn to set up the cool new extended SPI abilities on the awesome Due myself and having that skill. Almost there.

Thank you
2  Products / Arduino Due / LPD8806 + SPI + Due on: January 06, 2013, 09:32:53 pm
I'm trying to take the  Renard protocol output of Vixen Lights 3.0 into my Arduino Due and spit it out over SPI to the LPD8806 RGB strip (sold at adafruit).  The renard protocol is very simple, it will output 2 control bytes (which are ignored for now in the code) and then 3 bytes for each RGB pixel on the strip. So for 20 pixels that is 60 bytes + 2 bytes for a total of 62 bytes.  All I do is take the 60 bytes of color information and send it out via spi with 3 latch bytes.  The code below works fine for 20 pixels. Not a problem.  Once I try anything above that (24 pixels) the spi output stops cold and I see nothing on the strip.  This is where I've wasted hours and need a little advice.

I'm using 2 pins on the Arduino Due:
MOSI - 109
SCK - 110


Code:
//****************************************************************
//  Name    : LPD8806 RGB Awesomeness                           //
//  Author  : Matthew Strange                                   //
//  Version : 1.0                                               //
//  Notes   : Arduino Due Sketch                                //
//          : Renard Protocol                                   //
//          : LPD8806 RGB Strip                                 //
//          : Vixen 3.0.3                                       //
//****************************************************************

#include "SPI.h"

byte incomingByte[481]; //Channels + 1 - zero indexed

//number of pixels/LEDs in strip you will use
int pix = 24;

int pixCount = pix * 3;
int one = 0;
int fun = pixCount + 1;
//int ss=109;

// Clock Pin
//int clockPin = 110;
// Data Pin
//int dataPin = 109;

void setup()
{
//pinMode(ss, OUTPUT); // we use this for 109 pin 
SPI.begin(109);
SPI.setBitOrder(109, MSBFIRST);
SPI.setDataMode(109, SPI_MODE0);
SPI.setClockDivider(109, 21);
 
Serial.begin(115200);
}

void loop(){
  //Run once to clear the strip
  if (one == 0){
     SPI.transfer(109, 0x00, SPI_CONTINUE);
     SPI.transfer(109, 0x00, SPI_CONTINUE);
     SPI.transfer(109, 0x00);
     one = 5; 
  }
  //Place incoming bytes into the array
  if (Serial.available() >= (pixCount + 2)) { // Channels + 2
      for (int i=0; i < (pixCount + 3); i++) { // Channels + 3
        incomingByte[i] = ((Serial.read()/2) + 128);
      }

     
  }
      // Skip the first 2 bytes on Renard protocol and output to RGB strip
      for (int i=2; i < (pixCount + 3); i++) { //Channels + 3
        //shiftOut(dataPin, clockPin, MSBFIRST, incomingByte[i]);     
        SPI.transfer(109, incomingByte[i], SPI_CONTINUE);
       
      }
     // Latch the output
      SPI.transfer(109, 0x00, SPI_CONTINUE);
      SPI.transfer(109, 0x00, SPI_CONTINUE);
      SPI.transfer(109, 0x00);
      //delayMicroseconds(150);
      //delay(25);


}


Yes I'm aware Adafruit has a library but I'm a DIY geek/junkie and I want to learn this myself, not cheat. Thank you in advance
3  Forum 2005-2010 (read only) / Interfacing / Re: Vixen+Arduino mega on: October 15, 2010, 01:13:50 am
I have vixen lights controlling 5 LEDs (PWM) on my Arduino. If that helps you can read about it here.
4  Forum 2005-2010 (read only) / Interfacing / Re: Vixen+Arduino mega on: October 15, 2010, 01:13:30 am
Interesting!
Pages: [1]