Esp32 Firmware v1.12 Bug (Neopixel Glitches)
Esp32 Firmware v1.12 Bug (Neopixel Glitches)
I have been working on micropython for esp32, and found a very trade off situation w.r.t Neopixel and Multi-Threading.
Problem 1 - When I am using latest Esp32 Firmware v1.12 there is problem in Neopixel Led (Ws2812 Addressable Leds). It shows glitches randomly while working, It blinks randomly without any specific interval.
According to me it is mostly because there is some timing issue occurred in library while updating the Firmware from v1.11 to v1.12.
Problem 2 - When I am using the Firmware v1.11, the neopixel library is working fine without any glitches or any problem. But the problem is in this firmware Multi-threading is not handled properly. While running multiple threads in my project, they tend to slow down the process or it is very seemingly delay in each thread execution.
So, if anyone has any suggestion or Solution for this. I am all ears.
Problem 1 - When I am using latest Esp32 Firmware v1.12 there is problem in Neopixel Led (Ws2812 Addressable Leds). It shows glitches randomly while working, It blinks randomly without any specific interval.
According to me it is mostly because there is some timing issue occurred in library while updating the Firmware from v1.11 to v1.12.
Problem 2 - When I am using the Firmware v1.11, the neopixel library is working fine without any glitches or any problem. But the problem is in this firmware Multi-threading is not handled properly. While running multiple threads in my project, they tend to slow down the process or it is very seemingly delay in each thread execution.
So, if anyone has any suggestion or Solution for this. I am all ears.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Esp32 Firmware v1.12 Bug (Neopixel Glitches)
You may get better results using uasyncio instead of threading.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Esp32 Firmware v1.12 Bug (Neopixel Glitches)
See https://github.com/micropython/micropython/issues/5157.
TL;DR; Use the latest micropython version and use the RMT implementation by nevercast: https://gist.github.com/nevercast/9c485 ... 4a22062795
TL;DR; Use the latest micropython version and use the RMT implementation by nevercast: https://gist.github.com/nevercast/9c485 ... 4a22062795
Re: Esp32 Firmware v1.12 Bug (Neopixel Glitches)
@carsten after your suggestion I have tried RMT implementation and used the nevercast code of pixels.py for ws2812 led implementation.
Individually the library is working fine as it supposed to be But that implementation allocates a large chunk of memory and produces the error Memory Allocation Failed when I try to run it in my project which already consumes memory.
I read the the library for it, It makes tuples of very large size, which makes hard to allocate memory at runtime.
Individually the library is working fine as it supposed to be But that implementation allocates a large chunk of memory and produces the error Memory Allocation Failed when I try to run it in my project which already consumes memory.
I read the the library for it, It makes tuples of very large size, which makes hard to allocate memory at runtime.
Re: Esp32 Firmware v1.12 Bug (Neopixel Glitches)
@carsten I have used your approach but has memory allocation issue as it needs 15k memory in ram, quite not possible in my case.
Still thanks for reply.
Still thanks for reply.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: Esp32 Firmware v1.12 Bug (Neopixel Glitches)
Is it possible to mod the RMT implementation to use byte array instead of python tuples
Re: Esp32 Firmware v1.12 Bug (Neopixel Glitches)
@pythoncoder Thanks for replying.
We can only import uasyncio lib in Firmware v1.12, where threading is working fine but neopixel having glitching problem.
Multi Threading issue is in Firmware v1.11 and we can not import uasyncio in that version of Firmware.
We can only import uasyncio lib in Firmware v1.12, where threading is working fine but neopixel having glitching problem.
Multi Threading issue is in Firmware v1.11 and we can not import uasyncio in that version of Firmware.
Re: Esp32 Firmware v1.12 Bug (Neopixel Glitches)
Anyone has anymore solutions or suggestions?
Re: Esp32 Firmware v1.12 Bug (Neopixel Glitches)
Hi @shubham,
RMT is the right way to drive NeoPixels on the ESP32. Whether you use threads or asyncio the underlying OS (FreeRTOS) will periodically interrupt the system long enough to cause glitches in the datastream significant enough to upset NeoPixels.
RMT employs hardware specific to the ESP32 where a bitstream can be specified such that the hardware can send it out with highly accurate timing (down to 12.5ns).
I'm aware that currently RMT takes a large amount of RAM and have a plan to resolve this (effectively double-buffering the datastream, calling back into MicroPython when more data is required - as the alternate buffer is being sent) but I don't have time to work on this in the near future. If you'd like to take a go at implementing this yourself I'd be happy to help explain what I have in mind. Otherwise I'm afraid you'll have to wait a little while.
I wish I could give you a better solution right now!
I think you have learnt most of this but just to recap...
RMT is the right way to drive NeoPixels on the ESP32. Whether you use threads or asyncio the underlying OS (FreeRTOS) will periodically interrupt the system long enough to cause glitches in the datastream significant enough to upset NeoPixels.
RMT employs hardware specific to the ESP32 where a bitstream can be specified such that the hardware can send it out with highly accurate timing (down to 12.5ns).
I'm aware that currently RMT takes a large amount of RAM and have a plan to resolve this (effectively double-buffering the datastream, calling back into MicroPython when more data is required - as the alternate buffer is being sent) but I don't have time to work on this in the near future. If you'd like to take a go at implementing this yourself I'd be happy to help explain what I have in mind. Otherwise I'm afraid you'll have to wait a little while.
I wish I could give you a better solution right now!
Re: Esp32 Firmware v1.12 Bug (Neopixel Glitches)
The only way to get rid of the memory requirements would be to completely write the neopixel driver in C with a live-calculation of the pulses as has been done in FastLED: https://github.com/FastLED/FastLED/blob ... mt_esp32.h
The downside to that is that you can't use the current RMT implementation with that, because it requires you to use your own interrupt handlers. That would mean the driver would completely block the RMT and you couldn't use the other channels for anything else.
Implementing that shouldn't be that hard when you use FastLED for reference...
The downside to that is that you can't use the current RMT implementation with that, because it requires you to use your own interrupt handlers. That would mean the driver would completely block the RMT and you couldn't use the other channels for anything else.
Implementing that shouldn't be that hard when you use FastLED for reference...