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

    Adding a Z-hop to IDEX tool changing

    Scheduled Pinned Locked Moved
    General Discussion
    2
    3
    195
    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.
    • ComedianTF2undefined
      ComedianTF2
      last edited by ComedianTF2

      Firmware version: RRF3.4.5

      I'm trying to understand proper IDEX behavior with getting everything setup with the tool changing files, and one of the things I'm trying to accomplish is having a proper Z-hop movement added to the tool changing scripts. However I'm running into an interesting issue which I suspect cannot be fixed configuration side wise, and would need to be done slicer side

      The idea is to have a Z-hop movement in the tool changing script, where the tool would move up, then away from the print, and on selecting the new tool it would move back down (the lines shown in the graphic below with the black lines). However
      with the below tool changing scripts, it moves down, then to the next object (so the green pathway)

      I was able to make a script that first moves back to the XYZ coordinates of the previous selected tool, and then go to the new XYZ coordinates, but sadly that's also not always an ideal solution (orange pathway). The code for this is in the last bit of the commented out tpost0.g and tpost1.g (so the G1 R2 Z3 X0 Y0 followed by G1 R2 Z0. I have also tried it without the G1 R2 Z0, but in that case it behaves the same as with just the G1 R2 Z3 X0 Y0)

      373c80e9-b81f-4cb9-9836-ec4869fec583-image.png

      If anyone has any things to try out, I would love to hear them, otherwise it is most likely a slicer side solution that I'll have to dig in more

      Here are the tool changing scripts:

      Tfree0.g

      ; tfree0.g
      ; called when tool 0 is freed
      ;
      if job.file.fileName = null		; Check if printing a file
      	G4 P1 		; If you're not printing, don't extrude
      else
      	if heat.heaters[0].current < 160		; check for temperature
      		G4 P1				; dont retract if heaters aren't at temperature yet
      	else
      		M83				; relative extruder moves
      		G1 E-5 F1200		; retract 5mm
      		M106 S0						; disable fan
      
      G91						; relative moves
      if {(move.axes[2].machinePosition) < (move.axes[2].max - 5)} 			; check if there is >5mm space to raise head
      	G1 Z+4.5 F3600 					; move Z up by 4.5mm
      elif {(move.axes[2].machinePosition) < (move.axes[2].max - 2)}			; if there is >2mm but <5mm
      	G1 Z+0.5 F3000					; raise by 1.5mm
      else					; if there isn't enough space, don't lift.
      	G4 P20 				; wait 20ms
      G90						; absolute XYZ moves
      
      if job.file.fileName = null			; Check if printing a file
      	G4 P1 				; If you're not printing, don't extrude
      else
      	if heat.heaters[0].current < 160			; check for temperature
      		G4 P1						; dont retract if heaters aren't enabled yet
      	else
      		G1 E-5 F3600				; retract 5mm
      
      G91                    				; relative positioning
      G1 H1 Y{(move.axes[1].max+5)*-1} F6000 			; home Y axis
      G1 H2 Y2 F3000   					; go back a few mm
      G1 H1 Y{(move.axes[1].max+5)*-1} F600			; move slowly to Y axis endstop once more (second pass)
      G4 P0					; wait for movements to complete
      G90
      

      tfree1.g

      ; tfree1.g
      ; called when tool 1 is freed
      ;
      if job.file.fileName = null			; Check if printing a file
      	G4 P1 				; If you're not printing, don't extrude
      else
      	if heat.heaters[0].current < 160			; check for temperature
      		G4 P1						; dont retract if heaters aren't at temperature yet
      	else
      		M83				; relative extruder moves
      		G1 E-5 F1200				; retract 5mm
      		M106 S0						; disable fan
      
      G91						; relative moves
      if {(move.axes[2].machinePosition) < (move.axes[2].max - 5)} 			; check if there is >5mm space to raise head
      	G1 Z+4.5 F3600 					; move Z up by 4.5mm
      elif {(move.axes[2].machinePosition) < (move.axes[2].max - 2)}			; if there is >2mm but <5mm
      	G1 Z+0.5 F3000					; raise by 1.5mm
      else					; if there isn't enough space, don't lift.
      	G4 P20 				; wait 20ms
      G90						; absolute XYZ moves
      
      if job.file.fileName = null			; Check if printing a file
      	G4 P1 				; If you're not printing, don't extrude
      else
      	if heat.heaters[0].current < 160			; check for temperature
      		G4 P1						; dont retract if heaters aren't enabled yet
      	else
      		G1 E-5 F3600				; retract 5mm
      
      ;G1 U{(move.axes[3].max-1)} F6000				; back off 1mm
      G91                    				; relative positioning
      G1 H1 U{(move.axes[3].max+100)} F6000 			; home U axis
      G1 H2 U-2 F3000   					; go back a few mm
      G1 H1 U10 F600						; move slowly to Y axis endstop once more (second pass)
      G90
      G4 P0					; wait for movements to complete
      

      tpost0.g

      ; tpost0.g
      ; called after tool 0 has been selected
      ;
      ; Wait for set temperatures to be reached
      
      if job.file.fileName = null	; if not printing
      	G4 P1 		; don't extrude
      elif job.file.fileName != null			; When printing
      	if heat.heaters[0].current > 180	; and the nozzle is heated to printing temperatures
      		M116 P0 S5			; wait till printing temperature has been reached within 5c
      		G4 P0				; wait
      		M83		; relative extrusion
      		G1 E15 F500			; extrude 5mm
      		G4 P0				; wait
      		M106 R2				; restore fan speed
      		G1 E1 F500			; extrude 1mm
      	else
      		G4 P1
      G4 P0
      
      if job.file.fileName = null	; if not printing
      	if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed || !move.axes[3].homed 	; if axes aren't homed
      		G28		; home all axes
      	else
      		G4 P1				; wait 1ms
      ;elif job.file.fileName != null			; When printing
      ;	G4 P1		; wait 1ms
      ;	G1 R2 Z3 X0 Y0 F6000	; go back to 3mm above last position
      ;	G4 P0		; wait
      ;	G1 R2 Z0				; go back to the Z height of the last print
      

      tpost1.g

      ; tpost1.g
      ; called after tool 1 has been selected
      ;
      ; Wait for set temperatures to be reached
      
      if job.file.fileName = null	; if not printing
      	G4 P1 		; don't extrude
      elif job.file.fileName != null			; When printing
      	if heat.heaters[1].current > 180	; and the nozzle is heated to printing temperatures
      		M116 P0 S5			; wait till printing temperature has been reached within 5c
      		G4 P0				; wait
      		M83		; relative extrusion
      		G1 E15 F500			; extrude 5mm
      		G4 P0				; wait
      		M106 R2				; restore fan speed
      		G1 E1 F500			; extrude 1mm
      	else
      		G4 P1				; wait 1ms
      G4 P0			; wait
       
      if job.file.fileName = null				; if not printing
      	if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed || !move.axes[3].homed 	; if axes aren't homed
      		G28					; home all axes
      	else
      		G4 P1
      ;elif job.file.fileName != null			; When printing
      ;	G4 P1		; wait 1ms
      ;	G1 R2 Z3 X0 Y0 F6000	; go back to 3mm above last position
      ;	G4 P0		; wait
      ;	G1 R2 Z0				; go back to the Z height of the last print
      
      T3P3Tonyundefined 1 Reply Last reply Reply Quote 0
      • T3P3Tonyundefined
        T3P3Tony administrators @ComedianTF2
        last edited by

        @ComedianTF2 said in Adding a Z-hop to IDEX tool changing:

        G1 R2 Z3 X0 Y0 F6000

        The issue here is of course the "last position" which G1 R2 is restoring to is object a not object b, in fact the position for object b is not yet known when the toolchange is called as it is yet to be sent by the slicer, its sent after to the tool change.

        I think there needs to be slicer input here, this could be done in the slicer tool change macros if the the slicer exposes the next tool start position as a variable.

        www.duet3d.com

        ComedianTF2undefined 1 Reply Last reply Reply Quote 0
        • ComedianTF2undefined
          ComedianTF2 @T3P3Tony
          last edited by ComedianTF2

          @T3P3Tony Thanks, I had assumed so but was a good one to check. Will look at the slicer side for getting things working there.

          What I do wonder is if it would be possible for the nozzle to do a diagonal move (shown in purple), it always seems to get back to the previous part's Z position before starting no matter what I do. It always does the up/down motion in orange or green

          11242da2-87db-4cba-b32e-73232f8c19cc-image.png

          I tried using the following end bit in the tpost0.g and tpost1.g, but it would lower back to the Z position no matter what, even though there isn't anything in the tool changing scripts that would indicate that the Z motion should happen.

          elif job.file.fileName != null			; When printing
          	G90		; absolute positioning
          	if {(move.axes[2].machinePosition) < (move.axes[2].max - 4)} 	; if there is enough space
          		G1 Z{(move.axes[2].machinePosition)+3} 			; move up 3mm
          	else
          		G4 P1				; wait 1ms
          	G4 P0					; wait for moves to complete
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Unless otherwise noted, all forum content is licensed under CC-BY-SA