-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ws2812 timing is incorrect when using HARDWARE_NEOPIXEL
#294
Comments
Hi @jimmo, I don't remember the details, but I suspect we probably gathered the timings of the types of Neopixels we knew about at the time, and got it working for those values. Maybe @finneyj remembers more? (I'll move this issue to the |
Thanks @microbit-carlos -- I have sent a PR at lancaster-university/codal-nrf52#47 This works on all the neopixel and neopixel-like strips I have access to (which includes WS2812B, SK6812 RGBW, APA104), including the previously-not-working robots mentioned in the original message. |
Merged this in to |
hi @microbit-carlos & @JohnVidler, thanks for merging this. Damien has just updated the MicroPython repo to use CODAL 0.2.58 (microbit-foundation/micropython-microbit-v2@f47cbe1) which includes this fix. Could you please let me know a rough ETA for when the online editor at python.microbit.org will incorporate this so I can let the schools know (there are hundred of these affected robots in use across several schools and they're looking forward to the fix!). Thanks! |
I'm helping a school group figure out an issue related to neopixels. The background is:
Digging into this a bit more, it appears the issue is specifically with the CODAL implementation, I think likely only when
HARDWARE_NEOPIXEL
is enabled (which MicroPython uses the default, enabled). It appears that this isn't generating an 800kHz waveform, and although WS2812 seems to work, the other chips such as APA104 (and maybe SK6812) don't like it.I was surprised that make:code was fine though, but seems that they use their own driver https://github.com/microsoft/pxt-neopixel which uses https://github.com/microsoft/pxt-ws2812b/ which appears to be a common implementation shared by v1 and v2 micro:bit. Curious why they don't use CODAL also?
v1 MicroPython is also fine because it uses the hand-written assembly code in https://github.com/bbcmicrobit/micropython/blob/master/source/lib/neopixelsend.s
I captured some traces, which are attached (can be opened in PulseView). microbit-traces.zip The summary below is:
HH/L
means the relatively long H followed by the short L (i.e. a zero bit), and H/LL means the one bit. Note the last one is for CODAL withHARDWARE_NEOPIXEL
disabled and appears to have a small amount of jitter for the zero bit, hence two lines for the 0.I noticed that the hardware implementation has
#define WS2812B_PWM_FREQ 500000
https://github.com/lancaster-university/codal-nrf52/blob/master/inc/WS2812B.h#L37
Changed this to 800kHz and I think the results look more correct, although I think the T1H needs to be slightly longer? It does still work on a WS2812, need to test on APA104.
Happy to send a PR, but would be good to understand if the 500kHz is intentional? @finneyj @microbit-carlos @dpgeorge
Thanks!
The text was updated successfully, but these errors were encountered: