2 0
Read Time:5 Minute, 37 Second

I have a duet 2 powering a CNC router, the router itself however is not attached to the duet and so needs mains power and to be manually switched on. The model I have is a workbee that has 1.5m x 1.5m axis.

workbee CNC router

This blog entry shows the steps needed to make the router power controlled by the Duet.

What you need: A relay that is switched by DC current and switches on a mains power line and is rated with enough amps for your router. Dupont or other forms of connector to attach the relay to the duet board (3 wires minimum). The relay should use 5v or 3.3v dc for the VCC pin

One of the 2 channels wired on mains side

This is the relay I got, it has 2 channels meaning it can power two different circuits independent of each other, In this example I only use one but I will attach both to the duet.

The middle pin on the mains side is the live input, the left unused pin is for a circuit that is powered when the relay switch is off, the right one, the one I use is for when the relay switch is on. The neutral and earth cables are just wired to each other (n to n, e to e) so that the relay is in effect a single pole switch in the live cable.

This setup involves wiring using mains current, if you are not comfortable with doing electrical connections then get someone who is to do it for you. Personally I think it’s easy, but I take no liability should you cause any property damage or death by attempting these actions. You should also check that the pins I used for the low voltage connections are they same on your specific model of DUET these may change over time and you may need to use a different set of pins (you need 1-2 GPIO pins, 1 VCC pin and 1 GND pin if using the same relay I use)

A visual (and poorly drawn) summary of the main wiring

at the bottom right of the image there are 4 pins for the relay control, these are GND, R1, R2 and VCC. In my case the voltage (VCC) should be 5v, and R1 is for one of the channels and R2 is for the other, I only really need one of these pins but will attach both to the duet.

relay with 4 dupont connectors attached

In my case, the router is still under warranty and so instead of cutting the router cable I wired the relay to go an extension cord and I plug the router into that, also allowing me to attach future dust extractor to the same circuit (providing it keeps under the relays rated 10 amps)

Attaching to the duet involves finding some pins that can act as a GPIO pin and you are not currently using. The table https://duet3d.dozuki.com/Wiki/Duet_2_Pinout_table is very handy in determining this. For the moment I have opted for fan1 and fan2 since I only use the ‘always on’ fan ports for cooling.

The DUET wiring guide for my version is here https://duet3d.dozuki.com/Wiki/Duet_Wiring_Diagrams and shows you where each pin is

Now, I need a 5v connection, a GND connection and 1 or 2 GPIO pins. from the above I use the two right most pins on the expansion board and the two leftmost pins from fan1 and fan2 (near the middle of the board)

R1 and R2 wires from relay attached to left pin on fans 1 and 2
relay VCC (yellow) and GND (brown) attached to last column on duet extension port
Red rings show the two areas we are making connections to.

It’s hard to get decent images of the pins connected since they are obscured by all the other wires but they are easy enough to connect using dupont connectors. It is important that you use the left most pins of the fan not the right most one. The left pin is the GPIO pin, the right one is the fan voltage.

Now it is worth noting that by default the fan is NOT available for GPIO uses, it is there for passing power to a fan. The useage of the pin needs to be set each time you power on the board.

After you have the cables connected as you need them you power on the duet board.

The command M106 P1 I-1 can be sent to the board and this switched fan 1 from being a fan to being a GPIO pin (P2 switches fan 2)

Now that you have your chosen GPIO pin available you can set it ‘on’ with the command M42 P21 S255, thus switched Pin 21 which is fan 1 on.

The command M42 P21 S0 switches it off.

When it is on the relay activates and allows mains power to flow through the mains side of the relay, when it if off the flow of current stops.

So if you set the fan GPIO on board startup (in config,g) and you switch the pin on within your job code and switch it off at the end of your job gcode, you should be able to have your router start automatically by simply leaving it’s internal switch on all the time and controlling the flow of mains current.


M106 P1 I-1  ; Switch fan 1 to GPIO 
M106 P2 I-1  ; Switch fan 2 to GPIO
M42 P21 S0   ; turn off any relay on fan 1
M42 P22 S0   ; turn off any relay on fan 2

You would just add something like the above to your config.g file and save it

config.g file changes to enable GPIO and make sure router is off on power up

As well as all of the above I have a paneldue touchscreen attached to my workbee now. I have created two macros, one with the router on command and one with the router off command so that in the macro screen I can switch the router on and off for checking without needing to have a web browser open.

PanelDue screen showing macros from duet card

Parts used in this setup:

2ch relay case (3d printed) https://www.thingiverse.com/thing:1535155

Relay used – https://www.amazon.co.uk/gp/product/B01H2D2RI0/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

Dupont connectors (you need ones with female ends)

https://www.amazon.co.uk/gp/product/B01EV70C78/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

About Post Author

raymond

Been developing software for 40 plus years, started with Apple ]['s moved on to a variety of mainframes, PC's, Atari ST/Falcon, Psion's then onto more web related stuff (when there was an internet) and mobile apps (Xamarin.Forms) for IOS and Android.
Happy
Happy
100 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply