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
      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!

        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.

          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

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

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

                  @nightowl999
                  When you pause the job RRF saves certain values automatically.
                  From what I can glean from the docs that should include the spindle state, direction and speed.
                  If you hit pause and then use the object model browser you should be able to confirm.
                  I can't as I don't have a spindle configured.

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

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • Nightowlundefined
                      Nightowl
                      last edited by Nightowl

                      Well, I think I've got it, but there may be a tweak I could use to improve it, but as I've only got one spindle/tool this will probably do. This pause.g file works and saves the spindle speed to the defined variable:

                      set global.savedSpindleSpeed = spindles[0].active
                      echo "Spindle speed saved at " ^ {global.savedSpindleSpeed} ^ "RPM"
                      G1 Z{max(move.axes[2].userPosition+5,move.axes[2].max-5)} F2400 ; move the Z axis to a safe height		
                      G0 X273.5 Y560 ; move XY to a safe place
                      M5 ; turn the spindle off
                      

                      ...and the resume.g file turns the spindle back on, although I think there are a few spurious lines in it now. I'll deal with that in the morning!

                      Thanks @OwenD and @dc42 for your help with this 👍 👍

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

                        This post is deleted!
                        1 Reply Last reply Reply Quote 0
                        • Nightowlundefined
                          Nightowl
                          last edited by

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