neopixel ws2812 3V to 5V transistor converter inverter din

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
Post Reply
User avatar
cederom
Posts: 16
Joined: Tue Oct 26, 2021 1:37 am
Contact:

neopixel ws2812 3V to 5V transistor converter inverter din

Post by cederom » Fri Nov 26, 2021 2:46 am

Hello world :-)

I am using WS2812 and NeoPixel module with ESP32 chips. In order to drive 5V LED input with 3V MCU GPIO I am using transistor (N-MOS). But that transistor inverts logical signals of the gpio pin. Sure I can use second complementary transistor but this should be also fairly simple to solve in firmware.

My question is does NeoPixel module support inverted logic?

If not is this because there are any objections or no one just wrote it yet?

This seems pretty popular and minimalistic solution..?

Any hints welcome :-)
--
CeDeROM, SQ7MHZ, https://www.tomek.cedro.info

User avatar
cederom
Posts: 16
Joined: Tue Oct 26, 2021 1:37 am
Contact:

Re: neopixel ws2812 3V to 5V transistor converter inverter din

Post by cederom » Fri Nov 26, 2021 4:12 am

I noticed that:
  • neopixel module uses hardware dependant implementation of machine_bitstream() so we do not want to touch these.
  • it is possible to use 255-n RGB values to get valid color even when input is inverted.
  • the first LED does not seem to reset correctly, it stays dark, but because it is WS2812B is seems to reshape signal for the next LEDS so they light as expected.
  • question is how to make also first LED light as expected with inverted input :-)
--
CeDeROM, SQ7MHZ, https://www.tomek.cedro.info

User avatar
cederom
Posts: 16
Joined: Tue Oct 26, 2021 1:37 am
Contact:

Re: neopixel ws2812 3V to 5V transistor converter inverter din

Post by cederom » Fri Nov 26, 2021 6:36 am

  • It seems that just pin.value(1) needs to be added before and after bitstream() call in neopixel.write() so DIN stays low on bitstream start and all LEDs works fine including the first one (yes I saw the "sacrifice the first led" kind of ideas on the internets) :-)
  • DIN inversion can be achieved by swapping timings definitions and none underlying MCU driver code needs to be touched :-)
  • I will provide PR on GitHub for verification by wider audience :-)
--
CeDeROM, SQ7MHZ, https://www.tomek.cedro.info

User avatar
cederom
Posts: 16
Joined: Tue Oct 26, 2021 1:37 am
Contact:

Re: neopixel ws2812 3V to 5V transistor converter inverter din

Post by cederom » Sun Jan 16, 2022 1:40 pm

Just for reference here is the inverted neopixel code PR: https://github.com/micropython/micropython/pull/8037
--
CeDeROM, SQ7MHZ, https://www.tomek.cedro.info

Post Reply