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

fortolano

  • RFduino Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #30 on: May 08, 2014, 03:23:42 PM »
Hi Tolson,
For the colorwipe, the LEDS flick a bit, so you can tell there is some sort of animation going, but the LEDs are still super super bright (almost white).
I am attaching a video that I've just recorded from with my phone (pardon the bad production)

Thanks again.
Flavio

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #31 on: May 08, 2014, 03:31:24 PM »
I can't play your quicktime movie. However, from what you descripe you are not using my modifications.

After you unzip my zip file you need to rename the folder to  Adafruit_NeoPixel without my name attached.
What appears to be happening is your script is accessing the actual Adafruit library in the unmodified Adafruit folder.

You need to replace that folder with mine.



mark_n

  • RFduino Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #32 on: June 11, 2014, 08:22:57 PM »
Hi,

So I downloaded this mod to try it out, but it won't compile. I've also tried the Tolsonmod but same issues. The errors I'm getting are basically that nothing is in scope. I'm not sure what the issue is, because if I switch the board to say "Uno" it compiles.

Any ideas?

Thank you!


tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #33 on: June 11, 2014, 09:11:44 PM »
Need more Input!

What Arduino version?

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #34 on: June 11, 2014, 09:19:07 PM »
Hi,

So I downloaded this mod to try it out, but it won't compile. I've also tried the Tolsonmod but same issues. The errors I'm getting are basically that nothing is in scope. I'm not sure what the issue is, because if I switch the board to say "Uno" it compiles.

Any ideas?

Thank you!

OK, looking at your errors, you are not using the version for the RFduino.
The line numbers for the errors you are getting do not contain those commands in my version.
So you must still be accessing the un-modified versions.


mark_n

  • RFduino Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #35 on: June 11, 2014, 10:18:14 PM »
Turns out it was a naming conflict.

So if you're using one library (tolson mod, or the mkay mod) you have to remove the original neo-pixel library. Small thing, but good to find out. Complies and works now.
« Last Edit: June 11, 2014, 10:21:31 PM by mark_n »

foobar

  • RFduino Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #36 on: July 17, 2014, 08:36:34 PM »
@fortolano: Have you found a solution yet?

@others: I have the same problem as Flavio/fortolano (i.e., I always see white + color instead of the color I actually set it to) and I would appreciate any help. Here's the due diligence I have done so far. Like fortolano, I am also using the Adafruit Neopixel 12-LED ring. (I have also tried it on a strip of 7 neopixels and got the same problem.)

1) Used tolson's library and renamed it as Adafruit_Neopixel.
2) Only change to the example sketch is to change the number of pixels and the output pin (pin 2).
3) Used mkay's library and still got the same symptoms.
4) I know for sure that the LED strip/ring is fine because it works on teensy 3.1 and on the ATTiny85 (both with original Neopixel library).
5) I do not have any naming issues... I only keep one version of the library when testing.
---
Added later: I'm using Arduino 1.5.7 and RFDuino 2.1.
I'm running the RFDuino on USB power (via the USB shield) and powering the LED strips via a LiPo battery.
« Last Edit: July 17, 2014, 08:40:34 PM by foobar »

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #37 on: July 18, 2014, 12:54:05 PM »
Hi foobar,
Yes, the neopixel issue was resolved in the previous versions of Arduino 1.5.6-r2 with any version of RFduino prior to version 2.1.

I can confirm that the new beta Arduino 1.5.7 is slower than 1.5.6. At least in the time it takes to do if-else calls and returns. This results in stretching the critical timing required for neo pixel strips. I have confirmed that this occurs regardless of which RFduino version is used.

As far as ATTiny85 and Teensy 3.1... I think Teensy 3.1 only uses Aduino 1.0.x so far. Not sure how far the ATTiny85 has come with 1.5.x. But it doesn't matter. The timing code in the pixel library does different things specific for each microprocessor type, so you can't compare the three results. But, I realize you are probably just saying you are confirming that the strip isn't broken because it does work elsewhere. Cool!

Anyways, back to the drawing board. Either we need to figure out a speed optimize flag for the new compiler to return the compiled code back to faster code, or do more of the timing in Assembler instead of a mix of C and Assembler. I suspect the push to make the compiler produce smaller object code resulted in slower code for some functions.

In the mean time, if it is urgent to use neopixels (WS2812(B)) LEDs, I am going to continue using Arduino 1.5.6-r2 with RFduino-2.0.3. It looks to me like most of what changed in 2.1 was just to point to the changes in 1.5.7 naming and paths.

