RBG LED WS2812 Adafruit NeoPixel - anyone got it working

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

User avatar
Jay Dee
Posts: 356
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 135 times
Contact:

RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Jay Dee » Sun Aug 16, 2015 8:35 pm

Hi Guys,
I've revisiting an old RGB project.. and saw an RGB stick with 8 LED from Adafruit, available in the UK.

http://proto-pic.co.uk/neopixel-stick-8 ... d-drivers/

Ju8st happens to be more than ideal but has anyone had any luck driving the WS2812 programmable LEDs..
The issue I believe is mostly with getting very accurate timing for the serial programming.
a Logic Zero requires 0.35uS High, 0.8uS Low (both parts +/-0.15uS)
a Logic One required 0.7uS High, 0.6uS Low (both parts +/-0.15uS)
This is far finer than I'll achieve with a delay macro! :D
Tech and Spanish Dude discussed it over on the french forum but my french is p*ss poor conversational at best!

So anyone had a play with these little blighters? we all love a bit of flashy LED stuff!
J.

User avatar
Benj
Matrix Staff
Posts: 14325
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Benj » Mon Aug 17, 2015 10:28 am

Hello,

I have used similar LEDs on my project here.



Source code as available from here.

http://www.matrixtsl.com/mmforums/viewt ... =25#p57182

To output the signals to the LEDs I used the ECIO40P16 hardware though the EB091 will also be fast enough to work.

User avatar
Jay Dee
Posts: 356
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 135 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Jay Dee » Fri Aug 21, 2015 4:49 pm

Ah.. Nice one Benj !!
Will try to find time for a trawl this weekend. Blinky lights Ahoy!

User avatar
Benj
Matrix Staff
Posts: 14325
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Benj » Mon Aug 24, 2015 11:38 am

Used them in this project too. Great little LEDs :D


User avatar
Jay Dee
Posts: 356
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 135 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Jay Dee » Mon Aug 24, 2015 2:20 pm

This guy did some great background work on the LEDs on his blog.
https://cpldcpu.wordpress.com/2014/01/19/light_ws2812-library-v2-0/
Regarding the data timing Tims basic conclusions were;

A reset is issued as early as at 9 µs, contrary to the 50 µs mentioned in the data sheet. Longer delays between transmissions should be avoided.
The cycle time of a bit should be at least 1.25 µs, the value given in the data sheet, and at most ~9 µs, the shortest time for a reset.
A “0” can be encoded with a pulse as short as 62.5 ns, but should not be longer than ~500 ns (maximum on WS2812).
A “1” can be encoded with pulses almost as long as the total cycle time, but it should not be shorter than ~625 ns (minimum on WS2812B).

From the testing on another thread, managed to get an ECIO40P to output a pulse train of period 580ns, Low 140nS and Hi of 170nS using a bit of C code from Ben.
Given that the timing might not be as super precise as the datasheet implies.. it might yet be possible to get these lower speed PICs to crudely drive them... hmmm will keep looking.
These users thanked the author Jay Dee for the post (total 2):
Benj (Mon Aug 24, 2015 3:41 pm) • medelec35 (Fri Aug 28, 2015 8:00 am)
Rating: 10.53%
 

User avatar
Benj
Matrix Staff
Posts: 14325
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Benj » Mon Aug 24, 2015 3:41 pm

Great news, let us know how your getting on.

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Kenrix2 » Fri Aug 28, 2015 6:13 am

You might want to look into the application note pointed out by a forum member in this post:
viewtopic.php?f=41&t=14504&hilit=ws2812
Flowcode 6 now supports that chip, so you can ignore the parts of the post that add it to the chip list.
I was a bit curious about this since I like "flashy stuff" too, so I made a program to try it out..
Here are the approximate timings: for a (1) .8us High, .4us Low and for a (0) .4us High, .8us Low.
Edit: Changed micro and adjusted timings.
Attachments
flashy_stuff_experiment.fcfx
(9.12 KiB) Downloaded 345 times
Last edited by Kenrix2 on Tue Sep 08, 2015 10:36 pm, edited 1 time in total.
These users thanked the author Kenrix2 for the post:
medelec35 (Fri Aug 28, 2015 8:00 am)
Rating: 5.26%
 

User avatar
Jay Dee
Posts: 356
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 135 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Jay Dee » Mon Aug 31, 2015 1:19 pm

Hi Guys,
and Thanks Kenrix, I'm away on Event so not had much time to study the other post in detail yet but will go through when I'm back in the UK.

I was working on getting a nice fast bit bang output from the ECIO40P.. I did manage to get a very crude 80ns pulse! For improving my own understanding, I decided to write the section that needs to run as fast as possible in C, I can then trim it down, remove any bloat and get somewhere close to the actual timing needed to function.
The is the first bit of C code I've inserted into Flowcode. I know there are errors as boostC wont compile it so I would really appreciate someone pointing out the silly syntactical errors :) proper way to call FC variables...

Code: Select all

Int count;
for(count=0; count<=8; count++)
   {
   latc = 0x80;
      if(FCL_COLVAL&0x80)
      {
      asm { Nop };
      latc = 0x00;
      } //Close IF
   else
      {
      asm { Nop Nop Nop};
      latc = 0x00;
      } //Close Else   
   FCL_COLVAL<<=1   //Bitshift Byte for next time around loop
   } //Close For Loop


If it helps any...The flowcode attached is the 'work in progress' test program, a highly chopped down version of Bens Infinity mirror FC.
The above C code is used in the refresh macro.
Thanks for any pointers.
Attachments
NeoPixel_Test3_Nop_ECIO40P.fcfx
(11.96 KiB) Downloaded 313 times

User avatar
Benj
Matrix Staff
Posts: 14325
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Benj » Tue Sep 01, 2015 10:37 am

Hello,

I can see a couple of problems.

Code: Select all

Int count;


This should probably be.

Code: Select all

char count;


Another line that BoostC won't like is this.

Code: Select all

FCL_COLVAL<<=1


This should instead be like this.

Code: Select all

FCL_COLVAL = FCL_COLVAL << 1

User avatar
Jay Dee
Posts: 356
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 135 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Jay Dee » Tue Sep 01, 2015 6:02 pm

Cheers Ben,
Taken an hour to bash my way through but the following C code now compiles.. back at the office in a day or so and will flash it to an ECIO and see whjat we get in hardware. :)

Code: Select all

char count;
for(count=0; count<=8; count++)
   {
   latc = 0x80;
      if(FCL_COLVAL&0x80)
   {
    asm
    {
    Nop
    }
   latc = 0x00;
   } else {
    asm
    {
    Nop
    }   
   latc = 0x00;
   }   
   FCL_COLVAL = FCL_COLVAL << 1; //Bitshift Byte for next time around loop
   } //Close For Loop
These users thanked the author Jay Dee for the post:
Benj (Wed Sep 02, 2015 11:13 am)
Rating: 5.26%
 

User avatar
Jay Dee
Posts: 356
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 135 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Jay Dee » Sun Sep 06, 2015 11:42 am

The C code worked great.. had to play around the the 'Nop' commands to get the timing right. It does appear that the actual timing requirements are quite broad. Sticking to the limits previously discussed it works fine for me.
Attached is a working test routine for an ECIO40P driving 8 neopixels.
NOTE
If you are using anything other than an ECIO40P, ECIO28P, (18F4455 or similar) you'll need to re-tweak all of the Nop timings. It needs a fairly fast 8bit PIC, the ECIO's internal clock is running at 48Mhz.
This test program writes to the whole C port even though data is only output on C7.
If you writing to lots of Neopixels or doing something fancy.. you'll need more grunt than this 8 bit micro! But for real basic stuff it works. Good enough for the prototype my customer needs.
Hope this helps anyone else playing with Neopixels.. have fun.
J.
NeoPixel_Test4_Nop_ECIO40P.hex
NeoPixel Test Routine - ECIO40P PIC18F4455
(1.66 KiB) Downloaded 270 times
These users thanked the author Jay Dee for the post (total 3):
kersing (Sun Sep 06, 2015 1:04 pm) • Benj (Mon Sep 07, 2015 11:03 am) • medelec35 (Mon Dec 12, 2016 7:25 am)
Rating: 15.79%
 

tello
Posts: 88
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 55 times
Been thanked: 12 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby tello » Thu Nov 12, 2015 2:31 pm

Hey guys, I want to control some leds neopixel.
Long ago, I thought I saw a component to flowcode6 this led.
It's posible?? I'm not sure.

Thank you

User avatar
Benj
Matrix Staff
Posts: 14325
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Benj » Thu Nov 12, 2015 3:38 pm

Hello,

I would have made a component a while back but the timings to drive the LEDs were a bit too tight to reliably calculate based on clock speed and device family. With a bit of time and attention it probably could be done.

The alternative LED modules with Data and Clock data lines are far easier to control as you can simply clock out the data at your own speed. Therefore we could make a component to drive these.
These users thanked the author Benj for the post:
tello (Mon Nov 16, 2015 11:17 am)
Rating: 5.26%
 

tello
Posts: 88
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 55 times
Been thanked: 12 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby tello » Thu Nov 19, 2015 11:29 am

Hi Benj.

What I want to try that put only in asm code routine to set the output to "1" and "0" to get the necessary fast time.
No program in assembly, I would like to put in the code block C ASM code to activate and deactivate the output.
Thank you

User avatar
RobH
Posts: 95
Joined: Wed Sep 11, 2013 7:51 pm
Has thanked: 29 times
Been thanked: 17 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby RobH » Mon Feb 15, 2016 11:34 pm

