WS2811

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
kurakaira
Posts: 77
Joined: 21 March 2007, 1:21 AM
Location: Finland

WS2811

Post by kurakaira »

Is there a way to drive WS2811 led's with ZBasic ?
I have used APA102 led's that don't require strict timing , but these are hard to source ...
WS2811 needs a timing resolution of 0.25us ...
Even OutputCapture on a ZX24x/u can't handle this fast transitions ..?
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: WS2811

Post by dkinzer »

kurakaira wrote:Even OutputCapture on a ZX24x/u can't handle this fast transitions ..?
That's true. It might be possible to bit-bang the protocol but the RTC interrupts (and others) may interfere with the timing. Certainly you'd have to have interrupts disabled for the duration of a transmission sequence.

I haven't worked out how long that might be but, generally speaking, if interrupts are disabled for more than 1-1/2 times the period of the RTC interrupt then interrupts will be missed. For the 14.7MHz devices the RTC interrupt period is 0.977 mS. That would mean that the maximum number of bits that could be transmitted would be about 1200. That may be enough to accomplish what you need.

There is an article on instructables.com showing how to bit-bang the data transmission for an Arduino device. The author uses assembly language in order to precisely control the timing of the sequence of changes of an output pin. The code could be used, with few changes, on a native mode mega-based ZX device.

https://www.instructables.com/Bitbangin ... f-WS2811-/

There are references in that article to work done by Adafruit and PJRC. If you can find that code you may well be able to adapt it to a ZX.
- Don Kinzer
Post Reply