Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: rhtuttle on May 08, 2008, 01:58:22 PM
-
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
-
why not use the built in probe function, G31. Thats what it for.
Here is a probe in Z macro:
CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
PlateThickness = 0.062 'plate thickness
ProbeFeed = 1.0 'probing feedrate
Code "G90 F" &ProbeFeed
If GetOemLed (825)=0 Then
'Code "G4 P5" Time to get to the z-plate
Code "G31Z-1 F" &ProbeFeed
While IsMoving()
Wend
Code "G4 P0.25"
ZProbePos = GetVar(2002)
Code "G0 Z" &ZProbePos
While IsMoving ()
Wend
Call SetDro (2, PlateThickness)
Code "G4 P0.5" 'Pause for Dro to update.
Code "G0 Z 0.1" 'Change the Z retract height here
Code "(Z axis is now zeroed)"
Code "F" &CurrentFeed
Else
Code "(Plate is grounded, check connection and try again)"
Exit Sub
End If