Duet3D Logo

    Duet3D

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Documentation
    • Order

    single press to power on, long press to power off?

    Gcode meta commands
    4
    8
    201
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dhusolo
      dhusolo last edited by Phaedrux

      I have
      Duet 3 with RRF3.3
      24v PSU
      RPI4 powered off it's own power supply
      a momentary on/off button
      5v relay
      5v PSU to provide Duet3 PS_ON 5v

      The RPI is always on and the Duet is in low power mode.
      I can power on the Duet 3 with the ATX buttons in DWC
      The momentary button is wired to an IO port configured as an external trigger. When the button is pressed it sends M80 to turn the printer on. PS_ON grounds the relay switching the 24v PSU on.

      I'm wondering if there's a way(maybe with conditional G code) to also configure the same momentary button so if it's held for 3 seconds it will send M81 to shut the printer off?

      zapta OwenD 2 Replies Last reply Reply Quote 0
      • Phaedrux
        Phaedrux Moderator last edited by

        Yes I think that may be possible with conditional. I'll move to the conditional gcode forum.

        Z-Bot CoreXY Build | Thingiverse Profile

        1 Reply Last reply Reply Quote 0
        • zapta
          zapta @dhusolo last edited by

          @dhusolo said in single press to power on, long press to power off?:

          if it's held for 3 seconds it will send M81 to shut the printer off?

          A side note, you may also want to have an high accessible and immediate way to shut down the printer in case of an emergency.

          dhusolo 1 Reply Last reply Reply Quote 0
          • dhusolo
            dhusolo @zapta last edited by

            @zapta I have an E-stop button setup and there's a master power switch on the side that will cut power off to everything if needed

            zapta 1 Reply Last reply Reply Quote 0
            • zapta
              zapta @dhusolo last edited by

              @dhusolo, it seems that you took care of the safety aspect.

              1 Reply Last reply Reply Quote 0
              • OwenD
                OwenD @dhusolo last edited by

                @dhusolo
                I assume you're using a trigger for your button press

                Something like this in the triggerX.g file would be a simplistic approach

                M80 ; turn on power
                G4 S3 ; wait three seconds 
                if sensors.gpIn[0].value = 1 ; check if button still pressed
                      M81 ; turn off power
                
                dhusolo 1 Reply Last reply Reply Quote 0
                • dhusolo
                  dhusolo @OwenD last edited by

                  @owend I tried that and this is the response
                  Error: Failed to read code from macro trigger2.g: Failed to evaluate "sensors.gpIn[0].value = 1": reached null object before end of selector string

                  trigger2.g

                  M80					; Power on
                  G4 S3				;
                  if sensors.gpIn[0].value = 1 ; check if button still pressed
                        M81 ; turn off power
                  undefined
                  

                  config.g

                  M581 T2 P1 S1 R0		                       				; T2-Run Trigger 2; P1-J1; S1-When button pressed; R0-trigger any time
                  M582 T2														; Monitor external trigger 2
                  
                  OwenD 1 Reply Last reply Reply Quote 0
                  • OwenD
                    OwenD @dhusolo last edited by

                    @dhusolo
                    My code was meant as an example.
                    You need to monitor the pin that your you're using.
                    i.e the The pin you created with M950 and the P parameter you use in M581.
                    You have M581 T2 P1 S1 R0
                    try

                    M80					; Power on
                    
                    G4 S3				;
                    
                    if sensors.gpIn[1].value = 1 ; check if button still pressed
                    
                          M81 ; turn off power
                    

                    Not sure why you're using M582 in config.g
                    I believe it will cause the trigger to run as if you've pressed the button.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Unless otherwise noted, all forum content is licensed under CC-BY-SA