Arduino calls their 1.5.x versions BETA versions, meaning things may break with every revision. This is one good example.
« Last Edit: July 18, 2014, 12:59:20 PM by tolson »

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #38 on: July 19, 2014, 02:15:04 AM »
OK, got my old test program working again using the Arduino IDE 1.5.7 and the RFduino version 2.1.

<a href="http://www.youtube.com/v/i_N1K8oJ85M/" target="_blank" class="new_win">http://www.youtube.com/v/i_N1K8oJ85M/</a>

Try this code...

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 = 60;

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(); 
}


[EDIT] Verified works with Arduino 1.5.8
« Last Edit: October 22, 2014, 06:31:05 PM by tolson »

foobar

  • RFduino Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #39 on: July 19, 2014, 08:34:32 PM »
@tolson, Thanks a lot. I really appreciate your help. I will try out the new version and get back to you. 

And yes, my only point in bringing up the Teensy and ATTiny85 was that the LED strip was okay. (I am indeed using both Teensy 3.1 and ATTiny85 with Arduino 1.0.5.)

foobar

  • RFduino Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #40 on: July 20, 2014, 07:59:05 AM »
The new sketch works. Thanks a lot.


mkay

  • RFduino Team
  • *****
  • Posts: 405
  • Karma: +15/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #41 on: August 26, 2014, 06:44:51 PM »
Nice sketch tolson it works well.  :)

I made a change to the modified Adafruit library again and this one seems to work for me with Arduino v1.5.7. Only tested the 800khz speed. Let me know if it works for you guys also.

gotnull

  • RFduino Jr. Member
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #42 on: September 16, 2014, 12:51:19 AM »
Hi guys, this is not an official release, but it is a modified version of the Adafruit neopixel library with RFduino support.

Its working well on my end, let me know if you guys have any trouble with it.

I'm using this but I'm still getting errors compiling:

Arduino: 1.5.7 (Mac OS X), Board: "RFduino"

Using library RFduinoBLE in folder: /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/libraries/RFduinoBLE (legacy)
Using library Adafruit_NeoPixel in folder: /Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel (legacy)

