Author Topic: Digital rgb ledstrip driven by RFDuino  (Read 36248 times)

tolson

  • Global Moderator
  • *****
  • Posts: 827
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #45 on: October 19, 2014, 08:28:34 PM »
Can you describe your hardware setup?

Is it the first LED in the chain that works?

What voltage source are you using to supply Vcc to the LED chain?


zabowsky

  • RFduino Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #46 on: October 20, 2014, 07:29:34 PM »
Nothing special about my setup, I don't think. I've got a 16x NeoPixel Ring hooked up to pin 6 of an RFduino board; nothing else. I was initially powering the ring from the 3.3V board supply, but have now switched to using a dedicated 5V supply, with the same results.

I messed around some more and got some different results with the _tolsenMod.zip lib. With those files I can get strandtest to do what I expect it to do, looping through colors and rainbows (woo). The LEDs are quite bright in this configuration, though, and setting a value any lower than max results in all white, and doesn't actually lower the brightness.

With the _mod2.zip files I always get all bright white LEDs from strandtest.

The non-library sample sketch results in one functional LED and the rest all bright white. I can't tell for sure if the one that cycles through the colors is the first or last in the ring...it's next to the Data Out pin (which I'm not using).

tolson

  • Global Moderator
  • *****
  • Posts: 827
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #47 on: October 22, 2014, 06:45:44 PM »
Hi zabowsky,

Nothing special about my setup, I don't think. I've got a 16x NeoPixel Ring hooked up to pin 6 of an RFduino board; nothing else. I was initially powering the ring from the 3.3V board supply, but have now switched to using a dedicated 5V supply, with the same results.
 * * *
The non-library sample sketch results in one functional LED and the rest all bright white. I can't tell for sure if the one that cycles through the colors is the first or last in the ring...it's next to the Data Out pin (which I'm not using).

Do you have ground connected between the RFduino and the Ring?

The one that works would be the first one in the chain. Each LED passes the signal from its DI to it DO by re-syncing and buffering the pulses. So anything not working past the last working one is do to lost of sync.

Just verified the test sketch for Arduino 1.5.7 still works on Arduino 1.5.8.
http://forum.rfduino.com/index.php?topic=30.msg2526#msg2526

Can you describe your exact wiring configuration?
Can you post your entire sketch, so I can run it.
« Last Edit: October 22, 2014, 06:47:42 PM by tolson »

zabowsky

  • RFduino Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #48 on: October 22, 2014, 07:17:38 PM »
At the moment I've got the DataIn pin of my NeoPixel ring connect to GPIO6 of an RFduino board. The ground pin of the ring is connected to ground on the RFduino and the power connected to the 3.3V pin on the RFduino. The RFduino is being powered over USB, and nothing else is connected. I've alternately tried powering the ring with a dedicated 5V supply (old wall wart), with the same results.

Here's the sketch which produces 1x working LED and 15x bright white LEDs - the only modification to the earlier post is to set nPIXELS = 16:

Code: [Select]
// WS2812_RFduino_Test
// By Thomas Olson
// teo20140220.01
// teo20140719.01 Modified for Arduino 1.5.7
// 20141022.. verified works with Arduino 1.5.8
// No complicated Pixel Library needed.
// Tested with WS2812B 4 pin versions.

const int ws2812pin = 6;

const int nPIXELS = 16;

const int nLEDs = nPIXELS * 3;
uint8_t ledBar[nLEDs];


void setup() {

  pinMode(ws2812pin, OUTPUT);
  digitalWrite(ws2812pin, LOW);
  // Initialize the ledBar array - all LEDs OFF.
  for(int wsOut = 0; wsOut < nLEDs; wsOut++){
    ledBar[wsOut] = 0x00;
  }
  loadWS2812();
 
  delay(1);
}

void loop() {
   
 for(int wsOut = 0; wsOut < nLEDs; wsOut+=3){ // green
    ledBar[wsOut] = 0x3c;
    loadWS2812();
   
    delay(10);
   
    ledBar[wsOut] = 0x00;
    loadWS2812();
  }

 for(int wsOut = 1; wsOut < nLEDs; wsOut+=3){ // red
    ledBar[wsOut] = 0x3c;
    loadWS2812();
   
    delay(10);
   
    ledBar[wsOut] = 0x00;
    loadWS2812();
  }
 
   for(int wsOut = 2; wsOut < nLEDs; wsOut+=3){ // blue
    ledBar[wsOut] = 0x3c;
    loadWS2812();
   
    delay(10);
   
    ledBar[wsOut] = 0x00;
    loadWS2812();
  }


}

void loadWS2812(){
 
  noInterrupts();

  for(int wsOut = 0; wsOut < nLEDs; wsOut++){
    for(int x=7; x>=0; x--){
      NRF_GPIO->OUTSET = (1UL << ws2812pin);
      if(ledBar[wsOut] & (0x01 << x)) {
        __ASM ( \
              " NOP\n\t" \
              " NOP\n\t" \
              " NOP\n\t" \
              " NOP\n\t" \
              " NOP\n\t" \
              );
        NRF_GPIO->OUTCLR = (1UL << ws2812pin);
     
      }else{
        NRF_GPIO->OUTCLR = (1UL << ws2812pin);
        __ASM ( \
              " NOP\n\t" \
              " NOP\n\t" \
              " NOP\n\t" \
              );     
      }
    }
  }
  delayMicroseconds(50); // latch and reset WS2812.
  interrupts(); 
}


Thanks for the assistance!

tolson

  • Global Moderator
  • *****
  • Posts: 827
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #49 on: October 22, 2014, 07:41:59 PM »
Using your sketch for 16 pixels it works on my chain.
Which model neopixel ring do you have? Brand? Part Number?
Can you determine is it the 6pin (WS2812) or the 4pin (WS2812B) chips.

zabowsky

  • RFduino Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #50 on: October 22, 2014, 07:58:00 PM »
I'm using this guy: https://www.sparkfun.com/products/12664

It's stamped with WS2812 and there are 6 pins per LED (despite the picture on sparkfun showing 4 pins).

gcgasson

  • RFduino Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #51 on: October 27, 2014, 01:27:18 AM »
Hi Tolson,

I have the same problem between the Arduino Uno and the RFDuino. The Uno works great but I seem to have a problem with the RFDuino.

What I have noticed on my oscilloscope and maybe this could point you into the problem. I find that the first bit of every byte is out of spec (Meaning the first BIT is 920ns and the total length of the first 0 & 1 is 2.12us) but the rest is fine and in spec.

So if I send a r=0,g=0 and b=0 and this should turn the LED to OFF I get very bright white LED shinning.

Please could help to tell me where to look to try and fix this problem.

Best Regards,

Gary
« Last Edit: October 27, 2014, 01:35:26 AM by gcgasson »

tolson

  • Global Moderator
  • *****
  • Posts: 827
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #52 on: October 27, 2014, 07:28:54 AM »

What I have noticed on my oscilloscope and maybe this could point you into the problem. I find that the first bit of every byte is out of spec (Meaning the first BIT is 920ns and the total length of the first 0 & 1 is 2.12us) but the rest is fine and in spec.
Gary

Hi Gary,
Are those measurements using one of the sketches that use one of the modified libraries. Or is it for my bare minimum sketch that does not use a library. Can you provide measurements for the latter.
Tom

tolson

  • Global Moderator
  • *****
  • Posts: 827
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #53 on: October 27, 2014, 09:35:35 AM »
Hi Zaboswky and Gary,

Can you try this hex file. It works on my ring for 16 NeoPixels.

gcgasson

  • RFduino Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #54 on: October 27, 2014, 10:43:25 AM »
Hi Tolson,

I have used your Adafruit_NeoPixel_tolsonMod.zip and replaced the original. First removed original then replaced it.

I have a 24 LED Neoplix Ring and my Sketch is as follows:

Code: [Select]
#include <RFduinoBLE.h>
#include <Adafruit_NeoPixel.h>

#define PIN 5

Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, PIN, NEO_GRB + NEO_KHZ800);

void setup() {

  // this is the data we want to appear in the advertisement
  // (if the deviceName and advertisementData are too long to fix into the 31 byte
  // ble advertisement packet, then the advertisementData is truncated first down to
  // a single byte, then it will truncate the deviceName)
//  Serial.begin(9600);
//  while (!Serial) {
//    ; // wait for serial port to connect. Needed for Leonardo only
//  }
//  Serial.println("We have started");

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'

  //RFduinoBLE.advertisementData = "rgb";

  //start the BLE stack
  //RFduinoBLE.begin();


}

void loop() {
  // switch to lower power mode
  //RFduino_ULPDelay(INFINITE);
  colorWipe(strip.Color(0, 0, 0), 50);
  //colorWipe(strip.Color(0, 255, 0), 50);
  //colorWipe(strip.Color(0, 0, 255), 50);
}

void RFduinoBLE_onConnect() {
  // the default starting color on the iPhone is white
  colorWipe(strip.Color(0, 0, 0), 50);
//  Serial.println("We have connected");
}

void RFduinoBLE_onDisconnect() {
  // turn all leds off on disconnect and stop pwm
  colorWipe(strip.Color(0, 0, 0), 50);
}

void RFduinoBLE_onReceive(char *data, int len) {
  // each transmission should contain an RGB triple
  if (len >= 3)
  {
    // get the RGB values
    uint8_t r = data[0];
    uint8_t g = data[1];
    uint8_t b = data[2];

    colorWipe(strip.Color(r, g, b), 50);
  }
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

gcgasson

  • RFduino Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #55 on: October 27, 2014, 10:48:50 AM »
How do I upload the hex file to the RFDuino?

tolson

  • Global Moderator
  • *****
  • Posts: 827
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #56 on: October 27, 2014, 10:52:35 AM »
Hi Tolson,

I have used your Adafruit_NeoPixel_tolsonMod.zip and replaced the original. First removed original then replaced it.


My modifided Adafruit library is only good for Arduino 1.5.6. It is broken under 1.5.7 and 1.5.8.

To test the timing specific for RFduino and Arduino 1.5.[7-8] can you report on my  non-library sketch.
The hex file above will work on the 24 pixel device as well... just lighting up the first 16 pixels. The hex loader is called RFDLoader and it is in the RFduino folder. There are versions for windows, 32bit mac and 64 bit mac.



gcgasson

  • RFduino Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #57 on: October 27, 2014, 01:27:19 PM »
Non library sketch worked after a little tweeking. Thank you.

tolson

  • Global Moderator
  • *****
  • Posts: 827
  • Karma: +19/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #58 on: October 27, 2014, 01:31:37 PM »
Non library sketch worked after a little tweeking. Thank you.

What did you tweak?????

zabowsky

  • RFduino Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #59 on: October 27, 2014, 04:50:55 PM »
Hi Zaboswky and Gary,

Can you try this hex file. It works on my ring for 16 NeoPixels.

I just pushed the hex file to my board and got the same result as with the standalone sketch. One LED cycling through colors at an appropriate brightness, and the others all bright white.

...and then I accidentally disconnect the ground pin from the ring and it started working perfectly!...I'm not yet sure what to make of that. I suspected a bad solder joint, but there's nothing obviously shorted when I look closely.

 

anything