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

    Power failure and resurrection on a CNC machine

    Scheduled Pinned Locked Moved
    CNC
    4
    108
    7.1k
    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.
    • Nightowlundefined
      Nightowl
      last edited by

      Thanks, @infiniteloop. I do try to search the forums and the documentation first, but I don't seem to find anything descriptive enough to work from so ask on the forum.

      Of course, as I get to know stuff, I'll be asking fewer questions and giving more help 🙂

      Thanks again, my friend 👍

      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

        @infiniteloop
        So maybe the issue may not be power decline related...

        I changed a couple of things in the M911 line in the config.g file from:

        M911 S23 R23.5 P"M98 P""SaveSpindleSpeed.g"" M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000"
        

        ...to...

        M911 S23 R23.5 P"M913 X0 Y0 G91""M98 P""SaveSpindleSpeed.g"
        

        ...effectively deleting the printer stuff and changing the file order, although I'm not sure if the latter made any difference. I also raised the threshold for power loss.

        Now, the ResumeSpidleSpeed.g file is fully formed, which is great, but I'm getting a different error, twice, when I enter M916 in the MDI:

        M292 Error: No P parameter and no active tool with spindle
        M916 Error: No P parameter and no active tool with spindle
        

        This clearly relates to the spindle - again - so I think the SaveSpindleSpeed.g file will need to edited to add those variables from the Object Browser.

        I'm going to use your lead to see if I can finish this off....

        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

        infiniteloopundefined 1 Reply Last reply Reply Quote 0
        • infiniteloopundefined
          infiniteloop @Nightowl
          last edited by

          @nightowl999

          I changed a couple of things in the M911 line

          M911 S23 R23.5 P"M913 X0 Y0 G91""M98 P""SaveSpindleSpeed.g"
          

          There's something wrong: the double quotation marks following G91 should not be there (and you can skip G91 completely), then, a second quotation mark to end the M98 argument is missing, finally, the closing quotation mark of M911 is missing, too. So try this instead:

          M911 S23 R 23.5 P"M913 X0 Y0 M98 P""SaveSpindleSpeed.g"""
          

          Let's try and see if the M292 and M916 errors persist.

          Nightowlundefined 3 Replies Last reply Reply Quote 0
          • Nightowlundefined
            Nightowl @infiniteloop
            last edited by

            @infiniteloo

            Ooh, that's a lot of quotation marks...

            I'll let you know how it goes...

            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 @infiniteloop
              last edited by Nightowl

              @infiniteloop

              That change truncated the writing of the RestoreSpindleSpeed. g

              This is all I got...

              ; RestoreSpindleSpeed.g
              ; Spindle speed saved from running "0:/gcodes/Calibration Toolpath.gcode" CNC file
              
              ; set up the global variable abort_process so we can abort further execution of resurrect.g:
              if {!exists(global.abort_process)}
                  global abort_process = true
              else
                  set global.abort_process = true
              

              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

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

                @infiniteloop
                I deleted the RestoreSpindleSpeed.g to see how much SaveSpindleSpeed.g would write, but there was nothing. Running the SaveSpindleSpeed.g file from the MDI produced the file, but obviously it didn't have any proer values

                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

                infiniteloopundefined 1 Reply Last reply Reply Quote 0
                • infiniteloopundefined
                  infiniteloop @Nightowl
                  last edited by

                  @nightowl999 said in Power failure and resurrection on a CNC machine:

                  That change truncated the writing of the RestoreSpindleSpeed. g

                  That's what I expected. Due to the misplaced quotation marks, M911 didn't execute properly - I think that even resurrect.g has been malformed by that: this would explain the "No P parameter…" errors.

                  Sigh. One measure of last resort is to trim the execution time of SaveSpindleSpeed.g - with luck, we gain some nanoseconds. So make a copy of your actual SaveSpindleSpee.g file and put this into the macro, instead:

                  var fName = "RestoreSpindleSpeed.g"
                  echo >>{var.fName} "if {!exists(global.abort_process)}"
                  echo >>{var.fName} "    global abort_process = true"
                  echo >>{var.fName} "else"
                  echo >>{var.fName} "    set global.abort_process = true"
                  echo >>{var.fName} "M291 S3 R""Resurrect:"" P""Continue with <"^{job.file.fileName}^">?"""
                  echo >>{var.fName} "set global.abort_process = false"
                  echo >>{var.fName} "M3 S"^{spindles[0].active}
                  

                  With luck, this will work, depending on the current load on the Duet. But I have to insist: that's not good practice, it's more like a ride on a razor blade.

                  Nightowlundefined 2 Replies Last reply Reply Quote 0
                  • Nightowlundefined
                    Nightowl @infiniteloop
                    last edited by

                    @infiniteloop
                    Sorry, about this, but I tried something while you were cogitating...

                    I edited the M911 file to this:

                    M911 S23 R 23.5 P"M913 X0 Y0 M98 P"SaveSpindleSpeed.g"
                    

                    ...and it worked, apart from the spindle errors. The SavedSpindleSpeed was fully formed, too.

                    I don't think it's a timing thing afterall. The "processing" stays onscreen in the DWC for a few seconds, perhaps 2 or 3?

                    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 @infiniteloop
                      last edited by

                      @infiniteloop

                      This is the file:

                      ; RestoreSpindleSpeed.g
                      ; Spindle speed saved from running "null" CNC file
                      
                      ; set up the global variable abort_process so we can abort further execution of resurrect.g:
                      if {!exists(global.abort_process)}
                          global abort_process = true
                      else
                          set global.abort_process = true
                      
                      ; now comes the dialog:
                      M291 S3 R"Resurrect:" P"Continue with <null>?"
                      
                      ; we will only arrive here if the dialog was closed with OK:
                      set global.abort_process = false
                      M3 S0
                      
                      ;EOF
                      

                      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

                      infiniteloopundefined 1 Reply Last reply Reply Quote 0
                      • infiniteloopundefined
                        infiniteloop @Nightowl
                        last edited by

                        @nightowl999 said in Power failure and resurrection on a CNC machine:

                        I deleted the RestoreSpindleSpeed.g to see how much SaveSpindleSpeed.g would write, but there was nothing.

                        That's why I decidedly put the macro call at the beginning of the M911 sequence 😸

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

                          @infiniteloop
                          OK, I'll change them back...

                          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
                          • infiniteloopundefined
                            infiniteloop @Nightowl
                            last edited by

                            @nightowl999 said in Power failure and resurrection on a CNC machine:

                            This is the file:

                            We are out of sync. delete that and look at the file resulting from the next power outage.

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

                              @infiniteloop
                              File deleted. I'm just changing the M911 line back...

                              And now I'm going to try again...

                              And RestoreSpindleSpeed .g only got to line 6...

                              This is the M911 line in config.g...

                              M911 S23 R23.5 P"M98 P""SaveSpindleSpeed.g"" M913 X0 Y0"	; set voltage thresholds and actions to run on power loss
                              

                              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

                              infiniteloopundefined 1 Reply Last reply Reply Quote 0
                              • infiniteloopundefined
                                infiniteloop @Nightowl
                                last edited by

                                @nightowl999 said in Power failure and resurrection on a CNC machine:

                                And RestoreSpindleSpeed .g only got to line 6

                                At that point, remaining power has gone.

                                1 Reply Last reply Reply Quote 0
                                • infiniteloopundefined
                                  infiniteloop
                                  last edited by infiniteloop

                                  @Nightowl999 Obviously, SaveSpindleSpeed.g has not enough time to finish its job before power is totally lost. You have two options:

                                  1. take measures to keep power up a bit longer
                                  2. forego the dialog, so that RestoreSpindleSpeed.g becomes a one-liner

                                  The second option requires changes to SaveSpindleSpeed.g and resurrect-prologue.g. If you want to go this route, I will provide the sources.

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

                                    @infiniteloop

                                    I'm still hoping someone will answer my question about using a small powerbank permanently plugged in to the USB port on the Duet3, but nothing yet. If that isn't an option, there may be an alternative!

                                    I can REM out the unnecessary lines in SaveSpindleSpeed.g and resurrect-prologue.g quite easily, and see if that makes a difference. I'll do that this evening, but won't be able to test them until tomorrow, though.

                                    Thanks for your perseverence!

                                    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

                                    infiniteloopundefined 1 Reply Last reply Reply Quote 0
                                    • infiniteloopundefined
                                      infiniteloop @Nightowl
                                      last edited by infiniteloop

                                      @nightowl999 said in Power failure and resurrection on a CNC machine:

                                      I can REM out the unnecessary lines in SaveSpindleSpeed.g and resurrect-prologue.g quite easily, and see if that makes a difference

                                      It does. I am pretty sure that SaveSpindleSpeed.g has enough time to write a one-liner to the SD card. By now, it gets 4-6 lines done. 😊

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

                                        @infiniteloop

                                        OK, so I've done that, leaving the SaveSpindleSpeed.g at this:

                                        var fName = "RestoreSpindleSpeed.g"
                                        echo >>{var.fName} "if {!exists(global.abort_process)}"
                                        echo >>{var.fName} "    global abort_process = true"
                                        echo >>{var.fName} "else"
                                        echo >>{var.fName} "    set global.abort_process = true"
                                        echo >>{var.fName} "M291 S3 R""Resurrect:"" P""Continue with <"^{job.file.fileName}^">?"""
                                        echo >>{var.fName} "set global.abort_process = false"
                                        echo >>{var.fName} "M3 S"^{spindles[0].active}
                                        

                                        Which produces this RestoreSpindleSpeed.g file:

                                        if {!exists(global.abort_process)}
                                            global abort_process = true
                                        else
                                            set global.abort_process = true
                                        M291 S3 R"Resurrect:" P"Continue with <null>?"
                                        set global.abort_process = false
                                        M3 S0
                                        

                                        What I was surprised to see is that if I don't delete the RestoreSpindleSpeed.g and run the SaveSpindleSpeed.g again, it appends to the existing file - perpetually.

                                        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

                                        Nightowlundefined infiniteloopundefined 2 Replies Last reply Reply Quote 0
                                        • Nightowlundefined
                                          Nightowl @Nightowl
                                          last edited by Nightowl

                                          @infiniteloop
                                          Actually, why do I need to edit the resurrect-prologue.g file, as this is only run when power is restored?

                                          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
                                          • infiniteloopundefined
                                            infiniteloop @Nightowl
                                            last edited by

                                            @nightowl999

                                            What I was surprised to see is that if I don't delete the RestoreSpindleSpeed.g and run the SaveSpindleSpeed.g again, it appends to the existing file - perpetually.

                                            The first echo must be written with a single angular bracket, i.e. „echo >{var.fName} …

                                            OK, so I've done that, leaving the SaveSpindleSpeed.g at this:

                                            Hm, that’s the file I posted today at 19:14, and I know which RestoreSpindleSpeed.g it generates. That’s not the one-liner I had in mind. Don't mix things up, please.

                                            Actually, why do I need to edit the resurrect-prologue.g file, as this is only run when power is restored?

                                            Because if RestoreSpindleSpeed.g becomes a one-liner, the current resurrect-prologue.g throws an error on the missing variable abort_process.

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