Duet3D Logo

    Duet3D

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Documentation
    • Order

    Control RGB Color or rutine via impulses

    Duet Hardware and wiring
    6
    12
    1049
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • AS-3D Druck
      AS-3D Druck last edited by

      Hello Guys,

      first of i got a Idea how i could control my RGB Led's via a Fan pin but i don't know how far others are with a maybe better Solution so i explain it.

      End of 2018 i got a arduino Nano with a few Led's and other stuff and i asked my self how i can control my RGB Led's.
      It should be possible to send fast impulses to a input pin of a controller that is programmed to handle those and turn the Led's on to Red or led them blink or what ever i want right?

      So i can create a Sequenz what those should do while printing or heating up the Hotend and Heatbed etc.
      I didn't tryed it yet but if the Firmware dosen't send a Error or something else while i turn on and off my Fan like crazy i will test it.

      Or is there a simpler way?

      Best regards
      AS-3D Druck / Andre

      1 Reply Last reply Reply Quote 0
      • dc42
        dc42 administrators last edited by

        I have come across 3 types of RGB LED strips:

        1. 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.

        2. 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).

        3. 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.

        Duet WiFi hardware designer and firmware engineer
        Please do not ask me for Duet support via PM or email, use the forum
        http://www.escher3d.com, https://miscsolutions.wordpress.com

        1 Reply Last reply Reply Quote 1
        • AS-3D Druck
          AS-3D Druck last edited by

          Thx, the DotStar look realy nice so i think i will wait until the Support from you're side is there. ☺

          Best regards
          AS-3D Druck / Andre

          1 Reply Last reply Reply Quote 0
          • fma
            fma last edited by

            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()
            

            Frédéric

            1 Reply Last reply Reply Quote 1
            • dc42
              dc42 administrators last edited by

              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.

              Duet WiFi hardware designer and firmware engineer
              Please do not ask me for Duet support via PM or email, use the forum
              http://www.escher3d.com, https://miscsolutions.wordpress.com

              1 Reply Last reply Reply Quote 1
              • fma
                fma last edited by

                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...

                Frédéric

                1 Reply Last reply Reply Quote 1
                • CrazyCreator
                  CrazyCreator last edited by

                  Any news about RGB Support from the Duet?

                  http://www.crazycreatorcube.com

                  dc42 1 Reply Last reply Reply Quote 0
                  • dc42
                    dc42 administrators @CrazyCreator last edited by dc42

                    @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.

                    Duet WiFi hardware designer and firmware engineer
                    Please do not ask me for Duet support via PM or email, use the forum
                    http://www.escher3d.com, https://miscsolutions.wordpress.com

                    celulari 1 Reply Last reply Reply Quote 1
                    • CrazyCreator
                      CrazyCreator last edited by

                      Great news, thanks for your work

                      http://www.crazycreatorcube.com

                      1 Reply Last reply Reply Quote 0
                      • celulari
                        celulari @dc42 last edited by

                        @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?

                        dc42 1 Reply Last reply Reply Quote 0
                        • dc42
                          dc42 administrators @celulari last edited by

                          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.

                          Duet WiFi hardware designer and firmware engineer
                          Please do not ask me for Duet support via PM or email, use the forum
                          http://www.escher3d.com, https://miscsolutions.wordpress.com

                          tekstyle 1 Reply Last reply Reply Quote 0
                          • tekstyle
                            tekstyle @dc42 last edited by tekstyle

                            @dc42

                            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?

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post
                            Unless otherwise noted, all forum content is licensed under CC-BY-SA