IronOS icon indicating copy to clipboard operation
IronOS copied to clipboard

WS2812B RGB mod for Pinecil V2

Open doegox opened this issue 1 year ago • 8 comments

Hello,

Here is a little mod to add a WS2812B to a Pinecil V2. Obviously, it works better with the transparent shell!

Pinecil V2 has a free GPIO_12 accessible through TP10. I'm using it to drive a WS2812B and let the color logic already present for the MHP30 do its magic:

  • green when temperature is safe (< 55°C)
  • pulsing red when heating
  • solid red when desired temperature is reached
  • orange when cooling down (appears white on the video due to white balance)

https://github.com/Ralim/IronOS/assets/60773/ebb3e113-932a-44c1-898b-29e0118a8e5f

Electrical setup:

  • WS2812B requires a Vdd between 3.5 and 5.3V and Vih (high level of input signal) must be at least 0.7Vdd
  • GPIO levels are 3.3V
  • The 5V rail is actually max 4.6V

So we can directly power the WS2812B on the 5V rail and command it with the GPIO without need for a level shifter, or for a Zener diode to clamp Vdd.

Screenshot from 2023-07-09 23-46-50

  • Vss(3) is connected to GND, e.g. on the U10 pad mentioned and illustrated here
  • Vdd(1) is connected to the "5V" rail, e.g. on the capacitor mentioned and illustrated here
  • Din(4) is connected to TP10

Connections are made with 0.1-mm enameled wire and isolated with UV glue to avoid any shortcut (my WS2812B is not attached and could move around)

Patch is in a branch of mine for now: https://github.com/doegox/IronOS/tree/pinecilv2_ws2812b and the changes are visible in this commit The driver is heavily based on WS2812.h by Ralim for the MHP30, but adapted for the RISC-V. Timings are not super precise but, well, it works...

To compile with this feature: make firmware-EN model=Pinecilv2 ws2812b_enable=1

Have fun!

doegox avatar Jul 09 '23 22:07 doegox

nice mod but how do you solder the wires on the PCB when it is your only soldering iron?🤯

Lennervh avatar Jul 17 '23 12:07 Lennervh

I have a problem that the led flickers instead of pulsing when heating up

Lennervh avatar Jul 20 '23 19:07 Lennervh

Maybe my crude bitbang timings are not good enough for your WS2812B. You may try to monitor the signal with an oscilloscope and adjust the delay loops to be closer to the specs timings.

doegox avatar Jul 21 '23 15:07 doegox

I do not have an oscilloscope, is it possible to guess the values? Any idea what values i should try?

Lennervh avatar Jul 23 '23 10:07 Lennervh

no :( an oscillo is needed to measure precisely the duration of how and high pulses and then adapt code experimentally until durations correspond as close as possible to the ones expected by WS2812B. BTW are you sure LED is a WS2812B? Besides flickering the LED has the proper colors ? (green when plugged, red when hot, orange when cooling down)

doegox avatar Jul 23 '23 18:07 doegox

the colors are correct the LED is a WS2812B but i used TP14 instead of TP10, change the gpio number in the pins.h TP10 - TP14 should be available to use

Lennervh avatar Jul 23 '23 20:07 Lennervh

Should be... but I didn't test it. Could you test with TP10 instead? You made a change, the first thing is to see if that change is the source of the problem or not...

doegox avatar Jul 23 '23 20:07 doegox

TP11 and TP12 aren't usable as they're on the other side of a DNP

image

TP9 is usable though is under the screen, it is on the other side of the R42 DNP from TP11. I ended up going with TP9 after TP10 broke off during my hooking up an oscilloscope to it. Turns out the build system has changed significantly and passing build flags wasn't working like before so I was probing a pinecil which wasn't trying to light an LED - D'oh. Got there eventually. TP10 shall forever be missed. My old iron is not cut out for fine work.

After much pain I got the RGB working and it is great, thanks for your initial effort @doegox

I see no flickering and it works very nicely.

I rebased the commit and hardcoded the ws2812 support on for pinecil v2 to workaround the build system changes. https://github.com/t3chguy/IronOS/actions/runs/7573719952 has artifacts for if anyone else wants to hook it up to TP9, and https://github.com/t3chguy/IronOS/actions/runs/7573047803 for TP10.

20240118_131142 20240118_133217

(Pictures from before the TP10 disaster, and before I shortened the wires and removed most of the kapton)

t3chguy avatar Jan 18 '24 17:01 t3chguy