3040T/rectangle_probe.ngc
2023-02-05 18:45:48 +01:00

74 lines
1.7 KiB
Plaintext

( Rectangular area probe )
o<rectangle_probe> sub
#<xmin> = 0
#<xmax> = #<_hal[pyvcp.alprsx]>
#<xinterval> = #<_hal[pyvcp.alintervl]>
#<ymin> = 0
#<ymax> = #<_hal[pyvcp.alprsy]>
#<yinterval> = #<_hal[pyvcp.alintervl]>
#<zsafe> = #<_hal[pyvcp.alheight]>
#<zprobe> = 0
#<probespeed> = 50
#<xsteps> = [fix [abs[#<xmax> - #<xmin>]/#<xinterval> + 1]]
#<ysteps> = [fix [abs[#<ymax> - #<ymin>]/#<yinterval> + 1]]
O1 if[[#<xsteps>*#<xinterval>-#<xinterval>] lt #<xmax>]
#<xsteps> = [#<xsteps> + 1]
O1 endif
O2 if[[#<ysteps>*#<yinterval>-#<yinterval>] lt #<ymax>]
#<ysteps> = [#<ysteps> + 1]
O2 endif
#<points> = [#<xsteps> * #<ysteps>]
(debug, Probing #<xsteps> * #<ysteps> = #<points> points)
(LOGOPEN,probe-results.txt)
#<yct> = 0
#<xct> = 0
G53 G0 Z0
G0 X0 Y0
G30.1
G0Z#<zsafe>
F#<probespeed>
O12 while [#<yct> lt #<ysteps>]
#<xct> = 0
#<ytarget> = [#<ymin>+#<yinterval>*#<yct>]
O13 if [#<ytarget> gt #<ymax>]
#<ytarget> = #<ymax>
O13 endif
G0 Y#<ytarget>
O14 while [#<xct> lt #<xsteps>]
#<xtarget> = 0
O15 if [[#<yct>/2] - fix[#<yct>/2] eq 0]
#<xtarget> = [#<xmin> + #<xinterval> * #<xct>]
O15 else
#<xtarget> = [#<xmin> + #<xinterval> * [#<xsteps> - #<xct> - 1]]
O15 endif
O16 if [#<xtarget> gt #<xmax>]
#<xtarget> = #<xmax>
O16 endif
#<probesuccess> = 1
G0 x#<xtarget>
G38.2Z#<zprobe> (probe until contact, toward work, with error)
G0z#<zsafe>
#<probex> = [#5061+#5181]
#<probey> = [#5062+#5182]
#<probez> = #5063
(LOG,#<probex> #<probey> #<probez>)
#<xct> = [#<xct> + 1]
O14 endwhile
G0Z#<zsafe>
#<yct> = [#<yct> + 1]
O12 endwhile
(LOG,# Finished: total points = #<points>)
(LOGCLOSE)
(debug, Finished: see probe-results.txt)
G0Z#<zsafe>
G0X#<xmin>Y#<ymin>
o<rectangle_probe> endsub