• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

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

Scheduled Pinned Locked Moved
Gcode meta commands
4
8
395
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.
  • undefined
    dhusolo
    last edited by Phaedrux 11 Aug 2021, 16:36

    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?

    undefined undefined 2 Replies Last reply 16 Aug 2021, 20:51 Reply Quote 0
    • undefined
      Phaedrux Moderator
      last edited by 16 Aug 2021, 20:38

      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
      • undefined
        zapta @dhusolo
        last edited by 16 Aug 2021, 20:51

        @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.

        undefined 1 Reply Last reply 16 Aug 2021, 20:54 Reply Quote 0
        • undefined
          dhusolo @zapta
          last edited by 16 Aug 2021, 20:54

          @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

          undefined 1 Reply Last reply 16 Aug 2021, 21:56 Reply Quote 0
          • undefined
            zapta @dhusolo
            last edited by 16 Aug 2021, 21:56

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

            1 Reply Last reply Reply Quote 0
            • undefined
              OwenD @dhusolo
              last edited by 17 Aug 2021, 02:34

              @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
              undefined 1 Reply Last reply 19 Aug 2021, 21:48 Reply Quote 0
              • undefined
                dhusolo @OwenD
                last edited by 19 Aug 2021, 21:48

                @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
                undefined 1 Reply Last reply 20 Aug 2021, 05:13 Reply Quote 0
                • undefined
                  OwenD @dhusolo
                  last edited by 20 Aug 2021, 05:13

                  @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
                  7 out of 8
                  • First post
                    7/8
                    Last post
                  Unless otherwise noted, all forum content is licensed under CC-BY-SA