Experimenting with the emergency button

  • Hi to everyone,
    I'm trying to set my red mushroom emergency button to do what i want.
    First of all this the code:

    in config.g file:
    M581 T2 E1 S1 ; run macros "trigger2" for emergency stop

    in trigger2.g macro:
    M106 P0 S1 ;fan 0 on
    M106 P2 S1 ;fan 2 on
    M81 ;24V power supply off
    M112 ;shut down motors and heaters

    I've two power supplies, one 24v for the heat bed and motors, one 12v/5v for fans and cpu. So, even if i shut down the 24v power supply (via SSR) , fans and cpu can work (in order to cool the hotend).

    There'sonly one problem: after m112 command I'd like restart the machine rotating the emergency button, but i'm not able to do so becouse the only thing i can do is press "reset machine" in DWC.

    Any help is appreciate 😊

  • administrators

    I haven't tested it, but I think it should be possible to set up another trigger that runs M999 when it receives the opposite transition from the button.

  • @dc42 thank you, I'll try with this solution tomorrow.

  • @zecchi did it function as you expected?

  • @Nathan actually I've had small issues with fans, but now is all ok, so I will try in the next days.

    In my opinion there should be a sort of interaction between the two macros for this reason:
    Let's suppose the emergency button has been pushed, then the printer is switched off before the emergency button has been released. When the printer is restarted (switched on) there may be some problems due to the emergency button state.

    I'm a PLC programmer, and usually, to solve this kind of problems, we use rising edge (or falling edge). But for me g-code is completely new and I don't know how to use properly commands ( like M581). For now it's ok, I will try with dc42's solution.

  • @dc42 your solution seems work.

    I was wondering if M112 has an "automatic reboot", infact when I press the emergency button and wait few seconds DWC seems already rebooted.

Log in to reply