3D Shutdown

Autonomous shutdown with Flip-Flop RS for 3D printer.

Similar projects worth following
I would like to create an autonomous - easy - system for shutdown my 3D printer using M81 command of the Marlin.

For the Hardware components, i want to use only transistor, resistors and buttons. Plus one relay.

The flow of the problem is:

  1. When the printer will end, the Marlin will reads the "M81" command
  2. The PS_ON pin rises
  3. Now the relay will open the circuit and the printer power off
  4. So the ramps will power off, and the PS_ON pin will fall
  5. The relay will close
  6. And in the end the printer will power on, again....

So we need something with a memory, that can remember the last state of the PS_ON pin.

fzz - 7.34 kB - 06/18/2017 at 09:39


JPEG Image - 559.29 kB - 06/18/2017 at 09:38


  • 3 × Transistor NPN 2n5551
  • 5 × Resistor 3x 10k ohm & 2x 270 ohm
  • 1 × Led Fiber Optics / Emitters
  • 1 × Button Momentary switch toggle
  • 1 × Relay shield Arduino Relay shield

  • Final 3D case

    Dave07/11/2017 at 15:47 0 comments

    Today i have printed an easy case for my 3D ShutDown project.

    It's not amazing but it works pretty well.

    I leave you the link for my 3D model:

  • The case

    Dave07/08/2017 at 13:42 0 comments

    Unfortunately i'm not a good drawer, but my 3D Shutdown need a case.

    For now i'm have been doing a very easy case, for a protoboard, i hope to arrived to the end in a fast way.

    The part where I will start is the top, i need to find some position for the objects that that will be easily accessed when the case is closed.

  • Schematic update with relay

    Dave06/28/2017 at 00:10 0 comments

    It's time to add a relay on the out pin of my Flip Flop.

    According to the schematic, i connected the Collector pin to the input of relay:

    Now I created a 3D printer file with, at the end of the "final code", I entered the M81 command.

    Let me to show you what happens:

    When the print finished, the relay open the circuits and the printer shut down.

    In the same time the led turn on.

    When i press the button next to the led, the printer will turns on.

  • First video

    Dave06/24/2017 at 21:18 0 comments

    After i have changed the parameters written in the preview log - about PS_ON level after start - now the printer put down the PS_ON pin during the start up.

    I decided to show you my first success with the proto board:

    The yellow LED will turn on when the printer is switched off.

    The printer is turned off as long as you do not press the button next to the yellow led.

    The relay is not connected yet. When i will connect it, the printer will shut down completely and only the shutdown circuit stay on.

  • First practical test

    Dave06/24/2017 at 07:37 0 comments

    The first test works fine, but i noticed a problem when the printer power on.

    The pin PS_ON is put hight - 1 - when the printer start print.

    This mean that the Flip Flop circuit cut off the power of the printer immediately!

    I suppose i need to edit the checkbox equal for this pic:

    Well, i will try that parameter tomorrow.

  • Is PS_ON high or low?

    Dave06/19/2017 at 20:36 0 comments

    At this time of project, we need to verificate if PS_ON work well.

    Take the multimeter!

    According with the Marlin's guide, the PS_ON is LOW when the printer is powered.

    Good, i connect my "+" to the PS_ON pin and the "-" at a free GND on the RAMPS.

    It looks good, i read on my multimeter "0V".

    Now i edited my Gcode, i added "M81" command somewhere...

    Now i put the SD card on my 3D printer.

    When the 3D machine arrived in line with "M81", my LCD display came out of with the written "Printer OFF".

    But wait, why my multimeter does not show me "5V" ?

    Very strange.... i repeated the same process many time and i will have to read some guide about the Marlin power.

    According with the Marlin/Ramps power guide - - i have a problem with Diode.

    In my specific case, i have both of the diode, D1 and D2 on my RAMPS.

    If i want to use my PS_ON pin, i need to cut the Diode D1.

    But wait, if i cut the D1 Diode, i need to connect and external power supply - 5V stable - for power the Arduino board....

    It's not a good solution.... I need to find another approach.

    Marlin/Kimbra firmware

    This version of Marlin is called Kimbra.

    It's a very nice and easy - smart - way for customize your parameters of your 3D print.

    And they have a solution with out cut off the Diode D1, amazing!

    If you go to "firmware_configurator" you could edit your "Overral.h" file with a lot of new parameters.

    We need this part of guide:

    Now we have the functionality on!

    If you will repeat the process on top, now the multimeter will show 5V when the RAMPS will read the M81 command.


    I strongly recommend the Marlin Kimbra firmware for your 3D printer, it's very powerful and highly configurable.

  • Build it on protoboard

    Dave06/19/2017 at 20:02 0 comments

    According with my last circuit schematic, it's time to build the first protoboard!

    You can download the version 0.1 in "Files", or see the image below.

  • The relay and how control it

    Dave06/18/2017 at 14:39 0 comments

    This is a standard 2 relays for Arduino, very cheap and easy to find online.

    This one have 2 relay

    This module is made with some components inside, like optocoupler and diode.

    The microcontroller is a low power supply device, without relay it can not control high power supply, like the power supply in the 3D printer.

    The basic function is schemed in this picture:

    The rule of this component it's easy:

    when the current pass through a coil - the component draw like a punch - the switch move, the C connection, from NC to NO. So, when the current not pass in a coil, the circuit return at NC.

    Online simulator:

    Why i added the transistor, resistor and diode on the output of the Flip-Flop?

    These three components are integrated in the relay module. The resistor is put to put the transistor in the saturation region and the diode prevents the voltage spike when the inductor is discharged.

    Now is the time to build the first prototype on the PCB board, according with the last circuit on the top.

  • The Ramps with remember pin

    Dave06/18/2017 at 08:26 0 comments

    I want to add in the Gcode ( in the end ) the Marlin "M81" command for turn on a specific pin on the RAMPS.

    What is a RAMPS?

    The RAMPS 1.4 is the last shield for Arduino Mega with you can control the stepper motor on the 3D printer.

    The RAMPS is completely passive, the Marlin firmware in the Arduino, make the magic staff.

    So the Marlin firmware has a lot of command ( Gcode ) for control motor and some more I/O in your 3D printer. See the commands list:

    Ok but, how create the Gcode for the Marlin? The slicer, likes Cura.

    Now what pin is connected to "M81" ? if you see on the command list, is the pin "PS_ON".

    Take a look of the schematic:

    When the Marlin reads the "M81" command, rise up the pin PS_ON. Easy.

    Why we need the Flip-Flop to control the power off?

    The flow is this:

    1. When the printer will end, the Marlin will reads the "M81" command
    2. The PS_ON pin rises
    3. Now the relay will open the circuit and the printer power off
    4. So the ramps will power off, and the PS_ON pin will fall
    5. The relay will close
    6. And in the end the printer will power on, again....

    We need something with a memory to control - remember - the last state!

    In the easy word, the Flip-Flop.

    Now we can edit the schematic in this way:

    Online simulator:

    1. First step: the theory

      Dave06/17/2017 at 14:43 0 comments

      The NOR:

      I need to search some theory about Flip-Flop for the first step:

      This is the first model you see on Google/Wiki if you search Flip-Flop SR.

      The true table:

      It's pretty easy to understand, only 2 Nor, and very fast to build, if you want, with IC 7402.

      Online simulator:

      The NOR with the transistors:

      In this project we want to use only transistors and resistors component, and we need to go a little bit deeper inside the Nor component.

      This "clickable" image is the base of what is inside the NOR component:

      We can play with this schematic on the simulator:

      Now we could simplified the schematic in this way:

      Perfect, the last - simplified - schematic is a good point to start and grow up the project.

      The next steps for the projects are:

      • connect the RAMPS shield to the Flip-Flop
      • connect the Relay shield to the Flip-Flop


      Key note is that: the circuit is symmetric.

      • What happen if i change the top side resistors? what is change in the output?
      • Moreover, when the transistor is in Saturation region? This condition is define by which resistors?

    View all 10 project logs

    Enjoy this project?



    Rodger wrote 07/06/2023 at 02:24 point

    The project is outdated and there are inconsistencies:
    The first thing I see when looking at Fritzz's schematic is the LED, logically it will ALWAYS be on, as both Phase and Neutral are already on.

    Another easily observable thing is the number of resistors, in the material listing a total of 5 (2 types) are described, but in the schematic there are 7 of 3 types.

    Another issue is when pin placement on the 2N5551 - PIN 1 is normally connected to ground and is not what appears on the wiring diagram.

    Unfortunately, it is not possible to guess how the author made the wiring diagram correctly, it would be very useful if it were updated.


      Are you sure? yes | no

    tkizilaslan wrote 12/13/2022 at 09:38 point

    hello, where will the contact ends of the relay be connected? How to make nc c no connections? Will it be controlled by a 220 volt or 12 volt relay? Please provide information.

      Are you sure? yes | no

    Similar Projects

    Does this project spark your interest?

    Become a member to follow this project and never miss any updates