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

    CNC Pause and Resume config files

    Scheduled Pinned Locked Moved
    Gcode meta commands
    3
    44
    1.7k
    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.
    • OwenDundefined
      OwenD @Nightowl
      last edited by

      @nightowl999 said in CNC Pause and Resume config files:

      but I'm aware you're tired (as am I!)

      It's 5:51 AM here. I'm tired because I woke at 3am and couldn't get back to sleep 😧
      Try it when you can and report back.

      Nightowlundefined 2 Replies Last reply Reply Quote 1
      • Nightowlundefined
        Nightowl
        last edited by

        It works! And the spindle turns off with pause and on with resume!

        Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
        I'm still on my learning curve, so take everything I say with caution!

        RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

        OwenDundefined 1 Reply Last reply Reply Quote 0
        • Nightowlundefined
          Nightowl @OwenD
          last edited by

          @owend It's only 9pm here, but I've been trying to sort this all day!

          Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
          I'm still on my learning curve, so take everything I say with caution!

          RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

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

            @nightowl999
            OK,
            So the problem was there was no tool selected.
            I would have thought that was necessary to turn a spindle on, but maybe not.
            If you have multiple tools then you'll need to consider how to store which tool was selected when you pause (if RRF doesn't store that in CNC mode)

            1 Reply Last reply Reply Quote 1
            • Nightowlundefined
              Nightowl @OwenD
              last edited by Nightowl

              @owend This is how my spindle is configured in config.g:

              ; Makita and relay configuration
              M950 R0 C"out1+out7" L0:18000	; enable router relay on out7
              M563 P0 S"Makita" R0 		; assign spindle 0 to tool 0 and name it Makita
              T0				; select tool 0
              

              This was only configured to turn the spindle off/on via a relay, but I figured I will need this resolved for when my speed-contollable milling motor turns up. My assumption is the speed thing isn't relevant as the DI isn't connected.

              Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
              I'm still on my learning curve, so take everything I say with caution!

              RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

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

                @nightowl999
                What happens in the console when you run
                M98 P"0:/sys/config.g"

                You're selecting T0, so I'm at a loss why it's not selected in your job.
                Somewhere something is turning it off.

                Nightowlundefined 1 Reply Last reply Reply Quote 1
                • Nightowlundefined
                  Nightowl @OwenD
                  last edited by

                  @owend said in CNC Pause and Resume config files:

                  M98 P"0:/sys/config.g"

                  From the command line?

                  Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                  I'm still on my learning curve, so take everything I say with caution!

                  RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

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

                    @nightowl999
                    yes

                    Nightowlundefined 1 Reply Last reply Reply Quote 1
                    • Nightowlundefined
                      Nightowl @OwenD
                      last edited by

                      @owend
                      Only this:

                      27/05/2022, 21:02:24 M98 P"0:/sys/config.g"
                      HTTP is enabled on port 80
                      FTP is disabled
                      TELNET is disabled
                      Error: in file macro line 66 column 27: meta command: variable 'savedSpindleSpeed' already exists

                      but I haven't 'rebooted' the Duet

                      Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                      I'm still on my learning curve, so take everything I say with caution!

                      RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

                      1 Reply Last reply Reply Quote 0
                      • OwenDundefined
                        OwenD
                        last edited by

                        @nightowl999
                        OK
                        That error is normal if you haven't rebooted.

                        I'm at a loss why you have no tool selected when pause.g begins unless RRF deselects it when G25 is run.

                        I've been looking through the object model a bit and I think you can do away with teh global variable and use values from the object model.
                        I'll post something to try in 5-10 minutes

                        Nightowlundefined 1 Reply Last reply Reply Quote 1
                        • Nightowlundefined
                          Nightowl @OwenD
                          last edited by Nightowl

                          @owend If you're sure. I don't want to stress you (or me!) out trying to resolve this. I thought this would be easy 🤣 🤣

                          I'm going back to the hous, but I'll update the files when you post the answer ( 🙂 ) and I'll try it out toorrow morning (my time).

                          I'm really grateful for your time and help with this, @OwenD

                          Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                          I'm still on my learning curve, so take everything I say with caution!

                          RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

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

                            @nightowl999

                            Try these

                            ; pause.g
                            G1 X273.5 Y560 F2400 ; move XY to a safe place
                            M5 ; turn the spindle off
                            

                            and

                            ;resume.g
                            if state.restorePoints[0].toolNumber =-1
                            	"echo no tool was saved- selecting T0"
                            	T0
                            else
                            	T{state.restorePoints[0].toolNumber} ; select the tool that was active
                            if state.restorePoints[0].spindleSpeeds[0] = 0
                            	echo "No resume speed was saved"
                            else
                            	M3 S{state.restorePoints[0].spindleSpeeds[0]}	; resume saved spindle speed
                            	G4 S1					; wait 1 second to allow the spindle to spin up
                            	echo "Spindle speed resumed at ", state.restorePoints[0].spindleSpeeds[0], "RPM" ; this should show that the setting was successful
                            

                            Forgot to comment "resume.g" corrected.
                            Also I have no way of checking what's stored in the restore point arrays.

                            Nightowlundefined 2 Replies Last reply Reply Quote 1
                            • Nightowlundefined
                              Nightowl @OwenD
                              last edited by

                              @owend I tweaked the first echo, too!

                              Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                              I'm still on my learning curve, so take everything I say with caution!

                              RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

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

                                @owend I need to call it a night. I've been summoned and the neighbours don't like the noise!

                                Here's the last bit of Console text...

                                27/05/2022, 21:28:41 	M0
                                Printing paused at X205.3 Y258.9 Z64.0
                                Cancelled printing file 0:/gcodes/Calibration Toolpath.gcode, print time was 0h 0m
                                27/05/2022, 21:28:30 	M25
                                Resume state saved
                                27/05/2022, 21:28:29 	Printing resumed
                                27/05/2022, 21:28:21 	M24
                                no tool was saved- selecting T0
                                Error: in file macro line 7 column 4: meta command: unknown value 'spindleSpeeds^'
                                27/05/2022, 21:28:17 	Printing paused at X205.3 Y212.6 Z65.0
                                27/05/2022, 21:28:07 	M25
                                Resume state saved
                                27/05/2022, 21:27:48 	M32 "0:/gcodes/Calibration Toolpath.gcode"
                                File 0:/gcodes/Calibration Toolpath.gcode selected for printing
                                

                                Once again, the spindle didn't restart 😞

                                Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                                I'm still on my learning curve, so take everything I say with caution!

                                RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

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

                                  @nightowl999
                                  OK.
                                  As I said, I have no way of checking exactly how the restore points for spindles work.
                                  Perhaps @DC42 could chime in at this point now that it's narrowed down and explain why there's no tool selected when you pause and also whether all the spindle speeds etc are saved in the object model.

                                  Nightowlundefined 2 Replies Last reply Reply Quote 1
                                  • Nightowlundefined
                                    Nightowl @OwenD
                                    last edited by

                                    Thank you, @OwenD. you've been an absolute diamond.

                                    I'll restore the files back to where they were before I said "It works!..." and hope @dc42 would be kind enough to help.

                                    Thanks again!

                                    Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                                    I'm still on my learning curve, so take everything I say with caution!

                                    RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

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

                                      @owend said in CNC Pause and Resume config files:

                                      As I said, I have no way of checking exactly how the restore points for spindles work.

                                      I think the issue was only really with saving and restoring the spindle speed of a digitally controlled milling motor.

                                      If I need to pause the CNC, the only real difference between that and a 3D printer is it would be safer to turn the spindle off, and back on at the same speed on resume. Lifting the Z and moving the XY to a predetermined location is my variation on what seems to be the default for a 3D printer, i.e. X0, Y0 and Z0 (but I'm happy to be corrected.

                                      The default pause.g and resume.g files work as they should, even with my 'safe location' amendments, it's just saving and restoring the spindle speed.

                                      @dc42 first helped me with this by showing how to declare a global variable (savedSpindleSpeed) in the config.g file, then setting the variable's value to the actual spindle speed when pause.g is initiated.

                                      It sounded simple, but for some reason - as you've identified @OwenD - something is 'deselecting' the tool or the value of the variable isn't being saved.

                                      Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                                      I'm still on my learning curve, so take everything I say with caution!

                                      RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

                                      1 Reply Last reply Reply Quote 0
                                      • OwenDundefined
                                        OwenD
                                        last edited by

                                        @nightowl999
                                        I've just found that the restore points are saved to slot 1 in a pause.
                                        So if my last macro was to work it would have to be

                                        ;resume.g
                                        if state.restorePoints[1].toolNumber =-1
                                        	"echo no tool was saved- selecting T0"
                                        	T0
                                        else
                                        	T{state.restorePoints[1].toolNumber} ; select the tool that was active
                                        if state.restorePoints[1].spindleSpeeds[0] = 0
                                        	echo "No resume speed was saved"
                                        else
                                        	M3 S{state.restorePoints[1].spindleSpeeds[0]}	; resume saved spindle speed
                                        	G4 S1					; wait 1 second to allow the spindle to spin up
                                        	echo "Spindle speed resumed at ", state.restorePoints[1].spindleSpeeds[0], "RPM" ; this should show that the setting was successful
                                        
                                        
                                        Nightowlundefined 1 Reply Last reply Reply Quote 0
                                        • Nightowlundefined
                                          Nightowl @OwenD
                                          last edited by Nightowl

                                          Thank you so much, @OwenD!

                                          I'll update the pause.g and resume.g files, but am I correct in thinking all the save/resume 'stuff' is being carried out in the resume.g file now, rather than the pause.g file?

                                          From what I've gleaned, these are the files I'm going to try out:

                                          ; pause.g
                                          G1 Z{max(move.axes[2].userPosition+5,move.axes[2].max-5)} F240 ; move the Z axis slowly to a safe height
                                          G0 X273.5 Y560 ; move XY to a safe place
                                          M5; turn the spindle off
                                          
                                          ;resume.g
                                          if state.restorePoints[1].toolNumber =-1
                                          	echo "No tool was saved - selecting T0"
                                          	T0
                                          else
                                          	T{state.restorePoints[1].toolNumber} ; select the tool that was active
                                          if state.restorePoints[1].spindleSpeeds[0] = 0
                                          	echo "No resume speed was saved"
                                          else
                                          	M3 S{state.restorePoints[1].spindleSpeeds[0]} ; resume saved spindle speed
                                          	G4 S1 ; wait 1 second to allow the spindle to spin up
                                          	echo "Spindle speed resumed at ", state.restorePoints[1].spindleSpeeds[0], "RPM" ; this should show that the setting was successful
                                          G1 R1 X0 Y0 F2400 ; move XY back to last saved location 
                                          G1 R1 Z0 F240 ; move Z slowly to last saved location
                                          

                                          Also, it seems I no longer need the variable to be defined in the config.g file?

                                          Thank you

                                          Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                                          I'm still on my learning curve, so take everything I say with caution!

                                          RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

                                          1 Reply Last reply Reply Quote 0
                                          • Nightowlundefined
                                            Nightowl
                                            last edited by Nightowl

                                            I'm wondering if the issue is with the state of the spindle is being saved after it's been turned off with the M5 line in the pause.g file, or does the very act of initiating pause.g save the state of the machine somewhere?

                                            I'll have a look at transposing the files and see how I get on...

                                            Few things are more dangerous than taking the advice of someone who thinks he knows what he's doing.
                                            I'm still on my learning curve, so take everything I say with caution!

                                            RatRig 1075, Duet3 MB6HC, Sorotec SFM 1000 PV-ER milling motor, Hobbyist

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