Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
GCODE to ease delta tower home positioning; script for generating a homing script
; generated with
; curl -s https://gist.github.com/kastner/4772276/raw/e0f0fc66793eacc3f94fd8961e391b6499ad71b0/homward.rb | ruby -- - -77.94 -45 0 10
G28
G1 Z10 F80000
; center
G1 X0 Y0 F80000
G1 Z0 F1000
G4 S1
; visit all three towers and their oppisites
G1 Z10 F1000
G1 X-77.94 Y-45 F80000
G1 Z0 F1000
G4 S1
G1 Z10 F1000
G1 X77.94 Y-45 F80000
G1 Z0 F1000
G4 S1
G1 Z10 F1000
G1 X0 Y90 F80000
G1 Z0 F1000
G4 S1
G1 Z10 F1000
G1 X-77.94 Y45 F80000
G1 Z0 F1000
G4 S1
G1 Z10 F1000
G1 X77.94 Y45 F80000
G1 Z0 F1000
G4 S1
G1 Z10 F1000
G1 X0 Y-90 F80000
G1 Z0 F1000
G4 S1
; home
G28
; disable motors
M84
#! /usr/bin/env ruby
bx = ARGV[0] && ARGV[0].to_f || -77.94
by = ARGV[1] && ARGV[1].to_f || -45
z_down = ARGV[2] && ARGV[2].to_f || 0
z_up = ARGV[3] && ARGV[3].to_f || 10
sleep = 1
fast = 80000
slow = 1000
dance = ""
[[bx,by],[-bx,by],[0,-(by*2)],[bx,-by],[-bx,-by],[0,(by*2)]].each do |x,y|
# puts (y==45)
# y = (y == weird_y) ? -weird_y : weird_y
# y = -1 * y if y >=2 && y < 0
td = <<-EOF
G1 Z#{z_up} F#{slow}
G1 X#{x} Y#{y} F#{fast}
G1 Z#{z_down} F#{slow}
G4 S#{sleep}
EOF
dance << td.gsub(/^\s*/,'')
end
puts <<-EOF
; generated with
; curl -s https://gist.github.com/kastner/4772276/raw/e0f0fc66793eacc3f94fd8961e391b6499ad71b0/homward.rb | ruby -- - -77.94 -45 0 10
G28
G1 Z#{z_up} F#{fast}
; center
G1 X0 Y0 F#{fast}
G1 Z0 F#{slow}
G4 S#{sleep}
; visit all three towers and their oppisites
#{dance}
; home
G28
; disable motors
M84
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment