Hi, I try to write some macro, one for probing on the Z axis and one to measure tool offset, with no great success.

When I run the macro for the tool offset, I don't understand why, instead of changing only the Dro(42) if also change the value of the Z Axis as well as the Z offset value Dro(49)


Those macro a a little bit mixed up since I Have try so many things

Macro to probe on the Z Axis

SetOemDro (824,2)
ProbeLength = 5.288
HauteurTable = -4.6205
HauteurMesureurOutil = -3.8295
Code"G0 G53 X-.4 Y-29.03 Z-5.5"
If GetOemLed (825) <> 0 Then '(Please, Insert Connector in PROBE INPUT)
Else
FeedCurrent = GetOemDRO(818)
Code "F5"
ZNew = Zcurrent - 12
Code "G31 Z" &ZNew
While IsMoving()
Wend
ToolPosition = GetOemDro(85)
ToolOffset = tooPosition - 3.8295
NewToolOffset = 5.288 - ToolOffset
SetOemDRO(42,NewToolOffset)
Code "G53 G0 Z-1"
Code"F" &FeedCurrent
End If


Macro for tool setter
CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
HauteurTable = -4.6205
ProbeLenght = 4.6102
ProbeFeed = 4.0 'probing feedrate
Tool_Num = GetDRO(24)
ZHomeSwitch = 0
SetDro(24,1)
Code "G90 F" &ProbeFeed
If GetOemLed (825)=0 Then
Code "G31Z-5 F" &ProbeFeed
While IsMoving()
Wend
Code "G4 P0.25"
ZProbePos = GetVar(2002)
Code "G0 Z" &ZProbePos
While IsMoving ()
Wend
PositionApresPalpage = GetDro(802)
PositionZG54= ZHomeSwitch-PositionApresPalpage
Call SetDro (2,0)
Call SetDro (18,PositionApresPalpage)
Code "G4 P0.5" 'Pause for Dro to update.
Code "G0 G53 Z -0.5" '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

The length of the probe is 5.288(from under the spindle)
When I probe the table top, this give a value of -4.620
If I add 5.288 + 4.620 this give 9.908 from under the spindle to the table top
When I probe the tool setter, this give me a value of -3.8295
If I add 5.288 + 3.8295, this give 9.175 under the spindle to the tool setter
For the G54, this would be 9.908 - 5.288 - DroZ
The tool setter is fixed on the side of the table

I have trouble to put the result in the Dro

I have many problems using GetVar(2002)
What is the difference between an OemDro and Dro

Any help would be greatly appreciated. Thanks