How do you connect a LED RGB strip



  • I have a 24 volt Duet wifi with duex5.
    I have a RGB 24 volt strip with the idea of using conditional gcodes to change colour dependant on the printer state.
    The strip has 4 wires red, green, blue and black, I assume that the 3 colours are 24volt and the back is a common return 0volt.
    I thought of connecting to the duex5 heater 3,4,and 5.

    M950 F3 C"exp.heater3" Q500 ; RGB Red
    M106 P3 C"RGB Red" ; set RGB Red PWM
    M950 F4 C"exp.heater4" Q500 ; RGB Green
    M106 P4 C"RGB Green" ; set RGB Green PWM
    M950 F5 C"exp.heater5" Q500 ; RGB Blue
    M106 P5 C"RGB Blue" ; set RGB Blue PWM

    I'm not sure but isn't the PWM on the negative side with a fixed 24volt on the positive.
    Because I only have a common return, all 3 colours would be on.

    Is there any way to connect this strip to the duet or duex5 so that I can control each colour separately?


  • administrators

    @appjaws said in How do you connect a LED RGB strip:

    The strip has 4 wires red, green, blue and black, I assume that the 3 colours are 24volt and the back is a common return 0volt.

    That would be a "common cathode" LED strip. The other type is "common anode" which uses a common positive rail, and could therefore be driven directly from heater or fan outputs on the Duet or DueX if the voltage is compatible.

    To drive a common cathode LED strip, you could use a P-channel mosfet and a couple of resistors to drive each of the three positive connections.



  • @dc42 said in How do you connect a LED RGB strip:

    LED strip. The other type is "common anode"

    Thanks @dc42 I have tested the strip and the black wire is the common anode so I should be able to drive via the duex5.
    Are my M950 and M106 entries correct?


  • administrators

    @appjaws said in How do you connect a LED RGB strip:

    Are my M950 and M106 entries correct?

    You can drive them that way; but personally I would use M950 P commands to configure the ports as GPIO. then then M42 commands to control them; unless you want them to change colour automatically with temperature, in which case leave them configured as fans.



  • I do want the colours to change, depending on the printer state, controlled by conditional macros.

    I am totally confused, can't get it to work at all
    @dc42 said "You can drive them that way; but personally I would use M950 P commands to configure the ports as GPIO. then then M42 commands to control them; unless you want them to change colour automatically with temperature, in which case leave them configured as fans."
    so I changed my settings to:-
    ; LED Lighting
    M950 P3 C"exp.heater3" Q500 ; Allocate GPIO port3 to LED Red
    M950 P4 C"exp.heater4" Q500 ; Allocate GPIO port4 to LED Green
    M950 P5 C"exp.heater5" Q500 ; Allocate GPIO port5 to LED Blue
    I physically connected the LED strip to E3:E4 :E5 Heater on the duex5
    Tried M42 P3 S1 but it didn't work

    QUESTION where do I physically connect the LED strip?

    Then decided to try the original
    M950 F3 C"exp.heater3" Q500 ; RGB Red
    M106 P3 C"RGB Red" ; set RGB Red PWM
    M950 F4 C"exp.heater4" Q500 ; RGB Green
    M106 P4 C"RGB Green" ; set RGB Green PWM
    M950 F5 C"exp.heater5" Q500 ; RGB Blue
    M106 P5 C"RGB Blue" ; set RGB Blue PWM
    but again nothing happened

    I then connected to the Fan3, Fan4 and Fan5 connections and changed the settins to:-
    M950 F3 C"exp.fan3" Q500 ; RGB Red
    M106 P3 C"RGB Red" ; set RGB Red PWM
    M950 F4 C"exp.fan4" Q500 ; RGB Green
    M106 P4 C"RGB Green" ; set RGB Green PWM
    M950 F5 C"exp.fan5" Q500 ; RGB Blue
    M106 P5 C"RGB Blue" ; set RGB Blue PWM

    on the duex5 but again nothing worked

    QUESTION is exp.fan3 valid? If not what should it be?
    You can see how confused I am so please outline the correct config entries and where should the LED strip be connected on the duex5


  • Moderator

    @appjaws Pin names: https://duet3d.dozuki.com/Wiki/RepRapFirmware_3_overview#Section_Pin_names_for_Duet_2_WiFi_Ethernet

    exp.fan3 isn't valid, should be duex.fan3. 'exp' is for expansion header (no Duex connected, usually).

    If you have a Duex connected, best to use the 'duex.[pin]' name and connect it to the Duex. You many need to invert the output though, with '!', as I think outputs on Duex are inverted. So I'd try:
    M950 F3 C"!duex.fan3" Q500 ; RGB Red
    M106 P3 C"RGB Red" ; set RGB Red PWM
    M950 F4 C"!duex.fan4" Q500 ; RGB Green
    M106 P4 C"RGB Green" ; set RGB Green PWM
    M950 F5 C"!duex.fan5" Q500 ; RGB Blue
    M106 P5 C"RGB Blue" ; set RGB Blue PWM

    Ian


  • administrators

    @appjaws said in How do you connect a LED RGB strip:

    M950 P3 C"exp.heater3" Q500 ; Allocate GPIO port3 to LED Red
    M950 P4 C"exp.heater4" Q500 ; Allocate GPIO port4 to LED Green
    M950 P5 C"exp.heater5" Q500 ; Allocate GPIO port5 to LED Blue

    The correct pin names are "duex.heater3" and so on. "exp.heater3" is for when you are connecting something directly to the expansion connector.



  • Thanks for the reply @dc42.
    Do I use the heater connections or the fn connections?
    Do I need any other entries in config.g?


  • administrators

    @appjaws said in How do you connect a LED RGB strip:

    Thanks for the reply @dc42.
    Do I use the heater connections or the fn connections?
    Do I need any other entries in config.g?

    If you use pins "duex.heater3" etc. in your M950 commands then use the heater outputs on the DueX5. Alternative, use pins "duex.fan3" etc. and then use the fan outputs.



  • SUCCESS 👍 😀
    I now have LED lights changing dependant on the printer state, thanks @dc42.
    However, I had to use the Fan connection option because I couldn't get the heater connections to work.



  • hello, i need some help to with the rgb leds, can u explain me where did u connect the rgb leds on the expansion pins and what did u put on config.g file to activate them ? tnx i appreciate a lot


Log in to reply