Skip to content
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

PICO PIO testing with WS2812B #5

Open
Gustavomurta opened this issue Nov 2, 2023 · 4 comments
Open

PICO PIO testing with WS2812B #5

Gustavomurta opened this issue Nov 2, 2023 · 4 comments

Comments

@Gustavomurta
Copy link

Congratulations Patricio! I've already managed to do some tests on the Raspberry Pico with the WS281B example. Thank you.
https://github.com/tinygo-org/pio/tree/main/rp2-pio/examples/ws2812

But I found some things that need correction or change.

ws, err := piolib.NewWS2812(sm, ws2812Pin, 16000000)

This function lacked the definition of the Baud rate.
Through testing, I discovered the frequency of 16MHz (maybe it is based on Arduino?).
func NewWS2812(sm pio.StateMachine, pin machine.Pin, baud uint32) (*WS2812, error)

The color sequence appears to be incorrect.
Based on the WS2812B datasheet, we can verify that the color sequence in the 24 bits is green-red-blue and not RGB.
https://cdn-shop.adafruit.com/datasheets/WS2812.pdf

image

https://github.com/tinygo-org/pio/blob/main/rp2-pio/piolib/ws2812.go

func (ws *WS2812) SetRGB(r, g, b uint8) {
	color := uint32(r)<<16 | uint32(g)<<8 | uint32(b)
	println("r", r, "g", g, "b", b)
	ws.sm.TxPut(color)
}
@Gustavomurta
Copy link
Author

If you find it convenient to make changes to faithfully adapt the bit time specifications (+- 150ns):

WS2812B:

T0H = 400ns / T0L = 850ns
T1H = 800ns / T1L = 450ns

image

My measurements with logic analyzer:

T0H = 500ns / T0L = 458 ns (can improve)
image

T1H = 875ns / T1L = 417ns (very good)
image

@Gustavomurta Gustavomurta reopened this Nov 2, 2023
@soypat soypat closed this as completed Dec 8, 2023
@soypat soypat reopened this Dec 8, 2023
soypat added a commit that referenced this issue Dec 8, 2023
@soypat
Copy link
Collaborator

soypat commented Dec 8, 2023

I've reverted the changes and moved all changes to a PR for better following of changes.

@Gustavomurta
Copy link
Author

Thank you Patrício!

@soypat
Copy link
Collaborator

soypat commented Apr 15, 2024

Latest main now contains changes that match the tinygo drivers implementation behaviour, please give it a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants