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

    [3.5.3-SBC] Closed loop position recovery / rehoming

    Scheduled Pinned Locked Moved
    Tuning and tweaking
    1
    2
    104
    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.
    • timschneiderundefined
      timschneider
      last edited by timschneider

      Hello, I am having the following issue with my closed-loop printer in an SBC configuration using CoreXY when a ‘position error’ occurs. I get a motor driver-warning event for each motor, 2 in total, and 1 driver-error event for each motor, again 2 in total, for a total of 4 events for a full crash.

      3e2ed8ae-209b-4f0f-b1de-8e48153cdd3e-grafik.png

      content of driver-warning.g

      ; driver warning - 51.0 : 1024 ,Driver 51.0 warning: position tolerance exceeded
      
      if param.B > 0 && param.D == 0 && param.P == 1024 && move.axes[0].homed == false && move.axes[1].homed == false
        M99 ; ignore warning when drives are not homed
      
      echo "driver warning - "^{param.B}^"."^{param.D}^" : "^{param.P}^" ,"^{param.S}
      
      if !exists(global.event_driver_stall)
        global event_driver_stall = true
      
      ; check if a printjob is running 
      ; if it is a can connected driver in closed loop mode with error position tolerance exceeded (param.B > 0 && param.D == 0 && param.P == 1024)
      if job.file.fileName != null
        if param.B > 0 && param.D == 0 && param.P == 1024
          set global.event_driver_stall = true
          
          M25                                                                 ; pause print and rehome X and Y
          M207 Z{tools[0].retraction.zHop+0.2}                                ; raise z-hop 0.2mm to prevent further crashes
          M24                                                                 ; resume print
        else
          set global.event_driver_stall = false                               ; do not rehome while pausing
          G91                                                                 ; relative positioning
          G1 H2 Z0.5 F600                                                     ; lift Z relative to current position
          M568 P0 R0 S0 A0                                                    ; disable hotend
          M25                                                                 ; pause print
      

      content of driver-error.g

      ; driver-stall.g
      ; called to home x and y after stall detection
      ; driver error - 51.0 : 3072 ,Driver 51.0 error: failed to maintain position
      
      if param.B > 0 && param.D == 0 && param.P == 3072 && move.axes[0].homed == false && move.axes[1].homed == false
        M99 ; ignore warning when drives are not homed
      
      echo "driver error - "^{param.B}^"."^{param.D}^" : "^{param.P}^" ,"^{param.S}
      
      if !exists(global.event_driver_stall)
        global event_driver_stall = true
      
      ; check if a printjob is running 
      ; if it is a can connected driver in closed loop mode with failed to maintain position (param.B > 0 && param.D == 0 && param.P == 3072)
      if job.file.fileName != null
        if param.B > 0 && param.D == 0 && param.P == 3072
          set global.event_driver_stall = true
          M207 Z{tools[0].retraction.zHop+0.2}                                ; raise z-hop 0.2mm to prevent further crashes
        else
          set global.event_driver_stall = false                               ; do not rehome while pausing
          G91                                                                 ; relative positioning
          G1 H2 Z0.5 F600                                                     ; lift Z relative to current position
          M568 P0 R0 S0 A0                                                    ; disable hotend
        M25                                                                 ; pause print
      

      I have already tried to check if the printer is in the ‘pausing’ or ‘paused’ state to prevent further pauses, but the events are deferred and the first event is processed completely, including the resume print, before the second is processed.

      if state.status == "paused" || state.status == "pausing" || state.status == "resuming"
        M99 ; ignore this event - it is already handled
      

      How can I cancle pending events? or what else should I do?

      12957b46-e840-4dc5-be83-76acd45da985-grafik.png

      timschneiderundefined 1 Reply Last reply Reply Quote 0
      • timschneiderundefined
        timschneider @timschneider
        last edited by timschneider

        I came up with the following solution:

        content of driver-warning.g

        ; driver-warning.g
        ; driver warning - 51.0 : 1024 ,Driver 51.0 warning: position tolerance exceeded
        
        if param.B > 0 && param.D == 0 && param.P == 1024 && move.axes[0].homed == false && move.axes[1].homed == false
          M99 ; ignore warning when drives are not homed
        
        echo "driver warning - "^{param.B}^"."^{param.D}^" : "^{param.P}^" ,"^{param.S}
        
        if state.status == "paused" || state.status == "pausing" || state.status == "resuming"
          M99 ; ignore this event - it is already handled
        
        if !exists(global.event_driver_stall)
          global event_driver_stall = true
        
        ; check if a printjob is running 
        ; if it is a can connected driver in closed loop mode with error position tolerance exceeded (param.B > 0 && param.D == 0 && param.P == 1024)
        if job.file.fileName != null
          if param.B > 0 && param.D == 0 && param.P == 1024
            set global.event_driver_stall = true
            
            M25                                                                 ; pause print and rehome X and Y
            M207 Z{tools[0].retraction.zHop+0.2}                                ; raise z-hop 0.2mm to prevent further crashes
            set global.resume_deferred = state.upTime + 5                        ; resume print after 5 seconds
          else
            set global.event_driver_stall = false                               ; do not rehome while pausing
            G91                                                                 ; relative positioning
            G1 H2 Z0.5 F600                                                     ; lift Z relative to current position
            M568 P0 R0 S0 A0                                                    ; disable hotend
            M25                                                                 ; pause print
        

        content of driver-error.g

        ; driver-error.g
        ; called to home x and y after stall detection
        ; driver error - 51.0 : 3072 ,Driver 51.0 error: failed to maintain position
        
        if param.B > 0 && param.D == 0 && param.P == 3072 && move.axes[0].homed == false && move.axes[1].homed == false
          M99 ; ignore warning when drives are not homed
        
        echo "driver error - "^{param.B}^"."^{param.D}^" : "^{param.P}^" ,"^{param.S}
        
        if !exists(global.event_driver_stall)
          global event_driver_stall = true
        
        if state.status == "paused" || state.status == "pausing" || state.status == "resuming"
          set global.resume_deferred = 0 ; reset resume_deferred
          M99 ; ignore this event - it is already handled
        
        ; check if a printjob is running 
        ; if it is a can connected driver in closed loop mode with failed to maintain position (param.B > 0 && param.D == 0 && param.P == 3072)
        if job.file.fileName != null
          if param.B > 0 && param.D == 0 && param.P == 3072
            set global.event_driver_stall = true
            M207 Z{tools[0].retraction.zHop+0.2}                                ; raise z-hop 0.2mm to prevent further crashes
          else
            set global.event_driver_stall = false                               ; do not rehome while pausing
            G91                                                                 ; relative positioning
            G1 H2 Z0.5 F600                                                     ; lift Z relative to current position
            M568 P0 R0 S0 A0                                                    ; disable hotend
          M25                                                                 ; pause print
        

        content of daemon.g

        if exists(global.resume_deferred) && global.resume_deferred > 0 && global.resume_deferred < state.upTime
          if state.status == "paused"
            set global.resume_deferred = 0
            M24 ; resume print
        

        The magic is done by the global.resume_deferred. It is set to state.upTime + 5 which means 5 second delay.
        The flow looks like the following

        driver-warning event -> check if it is already paused if so, exit else set resume_deferred
        driver-error event -> check if it is already paused, if so, reset resume_deferred to 0 to disable it and exit 
        daemon.g -> Check whether the delay for resume_deferred has already passed, if so resume the print.
        
        1 Reply Last reply Reply Quote 1
        • First post
          Last post
        Unless otherwise noted, all forum content is licensed under CC-BY-SA