Controlling WS2812 5050 RGB LED

inglewoodpete

Senior Member
Any code examples to drive a
WS2812 5050 RGB LED
Wow! That was a brief question. It would be better to start your query in a new thread, since it has no relationship with OLDmarty's thread.

No, it can't be done with a PICAXE and definitely not without external hardware. Even with that hardware, a PICAXE is unlikely to be able to drive the data into these LEDs fast enough. The LED's datasheet indicates required bit rate is 800kbits/s.
 

Beera

New Member
Wow! That was a brief question. It would be better to start your query in a new thread, since it has no relationship with OLDmarty's thread.

No, it can't be done with a PICAXE and definitely not without external hardware. Even with that hardware, a PICAXE is unlikely to be able to drive the data into these LEDs fast enough. The LED's datasheet indicates required bit rate is 800kbits/s.
I am sorry. It was my first post and I was desperate. Thanks for hippy to move it.
 

premelec

Senior Member
There are drivers that can accept slower data and put it out to the LED strings - if you want to drive a string directly by PICAXE use APA102s [see NLEDshop.com for drivers]
 

hippy

Technical Support
Staff member
My notes on the issue, and I don't believe the situation has changed -

Summary

APA102 - Easily controlled directly from a PICAXE.

WS2801 - Directly controllable by a fast enough PICAXE with appropriate code.

WS2811 / WS2812 / WS2812B / APA104 - Not controllable by PICAXE.


APA102

These are the RGB LED strips we recommend for PICAXE use.

These devices use a two-wire SPI interface which can be easily driven from any PICAXE at any operating frequency. Hardware SPI (HSPIOUT), SHIFTOUT commands or bit-banged SPI can be used.


WS2801

These RGB LED strips can only be directly controlled by a fast enough PICAXE with appropriate code.

These devices use a two-wire SPI interface which requires sending bytes at a reasonably high speed. This is achievable with a PICAXE using hardware SPI (HSPIOUT) or internal SHIFTOUT commands.

However, the length of gap between consecutive bytes is used to reset the LED strip to indicate the next data is for the first RGB LED. A gap of greater than 500us is considered a reset. Only a PICAXE able to output consecutive bytes quickly enough is able to control a LED strip and the code has to be crafted to facilitate that.

PICAXE forum member 'westaust55' has kindly provided details and example code for using WS2801-based LED strips here -

www.picaxeforum.co.uk/showthread.php?22713-Getting-Started-with-the-WS2801


WS2811 / WS2812 / WS2812B / APA104

These RGB LED strips cannot be directly controlled by a PICAXE.

The LED srips are similar to WS2801-based LED strips but have a shorter (50us) inter-byte reset period which is too short for the PICAXE to generate consecutive byte output without a reset occurring.
 

inglewoodpete

Senior Member
I concur with hippy's summary above.

In recent weeks I have written a program for a PIC18F25K42 in Microchip XC8 (C language). The chip runs at 64MHz and uses DMA to output SPI at 800 kbits/s into a CD4093 Quad Schmitt Trigger (configured as two monostables with outputs mixed into one output line). The CD4093 which combines the SPI clock and data signal into the one-wire binary-timed signal (refer to image, below). The controller circuit drives a chain of 125 RGB LEDs (ie 375 bytes) and takes 3mS to output the 375 bytes, followed by a further 50uS 'latching' signal. I'm pretty certain that an X2 PICAXE would not be able to sustain that sort of output. If a PICAXE could do what I want, believe me, I'd use one: they're so much easier to program and debug :).
 

Attachments

Last edited:
Top