; These are the parameters given to the subroutine ; #1 x ; #2 y ; #3 z ; #4 a ; #5 safe-Z ; #6 acceleration o sub ; set acceleration m171 p#6 ; find lateral distance # = [#1 - #<_x>] # = [#2 - #<_y>] # = sqrt[[#*#]+[#*#]] ; increase vertical max based on lateral distance, but only as far as z=20 # = [# * 0.5] #5 = [#5 + #] o1 if [#5 gt 20] #5 = 20 o1 endif ; spread rotation evenly over segments 2 and 3 # = [#5 - #3] ; down-going vertical distance # = [#4 - #<_a>] ; total rotation required # = [# / [# + #]] ; horizontal fraction of total distance of segments 2 and 3 # = [#<_a> + [# * #]] ; desired rotation at end of segment 2 ;(debug, t: #, v: #, r: # ) ; lift to safe-Z only if necessary o2 if [#5 gt #<_z>] g1 z#5 o2 endif ; backlash compensation waypoint # = #1 # = #2 ; z waypoint to ensure pure-vertical arrival at destination ; an offset of 5mm will ensure that at least the last 2.5mm is purely vertical even with blending # = [#3 + 5] ; check if x backlash compensation is needed o3 if [# gt 0] # = [#1 + 2] o3 endif ; check if y backlash compensation is needed o4 if [# gt 0] # = [#2 + 2] o4 endif g1 x# y# a# ; main horizontal movement to backlash comp waypoint, rotation waypoint, safe-Z g1 x#1 y#2 z# a#4 ; main down-going move to final x,y,rotation and pure-vertical start z g1 z#3 ; pure vertical o endsub