Making the power supply switchable

There are defined commands in gcode to control an ATX power supply. The commands are

* **M80** Turn the power supply on
* **M81** Turn the power supply off

## Instructions for the MKS board

These instructions are specific to the MKS board that is used on the 24 volt K280s. I can't speak to other printers because I am not familiar with them, What these commands actually do is to turn a power supply pin, a 5 volt control circuit, on and off. If you have done any arduino programming, these should be well known to you. There are a group of pins adjacent to the endstop sensors, immediately adjacent to the Z min sensor that is commonly used for the auto leveling sensor. They are marked on the silkscreen *A11, A12, D11, D12.* The ones closest to the edge of the board, marked D12, are the ones you want.

With D12 closest to you, set your voltimeter to DC volts and if it is not autoranging, set it to an appropriate scale for 5 volts. From left to right, let us imagine that the pins are numbered, *1, 2* and *3.* If you (carefully) hold a DC voltimeter to the 1 and 3 leads with the positive (generally red) lead on 3 and the ground (generally black) on 1. You should see 5 volts. Have someone run the M81 command, you should see zero volts. Have someone run an M80 command again, You should see 5 volts positive.

## Instructions for the RAMPS board

(Please, someone who knows, edit this article and fill this in)

## High Voltage Hookup

The usual warnings apply, *HIGH voltage is dangerous. If you have not done something like this before, don't do it. Don't touch anything until you have unplugged it. Unplug all voltages before going near high voltage. Double check everything. If you have doubts at all, get an experienced person or an electrician to help you. I disclaim all liability for your mistakes or mine. I am not an expert, I have just done this a couple of times.*

So you need an SSR, like this one: https://www.amazon.com/gp/product/B0087ZTN08 25 Amps should be enough for anything you can put on a branch circuit. The pins on the circuit board are typical 0.1" spacing I happened to have a wire that was 6 inches or so long with female pins on one end and male on the other. I attached the females to pins one and three (MKS), and I put the males under the control screw terminals. When I sent the **M81**, the control light went out. When I sent **M80** the light came on.

Now for the high voltage hookup. Normally, you would be sure to install the SSR on the hot lead, not the neutral. But the HE3D printer does not use a polarized or 3 prong plug. So there is no way to be sure of which lead you are breaking. Be careful. Consider changing the plug to a polarized or a three prong style plug. If you are not in the USA or someplace that uses USA standards you must know what your line cord standards are. If one of your power leads is close to ground potential you should install the switch in the other one. You need a 25cm wire (at least) of the gauge that carries light loads in your region, for the USA this would be 18 or maybe 16 gauge with the ends tinned about 2cm. Remove the line cord from the power supply (unplug!!! first) and remove about a foot of the outer insulation only. Install one of the high tension leads from the line cord to one of the power supply high voltage leads (where you just removed the line cord from). Install the other line cord lead to one of the high voltage leads on the SSR. Now take your wire, Connect one end to the remaining controlled lead on the SSR and the other end to the last unused high voltage lead on the power supply.

So, do you get the theory? The SSR acts line a line switch, and detaches the high voltage power circuit from the power supply. You send a M80, the power supply turns on, you send a M81 the power supply turns off. If the power supply is on, sending an M80 does nothing.

Huh? How do you send an M80 to the arduino when the power supply is off?

Simple. The arduino can run from the power supply, or it can run from five volts supplied through the USB port. So you supply five volts by hooking the USB cable to something - a wall charger, or a laptop or a Raspberry pi. If you use Octoprint on the Raspberry Pi, you can send the commands from Octoprint.

So how do you use this? Every slicer has a prolog and an epilog area for GCODE, I use this for prolog in kisslicer:

```
; Turn the power supply on.  If the power is off, 5V is a must
M80
; [mm] mode
 G21
 ; absolute mode
 G90
 ; Heated bed control
M140 S<BED> F1
; Home
 G28
 ; Absolute E
 M82

```

Simple. Here is the epilog gcode:

```
; Maybe move to some safe location?
;G1 F1200 X0 Y0 Z<Z+50>
; Just home instead
G28
; Wait 30000 milliseconds (30 seconds)
G4 P30000
; Turn the external power supply off now.  What fun!
M81

```

And that is it. I should use a G4 when I turn the power on to allow things to settle, maybe 2000 milliseconds.

If you can expand on this, please do so.