Page 1 of 1

Which PIC devices support the WS2812 component?

Posted: Sat Apr 29, 2017 4:36 pm
by triokenwood
Hi all,

I have been playing around with an on-screen simulation using the WS2812 component, but now want to move on to actual 'real-life' testing.

However, how can I tell which PIC device(s) will support the component (due to the extreme timing restrictions imposed by the WS2812 RGB leds)?

The simulation runs quite happily when I specify a PIC 16F877A clocked at 19,660,800 Hz, with the data line connected to PORT C.5 - but, does this mean that it will run equally as well on a 'real device' set up for the same speed?

Thanks in advance,
Bill

Re: Which PIC devices support the WS2812 component?

Posted: Tue May 02, 2017 12:17 pm
by Benj
Hi Bill,
The simulation runs quite happily when I specify a PIC 16F877A clocked at 19,660,800 Hz, with the data line connected to PORT C.5 - but, does this mean that it will run equally as well on a 'real device' set up for the same speed?
The 16F877A device doesn't have enough memory to allow you to compile the program for 50 LEDs. I have reduced the LED count from 50 to 4 and this is now compiling correctly. I only have 4 LEDs on my test board.

I also changed the LED type from WS2811 to WS2812B (the LEDs I have here) in the LED_WS2811 component properties.

Testing on hardware using a 19.6608MHz crystal the 16F877A device does not seem fast enough to drive the LED timings. Only the first LED is switching on which is a common sign that the timings are not quite right. One way around this might be to try the 60 free days for the Pro version of the XC8 compiler and seeing if this makes a difference.

I would recommend at least a 16-bit PIC or an AVR device to reliably drive these LEDs, the ECIO40P16 or EB091 might be a good options for you and are known to work well. These should also give you more memory to be able to drive the 50 or more LEDs.

Re: Which PIC devices support the WS2812 component?

Posted: Tue May 02, 2017 2:23 pm
by Benj
I did think 8-bit PICs were working but looking at the post here it seems not.
viewtopic.php?f=63&t=18033&hilit=WS2812#p76655

Pro compiler 60 day trial is worth a go but if you want a long term solution then I would suggest a faster device family e.g. the 16-bit PICs or an AVR/Arduino.

Re: Which PIC devices support the WS2812 component?

Posted: Tue May 02, 2017 3:29 pm
by Benj
I've been having another look at this and it seems the problem is not the bit timings to control the LEDs, these are ok. The problem is the space between the data bytes is too long.

Just looking now to see if I can find a way to optimise this on the PIC8 devices.
Timings.jpg
Timings.jpg (172.29 KiB) Viewed 9617 times

Re: Which PIC devices support the WS2812 component?

Posted: Tue May 02, 2017 4:24 pm
by Benj
With a bit of tweaking I have a 48MHz PIC 8 working reliably.

Now to see if this can also work for a 16F1937 @ 32MHz and a 16F877A @ 20MHz.

Re: Which PIC devices support the WS2812 component?

Posted: Tue May 02, 2017 4:50 pm
by Benj
Right for an 8-bit PIC @ 48MHz to function first you need to use the updated component here which allows the inter byte timings to be reduced.

Simply copy the updated v7 component into your "Flowcode 7/Components" folder and restart Flowcode to load the changes.
LED_WS2811.fcpx
(13.89 KiB) Downloaded 422 times
For slower than 48MHz despite multiple attempts I haven't been able to get the code working using the Free XC8 compiler provided with Flowcode. The Pro version may work to allow slower devices but I haven't tried it so can't say for sure.

Re: Which PIC devices support the WS2812 component?

Posted: Mon May 08, 2017 2:58 pm
by triokenwood
Hi Benj,

Thanks for your efforts.

However, I don't know if you have come across this information (and, if not, it would seem to be well worth the read, especially Part II):-

Courtesy of "Tim's Blog"
https://cpldcpu.com/2014/01/14/light_ws ... he-ws2812/
https://cpldcpu.com/2014/01/19/light_ws ... rary-v2-0/

EDIT:
This is another useful link
Courtesy of "Josh .COM"
https://wp.josh.com/2014/05/13/ws2812-n ... know-them/

Perhaps this approach could greatly simplify things, and guarantee operation on devices with much lower clock frequencies?

Cheers,
Bill

Re: Which PIC devices support the WS2812 component?

Posted: Mon May 08, 2017 4:08 pm
by Benj
Thanks Bill,

However I'm already following one of those simplification guides.

Re: Which PIC devices support the WS2812 component?

Posted: Thu May 18, 2017 4:47 pm
by triokenwood
Hi Benj,

Sorry about the long delay - I seem to have too many other irons in the fire!

OK - at least we are all using the same book - even if I am several chapters behind you :D

Cheers,
Bill