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

    Power failure and resurrection on a CNC machine

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

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

                          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.

                          I wasn't saying it isn't, just that is what I was left with once I'd deleted the REM lines, but which one-liner were you referring to, to replace those 8 lines, please?

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

                          Ah, I deleted the lines above it, leaving this one with two >>. Should it be like this, then?

                          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}
                          

                          Because if RestoreSpindleSpeed.g becomes a one-liner

                          OK, but I'm still unsure how that file could possibly become a one-liner, to be honest!

                          Also, can I just check I've got the config.g M911 line correct, please:

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

                          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

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

                            FYI, the spurious {1} lines are a bug in the forum markup software.
                            You can alleviate them by specifying a language after the code ticks

                            
                            
                            
                            ```php
                            
                            ```json
                            
                            ```perl
                            
                            

                            Just try different ones till it clears the extra lines

                            Edit: some references
                            https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks

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

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

                              Also, can I just check I've got the config.g M911 line correct, please:

                              You should insert a blank in front of M913.

                              For the "one-liner", SaveSpindleSpeed.g will look like this:

                              ; SaveSpindleSpeed.g
                              ; Macro to store the actual spindle speed (RPM) at the time this is called
                              ; To restore the saved datum, call the macro "RestoreSpindleSpeed.g".
                              ;
                              var fName = "RestoreSpindleSpeed.g"
                              ;
                              echo >{var.fName} "M3 S"^{spindles[0].active}
                              

                              … and resurrect-prologue.g must be modified like that:

                              ; resurrect-prologue.g
                              M98 P"RestoreSpindleSpeed.g"
                              M98 P"homeall.g"	; homes all axes before restarting the job
                              
                              1 Reply Last reply Reply Quote 0
                              • infiniteloopundefined
                                infiniteloop @OwenD
                                last edited by infiniteloop

                                @owend Thank you for the tip! Works 😊

                                1 Reply Last reply Reply Quote 0
                                • dc42undefined
                                  dc42 administrators @infiniteloop
                                  last edited by

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

                                  From a first glance, I get the impression that this resurrect.g is missing all the things which are specific to CNC routers.

                                  @infiniteloop and @Nightowl999 if you can list the items that are missing from resurrect.g for CNC machines then I can add that fixing those items the work list for release 3.5.

                                  Duet WiFi hardware designer and firmware engineer
                                  Please do not ask me for Duet support via PM or email, use the forum
                                  http://www.escher3d.com, https://miscsolutions.wordpress.com

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

                                    @dc42

                                    if you can list the items that are missing from resurrect.g for CNC machines…

                                    From a coder’s point of view, this thread is more a lesson in practical chaos theory than about mills. So the list from this here is quite short:

                                    spindles[n].active
                                    

                                    According to @Nightowl999, the corresponding M3 should follow the prologue call in resurrect.g. But I have reasonable doubts if this is sufficient for more complex CNC devices. For a better picture, I need advice from someone with profound CNC knowledge who in turn is willing to try some macros who emulate the required steps in resurrect.g - just without the power outage.

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

                                      @dc42
                                      Thank you! It's been a really steep learning curve for me with this, but it has certainly provided me with a bit of an insight with programming, thanks to @infiniteloop!

                                      I'll include everything, so will probably mention things that are already preserved, but won't include 'stuff' from the config.g, as I guess this will run when the system restarts. I'm not sure where this information is stored in the Object Browser (Spindles or Tools?) so I'll give a little description.

                                      • Active Spindle (tools[n].spindle) - which spindle/tool was active
                                      • Spindle Speed (tools[n].spindleRpm) - the last programmed speed of the spindle/tool
                                      • XYZ coordinates at power loss

                                      I offer the following for considerations on power loss when the machine is in CNC Mode:

                                      • Raise the Z height to Z(max-3) - in preparation for homing when the machine is restarted
                                      • Turn the spindle off - after the Z axis is raised.

                                      I don't know if a printer will automatically resume the job when the power is restored, but this is definitely not a good idea for a CNC machin, but I'd like you to consider on power being restored is:

                                      • Home the machine - unless this isn't necessary. CNC machines can be quite a bit bigger than a 3D printer, so homing and resuming movements could take a while.
                                      • Return to saved XY coordinates - could be a rapid move
                                      • Turn the spindle on - at the saved spindle speed
                                      • Return to saved Z coordinates - slowly

                                      The option to Resume or Cancel the project should be included too?

                                      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

                                        @dc42
                                        Further to my comments above, which I hope other CNC users will look at and add their thoughts, is it worth considering a CNC-specific resurrect.g file, as there are a few references spurious to these machines.

                                        Here's my latest resurrect.g file with a "?" indicating the lines that may be irrelevant for CNCs...

                                        ; File "0:/gcodes/Calibration Toolpath.gcode" resume print after power failure at 2022-05-31 18:23
                                        G21
                                        G92 X368.755 Y584.170 Z47.739
                                        G60 S1
                                        ? T-1 P0 ; I'm not sure what this is for
                                        M98 P"resurrect-prologue.g"
                                        ? M116 ; not relevant for CNCs
                                        ? M290 X0.000 Y0.000 Z0.000 R0 ; is this relevant to CNCs
                                        ; Workplace coordinates
                                        G10 L2 P1 X247.00 Y534.00 Z48.05
                                        ? G10 L2 P2 X0.00 Y0.00 Z0.00 ; is this relevant to CNCs
                                        ? G10 L2 P3 X0.00 Y0.00 Z0.00 ; is this relevant to CNCs
                                        ? G10 L2 P4 X0.00 Y0.00 Z0.00 ; is this relevant to CNCs
                                        ? G10 L2 P5 X0.00 Y0.00 Z0.00 ; is this relevant to CNCs
                                        ? G10 L2 P6 X0.00 Y0.00 Z0.00 ; is this relevant to CNCs
                                        ? G10 L2 P7 X0.00 Y0.00 Z0.00 ; is this relevant to CNCs
                                        ? G10 L2 P8 X0.00 Y0.00 Z0.00 ; is this relevant to CNCs
                                        ? G10 L2 P9 X0.00 Y0.00 Z0.00 ; is this relevant to CNCs
                                        G54
                                        M106 S0.00
                                        M106 P0 S0.50
                                        ? M116 ; not relevant to CNCs
                                        ? G92 E0.00000 ; not relevant to CNCs
                                        ? M83 ; not relevant to CNCs
                                        ? M486 S-1 ; is thisrelevant to CNCs
                                        ? G17 ; is this relevant to CNCs
                                        M23 "0:/gcodes/Calibration Toolpath.gcode"
                                        M26 S2729
                                        ? G0 F6000 Z49.739 ; this should happen after XY 
                                        G0 F6000 X368.755 Y584.170
                                        ? G0 F6000 Z47.739 ; this speed is much too fast!!
                                        ? G1 F762.0 P0 ; is this relevant to CNCs
                                        G21
                                        M24
                                        

                                        I hope this helps.

                                        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 1
                                        • Nightowlundefined
                                          Nightowl @dc42
                                          last edited by Nightowl

                                          @dc42

                                          Would it be conceivable to add support for the M6 and M2 gcode commands, too?

                                          M6 would be useful as I'm using Vectric software with my machine set up as an Ooznest Workbee Z1+ 1075 with the Duet - RRF3_3(mm) post processor, which isn't allowing me to save multi-tool toolpaths. This function may be helpful for other CNC users 🙂 although I appreciate not everyone runs multi-tool files. This is a function available on my previous machine, and enabled if the machine had a tool length probe installed, to ensure the tool length is measured and the Z Work Zero height adjusted accordingly. Maybe I'm just being lazy...

                                          M2 would also be helpful for follow-on macros. I'm not sure why the spindle returns to +5mm above the Work Z Zero once the job is completed, but I would prefer it moved to a pre-defined location. I could do this with a stop.g macro, but I understand that would need the M2 gcode command in toolpath 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

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

                                            @nightowl999
                                            You have misunderstood my comments about M2
                                            It is not required for stop.g. You need M0 for that.
                                            I was pointing out that some post processors for cnc cutting machines use M2 to denote end of program, which would NOT call stop.g
                                            These systems use M0 and M1 differently as well.
                                            https://tormach.com/program-stop-and-program-end-m00-m01-m02-and-m30
                                            However as you're using a duet board you need to conform to how it uses M0 and M1
                                            That's not to say there's no case for M2, but you need to review the arguments.

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