Hi Mav,
FYI, the wizard you downloaded is mill specific, and geared towards working in X/Y plane. I'm working on a lathe specific version (X/Z plane). What you have may not do what you want, and may have issues if you are in 'diameter mode' on lathe.
I don't know why your code wouldn't work, do you have DRO 818 and 1151 in your lathe screenset somewhere for the macro to pull values? that's all I can think of. I can just MDI G31 commands, and they work for me.
Here is some rough code that I've used before to set the XDRO to a value based on a measured part (ie, if put a 2.0" bar in, I have to touch off and set X=2.0). Note this is some rough code based on cutting/pasting a portion out of a larger script, and I've replaced some references to DROs with just numbers so it should run if you just paste it into a button. I don't guarantee it is error free
test with care.
Not sure if it helps, but hope it does.
regards,
Eric
'set some variable, these are hard code for paste to button, but you could load DRO values...
frate1=1 ' feedrate
Xstart=GetoemDRO(800) 'current position
Probemax=1.0
Xset=2.0 ' this is the diameter of the stock to touch off on
Xend=Xstart-probemax
xretract=.1 ' how far to pull back after touch
hittol=.002 ' this is a small amount to see if hit or missed
' here is probing
Code "G31 x" & xend & "F" & FRate1
While IsMoving()
wend
'================
xhit = GetVar(2000)
yhit = GetVar(2001)
ZHit = GetVar(2002)
if xhit=0 and yhit=0 and zhit=0 then
sleep(15)
xhit = getoemdro(800)
yhit = getoemdro(801)
zhit = getoemdro(802)
else
end if
'=================
if abs(xHit-xend)<HitTol then
message "missed target"
code "G01 x" & xstart
while ismoving()
wend
exit sub
end if
'xset = xset + (ProbeD/2) ' Adjust up by Probe Radius to set Z at ball center (you may not want this, as I do this when using a probe with ball tip)
SetoemDRO(800, xset) ' Set XDRO to center of ball, bottom of ball as surface variable.
sleep(1000)
xclear= xset+Abs(xretract) ' retract away after touch.
Code "G0 x"&xclear
While IsMoving()
Wend
And a similar snippet for probing from right to left in Z
'set some variable, these are hard code for paste to button, but you could load DRO values...
frate1=1 ' feedrate
Zstart=GetoemDRO(802)
Probemax=1.0
Zset=2
Zend=Zstart-probemax
zretract=.1
hittol=.002 ' this is a small amount to see if hit or missed
Code "G31 z" & zend & "F" & FRate1
While IsMoving()
wend
'================
xhit = GetVar(2000)
yhit = GetVar(2001)
ZHit = GetVar(2002)
if xhit=0 and yhit=0 and zhit=0 then
sleep(15)
xhit = getoemdro(800)
yhit = getoemdro(801)
zhit = getoemdro(802)
else
end if
'=================
if abs(ZHit-zend)<HitTol then
message "missed target"
code "G01 z" & zstart
while ismoving()
wend
exit sub
end if
'zset = zset + (ProbeD/2) ' Adjust up by Probe Radius to set Z at ball center (you may not want this)
SetoemDRO(802, zset) ' Set ZDRO to center of ball, bottom of ball as surface variable.
sleep(1000)
Zclear= zset+Abs(zretract)
Code "G0 z"&zclear
While IsMoving()
Wend