Can't get my NeoPixels to turn on

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Can't get my NeoPixels to turn on

Post by jimmo » Tue Apr 28, 2020 6:28 am

OutoftheBOTS_ wrote:
Tue Apr 28, 2020 6:12 am
From the googling that I have done this seems to be the most common method for creating neopixle timings. basically work out how many NOPs are needed to get correct timings. Although it gets the job done it isn't very flexible to be able change the timings or running on different CPU freq MCUs. You can see mine uses a timer to create PWM on a pin but an interrupt changes the duty and freq at the end of each cycle to update the next cycle to be what ever the timing are needed for next cycle. The advantage is that it is very easy to adapt from different MCU's and different timing LEDs. See this in my video from 9:50 to 10:50 https://www.youtube.com/watch?v=4NSNO7NJv5c&t=2s
For sure. I agree that it's definitely a better and more robust approach! Was mainly just providing the other links as an FYI for other work in this area.

One difficulty with timers though is that now the API becomes a bit more complicated because it doesn't just work on any pin. So coming up with a Python API might have some challenges, but definitely not impossible. This is the same reason why defining a machine.PWM API for stm32 is tricky.

FWIW, I tested both the cycle counter version and instruction counter versions across a wide range of frequencies (although the F0 version needs some work).

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Can't get my NeoPixels to turn on

Post by OutoftheBOTS_ » Tue Apr 28, 2020 6:42 am

jimmo wrote:
Tue Apr 28, 2020 6:28 am
One difficulty with timers though is that now the API becomes a bit more complicated because it doesn't just work on any pin. So coming up with a Python API might have some challenges, but definitely not impossible. This is the same reason why defining a machine.PWM API for stm32 is tricky.
I think something like Neopixel will have to have a slightly different API for each port of MP (I know this is exactly what MP is trying very hard to avoid) because it is so hardware related.

Code: Select all

WS2812B = const((0.4, 0.8, 0.85, 0.45))

timer = 4
channel = 1
timings = WS2812B

my_neopixel = NeoPixel(timer, channel, timings)
My method for STM32 would be better sorted to this type of API where the user selects the timer and channel rather than the pin.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Can't get my NeoPixels to turn on

Post by OutoftheBOTS_ » Tue Apr 28, 2020 10:45 pm

jimmo wrote:
Tue Apr 28, 2020 6:28 am
One difficulty with timers though is that now the API becomes a bit more complicated because it doesn't just work on any pin. So coming up with a Python API might have some challenges, but definitely not impossible. This is the same reason why defining a machine.PWM API for stm32 is tricky.
Maybe the API for these addressable needs to be moved to the correct hardware class for the port becuase they are so hardware related e.g

Code: Select all

WS2812B = const((0.4, 0.8, 0.85, 0.45))

#declaration for STM32 port
timer = 4
channel = 1
timings = WS2812B
my_neopixel = pyb.NeoPixel(timer, channel, timings)

#declaration for ESP32 port
pin = 4
RMT_channel = 1
timings = WS2812B
my_neopixel = RMT.NeoPixel(pin, RMT_channel, timings)

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Can't get my NeoPixels to turn on

Post by jimmo » Tue Apr 28, 2020 11:30 pm

OutoftheBOTS_ wrote:
Tue Apr 28, 2020 10:45 pm
Maybe the API for these addressable needs to be moved to the correct hardware class for the port becuase they are so hardware related e.g
Good question... I can see good reasons for both approaches. Would you be interested in writing up your findings on that PR I linked to before (it's still not merged yet, so open for discussion).

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Can't get my NeoPixels to turn on

Post by OutoftheBOTS_ » Wed Apr 29, 2020 12:25 am

jimmo wrote:
Tue Apr 28, 2020 11:30 pm
OutoftheBOTS_ wrote:
Tue Apr 28, 2020 10:45 pm
Maybe the API for these addressable needs to be moved to the correct hardware class for the port becuase they are so hardware related e.g
Good question... I can see good reasons for both approaches. Would you be interested in writing up your findings on that PR I linked to before (it's still not merged yet, so open for discussion).
Ha Ha I am a little scared to go commenting on github.

This forum is where the learner programmers hang out and github is for the real programmers.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Can't get my NeoPixels to turn on

Post by jimmo » Wed Apr 29, 2020 1:27 am

OutoftheBOTS_ wrote:
Wed Apr 29, 2020 12:25 am
Ha Ha I am a little scared to go commenting on github.

This forum is where the learner programmers hang out and github is for the real programmers.
I've seen your code and your video, you've spent a lot of time thinking about this and your comments are valuable. Just do it! :)

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Can't get my NeoPixels to turn on

Post by OutoftheBOTS_ » Tue May 05, 2020 11:03 pm

jimmo wrote:
Wed Apr 29, 2020 1:27 am
OutoftheBOTS_ wrote:
Wed Apr 29, 2020 12:25 am
Ha Ha I am a little scared to go commenting on github.

This forum is where the learner programmers hang out and github is for the real programmers.
I've seen your code and your video, you've spent a lot of time thinking about this and your comments are valuable. Just do it! :)
I have updated my driver a little to fix a slight glitch discovered by the ardunio guys it now runs better https://github.com/OutOfTheBots/STM32_N ... ter/main.c

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Can't get my NeoPixels to turn on

Post by OutoftheBOTS_ » Sat Aug 15, 2020 10:20 pm

jimmo wrote:
Tue Apr 28, 2020 6:28 am
OutoftheBOTS_ wrote:
Tue Apr 28, 2020 6:12 am
From the googling that I have done this seems to be the most common method for creating neopixle timings. basically work out how many NOPs are needed to get correct timings. Although it gets the job done it isn't very flexible to be able change the timings or running on different CPU freq MCUs. You can see mine uses a timer to create PWM on a pin but an interrupt changes the duty and freq at the end of each cycle to update the next cycle to be what ever the timing are needed for next cycle. The advantage is that it is very easy to adapt from different MCU's and different timing LEDs. See this in my video from 9:50 to 10:50 https://www.youtube.com/watch?v=4NSNO7NJv5c&t=2s
For sure. I agree that it's definitely a better and more robust approach! Was mainly just providing the other links as an FYI for other work in this area.

One difficulty with timers though is that now the API becomes a bit more complicated because it doesn't just work on any pin. So coming up with a Python API might have some challenges, but definitely not impossible. This is the same reason why defining a machine.PWM API for stm32 is tricky.

FWIW, I tested both the cycle counter version and instruction counter versions across a wide range of frequencies (although the F0 version needs some work).
I am interested if my timer method of driving addressable RGB LEDs has gained any traction or it is just sitting on the back burner :)

Post Reply