Control RGB Color or rutine via impulses
-
I have come across 3 types of RGB LED strips:
-
Strips with separate 12V or 24V inputs for the red, green and blue LEDs. You would need to use 3 fan and/or heater outputs to control them. one for each colour.
-
5V LED strips with a single input and individually addressable LEDs, using WS2812B or SK6812 LEDs and associated serial protocol (Adafruit Neopixel and similar). These have very specific timing requirements and are not suitable for driving from a Duet (or any other system that has other real-time tasks to manage concurrently). You could use an Arduino Nano or similar to drive them and send it commands from the Duet (remember to level shift the control signal from 3.3V to 5V).
-
5V DotStar addressable LED strips. These use SPI protocol, which makes them much more suitable for the Duet. There is code to drive DotStar LEDs in the RepRapFirmware source, but currently it is not enabled for the standard Duet builds. You would need a buffer to level shift the SPI clock and data signals to 5V.
5V LED strips draw a lot of current, so you would generally need an external 5V power supply for them.
-
-
Thx, the DotStar look realy nice so i think i will wait until the Support from you're side is there.
-
David, it is possible to drive a WS2812 RGB led from SPI... Here is some Python code I used to drive a WS2812 strip from a Micropython board:
import math import gc from pyb import SPI def tsv2rgb(hue, saturation, value): """ See http://fr.wikipedia.org/wiki/Teinte_Saturation_Valeur#Conversion_de_TSV_vers_RVB """ S = saturation / 100. V = value / 100. Ti = int((hue / 60)) % 6 f = hue / 60. - Ti L = V * (1 - S) m = V * (1 - f * S) n = V * (1 - (1 -f) * S) if Ti == 0: red = V green = n blue = L elif Ti == 1: red = m green = V blue = L elif Ti == 2: red = L green = V blue = n elif Ti == 3: red = L green = m blue = V elif Ti == 4: red = n green = L blue = V elif Ti == 5: red = V green = L blue = m else: red = green = blue = 0 # Scale to 8 bits red *= 256 green *= 256 blue *= 256 return int(red), int(green), int(blue) def byte2bits(byte): b0 = chr(0x03) b1 = chr(0x0F) bits = '' mask = 0x80 while mask != 0: bits += b0 if (byte & mask) == 0 else b1 mask >>= 1 return bits def main(): spi = SPI(1, SPI.MASTER, baudrate=6400000, polarity=0, phase=1) spi.send(chr(0x00)) buf = bytearray(10 * 3) n = 0 while True: pos = 0 while pos < len(buf): buf[pos], buf[pos+1], buf[pos+2] = tsv2rgb(0, 100, 100) pos += 3 data = ''.join(list(map(byte2bits, buf))) spi.send(data) gc.collect() n += 1 if __name__ == "__main__": main()
-
I looked into this early last year and came to the conclusion that although it would work, it wouldn't be possible to get the timing perfectly consistent, because even if you use DMA to drive the SPI, other concurrent activity such as DMA to the network interface would be liable to mess it up. That's why I decided to support DotStar instead. The DotStar driver is already working and one of our OEM customers is using it.
-
Well, I agree if you want to have a continuous stream of data, to make fast animations, but it works fine without the need of a DMA to control a few leds...
-
Any news about RGB Support from the Duet?
-
@CrazyCreator said in Control RGB Color or rutine via impulses:
Any news about RGB Support from the Duet?
Duet 3 main board MB6HC supports DotStar RGB LED strips.
-
Great news, thanks for your work
-
@dc42 said in Control RGB Color or rutine via impulses:
@CrazyCreator said in Control RGB Color or rutine via impulses:
Any news about RGB Support from the Duet?
Duet 3 main board MB6HC supports DotStar RGB LED strips.
Only duet 3??? Not possible with duet 2 wifi?
-
To drive them from Duet WiFi, you would need an adapter to buffer, gate and and level shift the SPI signals on the daughter board connector.
-
since it would require hardware either with neopixel or dotstar on the duet2 board. which way would be the easier route? is there a tutorial page with hardware to purchase and downloadable code to compile into arduino?