BenJ,

I could use a NeoPixel component if you could make it.

User avatar
Benj
Matrix Staff
Posts: 14325
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Benj » Tue Feb 16, 2016 1:11 pm

Hi Rob,

I made a product using these LED strips and have got quite badly burnt, they work, then they dont, then they do... My table works well but I think that's because I don't really care which LED is LED 1. I don't think I want to go near them again.

The strips with the clock and data signals work very well and I would recommend using these instead if your making a product and don't want to be ripping your hair out when the customer out in the field is saying they don't work.

User avatar
RobH
Posts: 95
Joined: Wed Sep 11, 2013 7:51 pm
Has thanked: 29 times
Been thanked: 17 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby RobH » Tue Feb 16, 2016 1:14 pm

Sounds horrible! I've got them working fine in Arduino. I guess I'll stick with that.

User avatar
Benj
Matrix Staff
Posts: 14325
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Benj » Tue Feb 16, 2016 1:17 pm

Hi Rob,

I had them working fine, It wasn't until we actually tried them outside of the lab on a mains PSU rather then a DC bench supply that they started having issues. Lots of issues. I was converting from 3V3 to 5V so that could have been part of the problem.

Could be the Arduino lib is doing something special but I couldn't crack it from reading datasheets.

Do you have a link to the Arduino library and I will have a look at how they are doing things.

User avatar
RobH
Posts: 95
Joined: Wed Sep 11, 2013 7:51 pm
Has thanked: 29 times
Been thanked: 17 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby RobH » Tue Feb 16, 2016 2:52 pm

AdaFruit has some files on GitHub:
https://github.com/adafruit/Adafruit_NeoPixel

User avatar
Benj
Matrix Staff
Posts: 14325
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Benj » Wed Feb 17, 2016 11:25 am

Thanks Rob,

It's mostly written in assembler but looks interesting. I'll ponder on it.
These users thanked the author Benj for the post:
RobH (Wed Feb 17, 2016 11:18 pm)
Rating: 5.26%
 

User avatar
Jay Dee
Posts: 356
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 135 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Jay Dee » Thu Mar 10, 2016 1:24 pm

An alternative..
I got my 8 NeoPixels working fine but have recently started using the APA102C leds, Uses SPI.. only MOSI and Clock, 5V, Gnd. Its really simple to drive and no special timing at all. Certainly an option for those on new projects and have not commited to the NeoPixels. They do various density strips and loose 5050 packages, there is an LED strip with 144 per meter, 20ma per colour and 60mA per LED so can get quite power hungry at full brightness.
https://www.pololu.com/product/2557
J.
These users thanked the author Jay Dee for the post:
Benj (Mon Mar 14, 2016 5:46 pm)
Rating: 5.26%
 

wardelder
Posts: 5
Joined: Fri Dec 09, 2016 4:02 pm
Been thanked: 1 time
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby wardelder » Fri Dec 09, 2016 4:04 pm

Will Flowcode 7 support the APA102 in the future? I have several from Pololu and would like to use them on my WS2812 projects.

User avatar
Jay Dee
Posts: 356
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 116 times
Been thanked: 135 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Jay Dee » Mon Dec 12, 2016 5:07 am

Hi,
I know its not a flowcode component but the following is an example extracted from a project that I used APA102C leds.
They turn out to be pretty simple using an SPI component to push strings of data into the LED strip.
My example is only setup for 8 LED and the LED data is hard-written to an byte array.
LED_APA102C_SPI_Example1.fcfx
(11.73 KiB) Downloaded 173 times

I've not tested this example on hardware, as I'm away from office but I know the routine works as I've had it running RGB ID and running lights on a LeMans LMP1 race car all year. :)
02116009_11126 (Medium).jpg
LMP1
(260.21 KiB) Downloaded 2082 times

Another day at the office. ;)
These users thanked the author Jay Dee for the post (total 3):
jgu1 (Mon Dec 12, 2016 6:51 am) • medelec35 (Mon Dec 12, 2016 7:29 am) • Benj (Mon Dec 12, 2016 12:02 pm)
Rating: 15.79%
 

User avatar
Benj
Matrix Staff
Posts: 14325
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4412 times
Been thanked: 4130 times
Contact:

Re: RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Postby Benj » Mon Dec 12, 2016 12:30 pm

That's a nice picture :) Some real electronics, also thanks for the example.

Here's a really quick go at a component, the current usage setting is currently a global property rather than a LED by LED value. Saves a bit of RAM space but more limiting in terms of what you can do with it.

Just copy the file into your "Flowcode 7/Components" directory and restart Flowcode and the component should then appear under the outputs category.

LED_APA102C.fcpx
(12.59 KiB) Downloaded 215 times
These users thanked the author Benj for the post:
Jay Dee (Tue Dec 13, 2016 4:51 am)
Rating: 5.26%