Skip to content

Control your printer's ATX PSU through a RAMPS board using OctoPrint

Dennis P edited this page Mar 24, 2018 · 23 revisions


Step by step instructions

References and notes


The idea

Basically, if you are using the ubiquitous Arduino Mega 2560 + RAMPS 1.4 combo to interface with your printer hardware, and powering your setup with an ATX power supply, there is a simple way to switch on/off your printer with OctoPrint, without the need for any extra relays or electronic circuits.

The theory

One of the motherboard connector pins of the ATX power supply is a power-on input (PS_ON#, green wire) which must be driven low to switch on (soft-start) the power supply. Conversely, driving this signal high or leaving it open (note: it is pulled high internally in the ATX power supply itself) switches off the power supply, except for the +5V standby (+5 VSB, purple wire) line which always supplies +5V to the motherboard as long as the ATX power supply is electrically connected to a mains power source. BTW you can use this +5 VSB line to power a Raspberry Pi running Octoprint, which will in turn power the Arduino Mega 2560 through the USB interface (there are some caveats, see note at the bottom of this page).

ATX PSU motherboard power connector

The RAMPS 1.4 board provides a PS-ON pin which is controlled by one of the Arduino Mega 2560 pins. Connecting this pin to your ATX power supply PS_ON# input will allow OctoPrint to switch on/off (soft-start) the power supply by sending the appropriate code to the firmware running on the Arduino Mega 2560 - if the installed firmware is properly configured, of course.

Ramps 1.4 schematics Power section

In this HOWTO, I'll provide the instructions to properly connect the ATX power supply to the RAMPS 1.4 board and configure the Arduino firmware and OctoPrint so that it's easy (and safe) to switch on/off your printer with OctoPrint.

Note that for all this to work it is NOT necessary to make any internal changes to either the ATX power supply, your RAMPS board or your Raspberry Pi. All you need to do is to connect the proper wires and enable the correct options in the Arduino firmware and OctoPrint. In other words, the probability of smoke is low and you don't have to take out your soldering iron. But as always, the proper precautions must be taken, so ALWAYS SWITCH OFF ALL THE EQUIPMENT INVOLVED before working on it and, to be safe, physically disconnect your ATX power supply from the mains power outlet.

Step by step instructions

Before you start

In case you are using an old ATX power supply, you may want to open its case (usually by just removing four screws) and use a vacuum cleaner to carefully clean its insides (IMPORTANT: make sure you have physically disconnected the PSU from the mains outlet, and allow at least 5 minutes for the internal capacitors to discharge before attempting to open it):

Very dirty old ATX PSU

You will also want to check that your ATX PSU can supply the required current for your RepRap printer and an adequate amount of current on the +5V Standby output. These power ratings can usually be found on a label on the PSU's side:

ATX PSU label

What you want to check here:

  • +12V : 20A or more to be safe (24A in the PSU show above).
  • +5V SB : 1.5A or more (2A in the PSU shown above)

Next, make a quick zero-load test of the PSU output voltages, first with the PSU in Standby mode to test the +5VSB output:

ATX PSU +5VSB test

And second, to test the regular +12V output (I used a 47R 1/4w resistor between PS_ON# and GND to soft start the PSU):

ATX PSU 12V test

Notice how in the +5VSB test the fan is stopped since the PSU is in Standby mode, whereas in the +12V test the fan is spinning since the PSU has been soft-started.

Finally, disconnect everything once again before wiring the ATX PSU to the RAMPS board!

ATX PSU to RAMPS 1.4 wiring

The PS-ON output header pin on the RAMPS board is located to the left of the reset button, at the edge of the PCB:

PS-ON output header pin

The next step then, is wiring the PS-ON output of the RAMPS board to the PS_ON# input of the ATX power supply. I used a two pin connector here, which carries:

  1. Red wire: +5V from the ATX power supply to the RAMPS board for the servos (see below).
  2. Black wire: PS_ON active low signal from the RAMPS board to the ATX power supply.

RAMPS to ATX control connection

Finally, I used a terminal block strip to connect the red and black wires to their corresponding wires from the ATX power supply:

Using a terminal block strip to connect RAMPS and ATX PSU

In summary, at the terminal block strip we have:

  1. Red (+5V) from ATX power supply connects to red (+5V for servos) from the RAMPS board.
  2. Green (PS_ON# active low input) from ATX power supply connects to black (PS-ON output) from the RAMPS board

Notice the braided yellow and black cables coming from the ATX power supply, carrying +12V and Gnd respectively. The Gnd connection between the RAMPS board and the ATX power supply is shared with the power control circuitry. I connected the +12V and Gnd directly to the RAMPS board rather than going through the terminal block strip. Braiding cables is just for aesthetic reasons.

ATX PSU to Raspberry Pi wiring

(optional, in case you are using a Raspberry Pi to run Octoprint)

A mentioned above, the ATX power supply has a +5VSB (+5V Standby) output available which we can use to power our Raspberry Pi. We only need to connect the +5VSB (purple) and one of the Gnd (black) wires from the ATX power supply to our terminal block strip, and connect the terminal block strip to a Micro USB male connector which we'll use to power the Raspberry Pi:

(picture placeholder)

Notice that in Standby mode our ATX power supply will provide +5V to the Raspberry Pi and also indirectly to the Arduino/RAMPS/LCD combo. When the ATX power supply is soft-started and provides +12V to the RAMPS board, the Arduino automatically switches its power supply from the USB port to its internal regulator which will draw current from the RAMPS board (12V - diode drop).

Configuring the firmware

You want to make sure the firmware you are using implements the following two M-codes:

  • M80 - Turn on Power Supply
  • M81 - Turn off Power Supply

and also that the ATX power supply functionality is enabled in the configuration file.

I have checked the following firmwares (by checking GitHub sources):

  1. Marlin: fully supports ATX power supply control functionality. In Configuration.h make sure you have: #define POWER_SUPPLY 1
  2. Repetier-firmware: fully supports ATX power supply control functionality, enabled by default in Configuration.h.
  3. Teacup: as far as I can tell, does not support ATX power supply control functionality (M80/M81 M-codes not parsed).

Both Marlin and Repetier allow you to decide whether the PSU should be soft-started or put/left in Standby mode when the Arduino is reset/powered on (see the source code for details). By default both firmwares will soft-start the PSU automatically.

Configuring OctoPrint and testing everything

This is the easiest part. Just edit your OctoPrint configuration file, adding the following lines to the controls section:

   - name: PSU Control
     type: section
       - name: Power On
         type: command
         command: M80
       - name: Standby
         type: command
         command: M81

If you are not comfortable editing the ./octoprint/config.yaml file directly, you can also use the Custom Control Editor to add a section and the buttons.

If you would like to use the PSU Control Plugin then you can configure it this way as well:

Restart OctoPrint to reload the configuration file and under the Control tab you should see something like this:

Control tab with ATX PSU Power Control options

Powering servos from the +5V from the ATX PSU

Your RAMPS 1.4 board has connectors for and can control up to 4 servos. However, you'll notice that the +5V trace that powers the servos on the RAMPS board is by default not connected to any power source. It just connects to the +5V input pin next to the PS_ON input pin. Using a jumper it is possible to connect it to the Vcc pin right next to it, but this will impose an additional load on the Arduino Mega 2560 power regulator, so imho it is better to connect it to the regular +5V from the ATX power supply.

Caveat concerning the Raspberry Pi A and early B versions

The problem here is that the Raspberry Pi A and early B versions USB port(s) cannot supply enough current to reliably power an Arduino Mega 2560. This is a design flaw that was acknowledged by the Raspberry Foundation.

The solution is very simple actually: if you are using a Raspberry Pi version A or early version B, you must use a powered USB 2.0 hub to connect to the Arduino Mega 2560 (and webcam, WiFi dongle, etc). You can still power your USB 2.0 hub from the ATX power supply +5 VSB, though, and even supply power to the Raspberry Pi from the powered USB hub itself (again with an extra caveat, see below), so in the end the result is almost the same.

There are two caveats to powering the Raspberry Pi from a powered USB 2.0 hub:

  1. Some hubs will not supply power to their USB ports unless they detect that a USB device is indeed active on that port.
  2. Some hubs will backfeed +5V on their USB master port, and you don't want that!

Instead of going through a number of USB hubs trying to find one that actually works well with your Raspberry Pi setup, I suggest to use the PiHub and avoid any headaches. And yes, you can power the PiHub from the ATX PSU +5 VSB line.

Last but not least, I have to make a special note (as an engineer - I am in no way associated with the Raspberry Pi Foundation or any company that distributes Raspberry Pi related products) for the just-launched Raspberry Pi B+: it has four USB 2.0 ports and its power distribution circuitry has been entirely revised and upgraded. Imho the Raspberry Pi B+ is much better suited for OctoPrint server use than all earlier versions.

References and notes

  1. ATX power supply to power RAMPS and RPi discussion, RepRap forum
  2. ATX12V Power Supply Design Guide, Intel Corporation, PDF document, available here
  3. RAMPS 1.4 documentation, schematics and layout, RepRapWiki
  4. Arduino Mega 2560 specifications, see the section about Power, Arduino website
  5. Raspberry Pi USB hub power discussion, Forum
Clone this wiki locally
You can’t perform that action at this time.