#49 Adding LED Lights to Duet 2 Wifi / Duex Expansion Board – Conditional G code

By | December 14, 2022

when the duet to Wi-Fi controller turns on a yellow LED light is power to indicate that the different axes are not honed I do this with conditional G code which I call into the conflict of G file in the system directory the lights are currently plugged into the PWM fan headers on the duet to Wi-Fi in this instance I'm using fan hannah0 for red one for yellow and two-foot warm white once all the axes are home and not before does the yellow LED light turn off and the warm white LED light turn on when in situ the warm white LED light will be under the country of my CNC machine and will be used to illuminate the waste board these LED lights accept a maximum of 12 watts I have to be careful when I write the code not to send the full 24 volts through the pins I also haven't quite worked out how to write a piece of conditional g code to turn the red light on while running the job so for that I simply put the correct code into my starting and stopping scripts that big clunky thing is a prototype for a dr white and gentle knife head mechanically it works but I haven't worked out how to control it during a job I suspect I'll make a video about that separately since my early experiment with the LED lights I decided to get a 24 volt RGB WW LED strip and to install that onto the heat tunnels of the Joe x5 expansion board I'm doing this because all but two PWM fan headers on the duet 2 Wi-Fi and all on the GX expansion board temporarily turned on upon reset this is a hardware feature and as I was informed by a user called error on the duet forum fan header zero and to have pulldown resistors on the gate to ensure they remain off and less driven but the others are normally for hot hand fans so that behavior is a safety feature which would otherwise call the hot end fan if the system is reset and somehow prevented from reading the config file as the fan would remain on in this instance we just see the LED flashing it doesn't look particularly creative lights flash randomly when any piece of electronics turns on so I'm going to move this over to the heat terminals now okay so show you how you're going to wire this up because I'm going to do is cut a piece of wire I'm using a common anode LED strip which are more common and can be connected directly to the controller the black wire goes to the voltage in terminals via a small section of terminal block and the other white blue red and green wires go to the various grounds I'll be using heat terminal e 2 e 3 E 4 and e 5 which are PWM enabled so I'll be able to control the brightness of the LED lights that's wide in so these different color wise the green red blue and white may not correspond with the colors on the LED so it depends where you buy them and so on after wiring everything up I can reboot the controller and we can see that the lights don't flash I'm now going to update my config dot G file to include the terminal pins associated with the new LED strip okay here goes so this is the web interface that I'm using in the system files I can go to my config file and there's quite a bit of stuff here I'll talk about this in more detail in different videos but the bit that I'm going to work on is this section which is to do the LED strips I'm going to ignore these three up here and then I'm going to change the settings for these ones here and I'm swapping from the do X dot fan free to fan six headers and I'm going to use the e to heater and this one will be the e free heater a for heater the five and you can only go up to nine in this case I don't know what colors these correspond to so I'm gonna delete these and I'll check these in a second so I just described quickly what these commands do so m95 zero has to be used to set a port up so essentially if I don't have this command written in the config file without specifying the pin that pin won't be used for the most part unless it's of a neighborhood with another command my herd or something else once that's created I can then control it using the m42 command which is to switch I open the P number refers to kind of quick reference to what is been conferred to in the pin it's like a shortcut and s sets the pin either on or off and if it's a PWM enabled terminal you can then go through all the varying voltages that are available so in my case I'm using a 24 volt power supply to power the control board and the maximum bolt that can come out of these headers is 24 volts if I write s 0.5 it should be 12 volts although do check it with a voltmeter found that is not exactly doesn't exactly correspond like that so now I'm going to save this and then I'm going to check p6 to p9 to see what colors they correspond to and just to make a note that I'm using the latest version of the RepRap firmware which is 3.0 1 RC 6 so it's a little bit different from version 2 where you have to define the pins by their names if I drag the overview this is the RepRap firmware version 3 overview you can see the pin names for the duet to Wi-Fi the jus X and this is what you're referring to and these correspond with the diagrams so in this case this is the expansion board and e2 heater defined like that @ux e to heater or heat sorry you kind of got to use your imagination with how these are written and what information is available on the diagram I've not seen an overlay between the diagram of the boards and the pin names okay so m42 p6s 0.1 now it's green so I'll write a note of that I'm going to turn that off of an s 0 and P 7.1 that is white P 8.1 it's red V 9.1 is blue so to make yellow it's green and red p6s point one so I can just go direct for brightness so you see what that's like I'll keep it low so we don't dazzle and red so P eight and that it's supposedly yellow it's not a great yellow this is a better yellow here but this is a dedicated yellow LED so I wonder if you can get these things made up so they have the wavelength of light that you actually want so the other thing I have in my config file all the way down here is a p98 command which refers to a conditional one G macro file which is where I've written a piece of conditional code and I'm now going to show you the updated conditional G code which controls the LED light strip plugged into the GX expansion board it's based on an example in the g-code meta commands page on the duet website I start with setting all the headers controlling the LED lights to off with the m42 and s0 command I then write a conditional construct starting with if followed by apostrophe moved axes 0 domed with two vertical lines and then followed by pretty much the same text but a different number which corresponds to the different axes the behavior works in the following way if ax is 0 1 2 & 3 are not home turn on the yellow LEDs elfs turn on the white LEDs and I found I had to write it this way so that all four axes had to be home before the warm white LEDs are turned on the apostrophe means a boolean not which is a logical prefix operator and inverts the upcoming inquiry I think it's an inquiry I don't really know what the right terms are I'm still getting my head around this type of programming but the next thing I want to do is either write a new conditional script expand the current one to detect when a job is running so the red LED turns on and the other LED lights turn off so I don't have to either use the post processor in vetrix to write m42 commands in the g-code script or what I actually do which is write the m42 commands in the star stop and pause dot G macros in the Joette system files so that's how I stored the LEDs on to the QA tool I fly and the direct expansion board and the example of conditional G code I've used to you control them I'm going to leave this video here and I hope you found that interesting please remember to sacrifice the thumb and if you haven't done so already subscribe and press the power button for notifications of new videos thanks again for watching and you'll catch me in the next one [Music]

As found on YouTube