This is my first attempt at writing a macro for Mach3.
All suggestions welcomed.
My approach is to take my home made probe that has 3 contact points, one on each side on one for the top.
The probe straddles the workpiece which is narrow.
I will be using the A-axis limit input to determine when the probe has made contact
sub Main
dim yStart,yMin,ymax,yMid,z as double;
rem get the yAxis value
rem increment until probe connects
yStart=getOEMdro(86)
yMax=yStart
while not getOemLed(837) do
yMax=yMax+0.0001
Code "g0 y"&yMax
wend;
rem reset and go the initial yAxis value
rem decrement until probe connects
yMin=yStart
code "g0 y"&yStart
while not getOemLed(838) do
yMin=yMin-0.0001
Code "g0 y"&yMin
wend;
rem calculate midpoint and move to it
rem set yDro to 0
yMid=yMax-yMin
code "g0 y"&yMid
setOEMDro(801,0)
rem get the zaxis value and plunge until probe connects
z=getOemDro(802) ' zDRO value
while not getOemLed(839) do
z=z-0.0001
Code "g0 y"&z
wend;
rem Set the z dro to the standard's height
setOEMdro(802,1)
end sub