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

Post Reply
User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

RBG LED WS2812 Adafruit NeoPixel - anyone got it working

Post by Jay Dee »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post by Benj »

Hello,

I have used similar LEDs on my project here.

[/youtube]

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: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

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

Post by Jay Dee »

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

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

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

Post by Benj »

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

[/youtube]

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

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

Post by Jay Dee »

This guy did some great background work on the LEDs on his blog.
https://cpldcpu.wordpress.com/2014/01/1 ... rary-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.

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

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

Post by Benj »

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

Post by Kenrix2 »

You might want to look into the application note pointed out by a forum member in this post:
http://www.matrixtsl.com/mmforums/viewt ... lit=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 584 times
Last edited by Kenrix2 on Tue Sep 08, 2015 10:36 pm, edited 1 time in total.

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

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

Post by Jay Dee »

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 537 times

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

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

Post by Benj »

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: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

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

Post by Jay Dee »

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

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

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

Post by Jay Dee »

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.62 KiB) Downloaded 485 times

tello
Posts: 94
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 16 times
Contact:

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

Post by tello »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post by Benj »

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.

tello
Posts: 94
Joined: Wed Jan 16, 2013 11:37 am
Has thanked: 56 times
Been thanked: 16 times
Contact:

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

Post by tello »

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

Post by RobH »

BenJ,

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

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

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

Post by Benj »

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

Post by RobH »

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

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

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

Post by Benj »

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

Post by RobH »

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

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

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

Post by Benj »

Thanks Rob,

It's mostly written in assembler but looks interesting. I'll ponder on it.

User avatar
Jay Dee
Posts: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

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

Post by Jay Dee »

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.

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

Post by wardelder »

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: 398
Joined: Tue Aug 18, 2009 6:42 pm
Has thanked: 121 times
Been thanked: 154 times
Contact:

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

Post by Jay Dee »

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 320 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.2 KiB) Downloaded 2082 times
Another day at the office. ;)

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

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

Post by Benj »

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 375 times

Post Reply