/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fno-builtin -mcpu=cortex-m0 -DF_CPU=16000000 -DARDUINO=157 -mthumb -D__RFduino__ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/variants/RFduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/libraries/RFduinoBLE -I/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/system/RFduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/system/RFduino/Include -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/system/CMSIS/CMSIS/Include /var/folders/b6/pnpkh4cd7dj0xcbygbdw9mph0000gn/T/build7271153727973197368.tmp/strandtest_rfduino.cpp -o /var/folders/b6/pnpkh4cd7dj0xcbygbdw9mph0000gn/T/build7271153727973197368.tmp/strandtest_rfduino.cpp.o
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fno-builtin -mcpu=cortex-m0 -DF_CPU=16000000 -DARDUINO=157 -mthumb -D__RFduino__ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/variants/RFduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/libraries/RFduinoBLE -I/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/libraries/RFduinoBLE/utility -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/system/RFduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/system/RFduino/Include -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/system/CMSIS/CMSIS/Include /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/libraries/RFduinoBLE/RFduinoBLE.cpp -o /var/folders/b6/pnpkh4cd7dj0xcbygbdw9mph0000gn/T/build7271153727973197368.tmp/RFduinoBLE/RFduinoBLE.cpp.o
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fno-builtin -mcpu=cortex-m0 -DF_CPU=16000000 -DARDUINO=157 -mthumb -D__RFduino__ -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/variants/RFduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/libraries/RFduinoBLE -I/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel -I/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/utility -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/system/RFduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/system/RFduino/Include -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/system/CMSIS/CMSIS/Include /Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp -o /var/folders/b6/pnpkh4cd7dj0xcbygbdw9mph0000gn/T/build7271153727973197368.tmp/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp.o
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp: In member function 'void Adafruit_NeoPixel::show()':
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:748:3: error: 'Pio' was not declared in this scope
   Pio            *port;
   ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:748:19: error: 'port' was not declared in this scope
   Pio            *port;
                   ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:749:12: error: 'WoReg' does not name a type
   volatile WoReg *portSet, *portClear, *timeValue, *timeReset;
            ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:752:29: error: 'pmc_set_writeprotect' was not declared in this scope
   pmc_set_writeprotect(false);
                             ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:753:35: error: 'TC3_IRQn' was not declared in this scope
   pmc_enable_periph_clk((uint32_t)TC3_IRQn);
                                   ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:753:43: error: 'pmc_enable_periph_clk' was not declared in this scope
   pmc_enable_periph_clk((uint32_t)TC3_IRQn);
                                           ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:754:16: error: 'TC1' was not declared in this scope
   TC_Configure(TC1, 0,
                ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:755:5: error: 'TC_CMR_WAVE' was not declared in this scope
     TC_CMR_WAVE | TC_CMR_WAVSEL_UP | TC_CMR_TCCLKS_TIMER_CLOCK1);
     ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:755:19: error: 'TC_CMR_WAVSEL_UP' was not declared in this scope
     TC_CMR_WAVE | TC_CMR_WAVSEL_UP | TC_CMR_TCCLKS_TIMER_CLOCK1);
                   ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:755:38: error: 'TC_CMR_TCCLKS_TIMER_CLOCK1' was not declared in this scope
     TC_CMR_WAVE | TC_CMR_WAVSEL_UP | TC_CMR_TCCLKS_TIMER_CLOCK1);
                                      ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:755:64: error: 'TC_Configure' was not declared in this scope
     TC_CMR_WAVE | TC_CMR_WAVSEL_UP | TC_CMR_TCCLKS_TIMER_CLOCK1);
                                                                ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:756:18: error: 'TC_Start' was not declared in this scope
   TC_Start(TC1, 0);
                  ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:758:15: error: 'g_APinDescription' was not declared in this scope
   pinMask   = g_APinDescription[pin].ulPin; // Don't 'optimize' these into
               ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:760:3: error: 'portSet' was not declared in this scope
   portSet   = &(port->PIO_SODR);            // burn a few cycles after
   ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:761:3: error: 'portClear' was not declared in this scope
   portClear = &(port->PIO_CODR);            // starting timer to minimize
   ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:762:3: error: 'timeValue' was not declared in this scope
   timeValue = &(TC1->TC_CHANNEL[0].TC_CV);  // the initial 'while'.
   ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:763:3: error: 'timeReset' was not declared in this scope
   timeReset = &(TC1->TC_CHANNEL[0].TC_CCR);
   ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:787:18: error: 'TC_CCR_CLKEN' was not declared in this scope
     *timeReset = TC_CCR_CLKEN | TC_CCR_SWTRG;
                  ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:787:33: error: 'TC_CCR_SWTRG' was not declared in this scope
     *timeReset = TC_CCR_CLKEN | TC_CCR_SWTRG;
                                 ^
/Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:797:17: error: 'TC_Stop' was not declared in this scope
   TC_Stop(TC1, 0);
                 ^

tolson

  • Global Moderator
  • *****
  • Posts: 866
  • Karma: +20/-0
    • View Profile
    • Thomas Olson Consulting
Re: Digital rgb ledstrip driven by RFDuino
« Reply #43 on: September 16, 2014, 07:42:37 AM »
Hi guys, this is not an official release, but it is a modified version of the Adafruit neopixel library with RFduino support.

Its working well on my end, let me know if you guys have any trouble with it.

I'm using this but I'm still getting errors compiling:

Arduino: 1.5.7 (Mac OS X), Board: "RFduino"

Using library RFduinoBLE in folder: /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/RFduino/libraries/RFduinoBLE (legacy)
Using library Adafruit_NeoPixel in folder: /Users/fulvio/Documents/Arduino/libraries/Adafruit_NeoPixel (legacy)

* * *

Hi gotnull,

From the quote I assume you are using the mod file provided with that comment. Is that right? If so, that may be the problem. mkay as provided an updated mod2 file for the 1.5.7 / 2.1.x  IDE. Can you confirm which you are using?

zabowsky

  • RFduino Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Digital rgb ledstrip driven by RFDuino
« Reply #44 on: October 19, 2014, 02:02:42 PM »
Nice sketch tolson it works well.  :)

I made a change to the modified Adafruit library again and this one seems to work for me with Arduino v1.5.7. Only tested the 800khz speed. Let me know if it works for you guys also.

This library is not working for me. I get the same results using this or the original mod, which is that all my LEDs simply stay bright white no matter what I send.

I'm using Arduino 1.5.7 - I've also tried 1.5.8 -, RFduino 2.1.2, and a 16 LED ring.

With tolson's updated example sketch, modified for my LED ring size, I see one of my 16 LEDs cycle through colors properly, and the other 15 remain bright white.
« Last Edit: October 19, 2014, 02:52:14 PM by zabowsky »

 

anything