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

Preview Download

  • 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

  • First practical test

    Dave8 hours ago 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?

    Dave5 days ago 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

    Dave5 days ago 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

    Dave6 days ago 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

    Dave6 days ago 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:

    • 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 6 project logs

    Enjoy this project?



    Similar Projects

    Does this project spark your interest?

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