( Simple Edge find - Tomas CNC version)
( Parameter #40 is axis )
( Parameter #50 is maximum distanse )
( Parameter #7075 - the ball diameter )

( Working cube values are situated in Parameters - )
( 5421 ... 5428 - Minimum point )
( 5431 ... 5438 - Maximum point )
( 5401 ... 5409 - Current Tool Offset )
( 5471 ... 5479 - Tool Length Sensor position )
( 5403 - Current Tool Z Offset )
( Position of Tool Sensor is situated in Parameters 5471 ... 5478 )

#10=10 (Sensor number)
#100=500 (Speed)

#111=0.0 (X)
#112=0.0 (Y)
#113=0.0 (Z)



if [ #40 eq 2 ] 200	(Z axis)
if [ #40 eq 1 ] 100	(Y axis)
(X axis)
M88 L1 P#10
G91 G0 X#50 F#100
G04 P0.5
M89 L0 P#10
G91 G0 X[0-#50] F30
G04 P0.5
if [ #50 lt 0 ] 50
( Positive direction )
G90 G10 L70 P1 X[#111-#7075/2]

GOTO 1000

N50
( Negative direction )
G90 G10 L70 P1 X[#111+#7075/2]
GOTO 1000


N100 (Y axis)
M88 L1 P#10
G91 G0 Y#50 F#100
G04 P0.5
M89 L0 P#10
G91 G0 Y[0-#50] F30
G04 P0.5
if [ #50 lt 0 ] 150
( Positive direction )
G90 G10 L70 P1 Y[#112-#7075/2]
GOTO 1000

N150
( Negative direction )
G90 G10 L70 P1 Y[#112+#7075/2]
GOTO 1000



N200 (Z axis)
M88 L1 P#10
G91 G0 Z#50 F#100
G04 P0.5
M89 L0 P#10
G91 G0 Z[0-#50] F30
G04 P0.5

G90 G10 L70 P1 Z0

N1000




