8000 Neopixel data timing too slow on Samd51 M4 boards · Issue #1083 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Neopixel data timing too slow on Samd51 M4 boards #1083

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

Closed
Thomasinator opened this issue Aug 3, 2018 · 24 comments
Closed

Neopixel data timing too slow on Samd51 M4 boards #1083

Thomasinator opened this issue Aug 3, 2018 · 24 comments

Comments

@Thomasinator
Copy link

I discovered a problem driving a neopixel strip from adafruit. Whatever color, even all off, i send to the strip. The leds appear in a flickering full white. Driving a neopixel ring with the same script works fine.

I have an ItsyBitsy M4 with CircuitPython 3.0.0 installed and the Library bundle 3.x 20180802 on it.
I used the example from here

At work i could measure the output on D5 with an oszilloskop and the output is at a frequency at around 280 kHz. Normally it should be at 400 or 800 kHz.
Driving it with an Arduino UNO and the C-Library for NeoPixel from Adafruit produces an Output of 800 kHz and the Strip is working fine.

In the descriptions of the strip and the ring i have found only one difference, the ring could be with WS2812 or SK6812, the strip is only made from SK6812.
So it could be i have a ring with WS2812 and they work with the 280 kHz signal fine, and my strip is from SK6812 and won't work with the 280 kHz signal

So i think something is wrong with timing the output, or processor is running at lower frequency than it should.

Or am i make something wrong?

Adafruit NeoPixel Digital RGBW LED Strip - Black PCB 60 LED/m
PRODUCT ID: 2837
NeoPixel Ring - 12 x 5050 RGBW LEDs w/ Integrated Drivers - Natural White - ~4500K
PRODUCT ID: 2852

@jerryneedell
Copy link
Collaborator
jerryneedell commented Aug 3, 2018

The strip is RGBW so the script needs to be modified to handle 4 values per pixel.
Add bpp=4 to the pixels=... keywords
Also modify wheel to return 4 values for the RGBW settings

@Thomasinator
Copy link
Author

Thanks,
i have considered this an initialized it with bpp=4 and pixel_order=(1,0,2,3).
But that does not explain why the frequency of the data is around 280 kHz

@Thomasinator
Copy link
Author

i have also tested this example form here
http://circuitpython.readthedocs.io/en/latest/shared-bindings/neopixel_write/__init__.html#module-neopixel_write

And there is also an output freqency of 280 kHz, seems to me something is wrong with the basic timing generating the output for the neopixel

@jerryneedell
Copy link
Collaborator

Hmmm. I’ll try to reproduce this later today.

@jerryneedell
Copy link
Collaborator
jerryneedell commented Aug 3, 2018

Did you try pixel_off=bytearray([0,0,0,0])

@Thomasinator
Copy link
Author

Yes,
i have changed the example to toggle between green (0,255,0,0) and off (0,0,0,0) every second.
But the strip keeps beeing something full white flickering

@jerryneedell
Copy link
Collaborator
jerryneedell commented Aug 3, 2018

FYI -- I connected an 8 LED strip https://www.adafruit.com/product/2869 to my itsybtsy m4 express and I do see the 280kHz data rate, but the strip works fine on both my itsybitsy m4 and feather m4 -- note that this test

import board
import neopixel_write
import digitalio
import time

pin = digitalio.DigitalInOut(board.D13)
pin.direction=digitalio.Direction.OUTPUT
pixel_off=bytearray([0,0,0,0])
pixel_on=bytearray([0,255,0,0])
while True:
    neopixel_write.neopixel_write(pin,pixel_off)
    time.sleep(1)
    neopixel_write.neopixel_write(pin,pixel_on)
    time.sleep(1)

toggles the first pixel on the strip RED (not green) but the doc indicates that ignores the pixel ordering, so I think this is expected.

@jerryneedell
Copy link
Collaborator

also - FYI - I am powering the strip from the Itsybitsy 3V output and have it connected to D13.

@jerryneedell
Copy link
Collaborator
jerryneedell commented Aug 3, 2018

ah -- interesting -- I can reproduce your issues if I power the strip from VUSB (or VHi) and use D5 for the data signal!!

@dhalbert
Copy link
Collaborator
dhalbert commented Aug 3, 2018

Thanks for detecting this problem. We'll look at the timing code. There are some loops that were calibrated to give the correct timing, but it seems like something is wrong with the measurements. Also, there is a instruction/data cache on the M4, and there may be an issue with its state when the neopixel_write code runs.

@jerryneedell
Copy link
Collaborator

sorry - hit wrong button -- did not mean to close.
@dhalbert Any idea why it would depend on the voltage level used.

@dhalbert
Copy link
Collaborator
dhalbert commented Aug 3, 2018

might be waveform shape, rise/fall time on the level converter vs not

@jerryneedell
Copy link
Collaborator
jerryneedell commented Aug 3, 2018

OK -- there are some big negative spikes when using 5V that are not there at 3V. It's not clear to me that the data rate is the issue. Its something to look at , but may not be related to the performance. My quick glance at the neopixel data sheet referred to maximum rates, but was less clear about minimum rates.

never-mind -- it does say minimum 400 for the WS2812, but it is not specified for the SK6812

@tannewt
Copy link
Member
tannewt commented Aug 8, 2018

@Thomasinator could you test a new build from here: https://adafruit-circuit-python.s3.amazonaws.com/index.html?prefix=bin/itsybitsy_m4_express/ Its commit 2e80.

@Thomasinator
Copy link
Author
Thomasinator commented Aug 8, 2018

Short test, the NeoPixel Ring 12 works fine, the strip same failure.
I'll try to measure the signals tomorrow at work, frequency and spikes. Maybe a collegue helps me to calculate an RC circuit to supress the spikes to see if it works better then.

@Thomasinator
Copy link
Author
Thomasinator commented Aug 9, 2018

I did some measurements, the frequency is now 632 kHz for sending an OFF (0,0,0,0) to a pixel and 700 kHz for sending full ON (255,255,255,255). The example with green blinking is working for the ring but not for the strip. To supress the positiv/negativ spikes i use a 150ohm series resistor, the signal is clear as of a 3,3V digital output pin but with the 5v level.

Here the measured timing and the deviations to the datasheet timings

                 WS2812      SK6812
              nom.   dev.    nom.  dev.
T0H   480ns  350ns + 80ns   300ns +180ns
T1H   780ns  700ns + 80ns   600ns +180ns
T0L  1100ns  800ns +300ns   900ns +200ns
T1L   620ns  600ns + 20ns   600ns + 20ns

nom. = Time as described in datasheet
dev. = Deviation measured time to nom.

I attached a screenshot from oscilloscope after the 150ohm resistor at first neopixel from strip.
The first bit is 1, the second a 0 to see the timing of both. Hope it helps.

scope_5

@Thomasinator
Copy link
Author
Thomasinator commented Aug 9, 2018

Same code, but changed Output-Pin from D5 to D7 and power the strip from 3,3V, not 5V-USB. Works fine.
scope_7

@dhalbert
Copy link
Collaborator
dhalbert commented Aug 9, 2018

Yes, we recommend that the data signal voltage match the supply voltage, and use a level converter if necessary. I don't think what you're seeing is a timing issue now - it's related to trying to use the devices at the spec margins. That's one reason we added a 5V logic output pin to the Itsy Bitsy boards.

EDIT: apologies, never mind, I didn't read far enough back.

@Thomasinator
Copy link
Author

Sorry for the closing, tapped wrong on Smartphone

@tannewt
Copy link
Member
tannewt commented Aug 10, 2018

Its weird that its still not working for you. I reproduced the problem and it went away when I tightened up the timings. I don't expect it to be 800khz though since its being bitbanged.

Would you mind experimenting with the numbers yourself like I did in b0dd645 ?

Thanks!

@Thomasinator
Copy link
Author

Sorry, I don't know how to do these changes and get an .uf2 file to update my ItsyBitsyM4.

@tannewt
Copy link
Member
tannewt commented Aug 17, 2018

Instructions on building CircuitPython are here: https://learn.adafruit.com/building-circuitpython

I can't do much more myself since its fixed for me.

@jerryneedell
Copy link
Collaborator

PR #1132 worked on my ITSY BITSY M4 express -- but I did find that I had to improve my wire connections to get it to work reliably.

tannewt added a commit that referenced this issue Aug 21, 2018
SK6812 on 5v is pickier than WS2812 on 5v.

Hopefully fixes #1083.
@tannewt
Copy link
6D40 Member
tannewt commented Aug 23, 2018

I believe this is fixed. @Thomasinator please let me know if it's still an issue for you.

@tannewt tannewt closed this as completed Aug 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0