You can do an offset as Eric said, or you can write a function that adds an offset to your X, Y, and Z offsets if you want. That is how I do it for my laser’s touchplate rod. I run the touchplate routine on the rod thats mounted to my laser head, and then run the offset code that just adds the offset between where the rod is and the laser beam (which i have gotten through characterization).
The function code is:
– This function is used to set X, Y, and Z offsets from a probe that is offset
– from the actual tooling. First you use a touchplate and a probe to set the offsets to that reference,
– and then you run this function to adjust the work coordinates with respect to the probe to tooling offset.
– In the case of a laser, there is an additional Z parameter called focus offsets that lets you enter
– an additional offset to adjust focus height. This value is just added to the other Z offset, but it allows
– the user to set a fixed offset for the probe offset, and then just adjust the focus parameter based on the job’s
– beam requirements.
– NOTE: This Function should be executed AFTER the touchplate is used to set the Z of the Laser nozzle.
function SetOffsetsforLaser()
local inst = mc.mcGetInstance(“SetOffsetsforLaser()”)
if not (pf.IsHomed()) then
wx.wxMessageBox("Machine is not homed, it is not safe to perform this move")
do return end
end
–Get DRO settings
local XOffset = scr.GetProperty(‘droOffsetX’, ‘Value’) --gets dro
XOffset = tonumber(XOffset) --convert string to number
local YOffset = scr.GetProperty('droOffsetY', 'Value') --gets dro
YOffset = tonumber(YOffset) --convert string to number
local ZOffset = scr.GetProperty('droOffsetZ', 'Value') --gets dro
ZOffset = tonumber(ZOffset) --convert string to number
local LaserFocusHeight = scr.GetProperty('droLaserZ', 'Value') --gets dro
LaserFocusHeight = tonumber(LaserFocusHeight) --convert string to number
–Check that DRO settings are valid
if ((XOffset < -5) or (XOffset > 5)) then --check for valid XOffset. Adjust as needed for your machine
wx.wxMessageBox(“X Offset must be between -5 and +5”)
do return end
end
if ((YOffset < -5) or (YOffset > 5)) then --check for valid YOffset. Adjust as needed for your machine
wx.wxMessageBox("Y Offset must be between -5 and +5")
do return end
end
if ((ZOffset < -5) or (ZOffset > 5)) then --check for valid ZOffset. Adjust as needed for your machine
wx.wxMessageBox("Z Offset must be between -5 and +5")
do return end
end
if ((LaserFocusHeight > 0) or (LaserFocusHeight < -0.500)) then --check for valid Laser Focus height
wx.wxMessageBox(“Laser Focus Height must be <= Zero and > -0.500”)
do return end
end
–Print out values in log history
mc.mcCntlSetLastError(inst, "**** X Offset is: " …XOffset)
mc.mcCntlSetLastError(inst, "**** Y Offset is: " …YOffset)
mc.mcCntlSetLastError(inst, "**** Z Offset is: " …ZOffset)
mc.mcCntlSetLastError(inst, "**** LaserFocusHeight is: " …LaserFocusHeight)
–set new X Work Coordinates
local CurrentWorkCoordXAxis = mc.mcAxisGetPos(inst, mc.X_AXIS) --Get current X axis work coord
CurrentWorkCoordXAxis = tonumber(CurrentWorkCoordXAxis) --Convert string to number
mc.mcCntlSetLastError(inst, "**** Current X Axis Work Coordinate is: " …CurrentWorkCoordXAxis)
local NewWorkCoordXAxis = CurrentWorkCoordXAxis + XOffset
mc.mcCntlSetLastError(inst, "**** Setting New X Axis Work Coordinate to: " ..NewWorkCoordXAxis)
mc.mcAxisSetPos(inst, mc.X_AXIS, NewWorkCoordXAxis)
–set new Y Work Coordinates
local CurrentWorkCoordYAxis = mc.mcAxisGetPos(inst, mc.Y_AXIS) --Get current Y axis work coord
CurrentWorkCoordYAxis = tonumber(CurrentWorkCoordYAxis) --Convert string to number
mc.mcCntlSetLastError(inst, "**** Current Y Axis Work Coordinate is: " …CurrentWorkCoordYAxis)
local NewWorkCoordYAxis = CurrentWorkCoordYAxis + YOffset
mc.mcCntlSetLastError(inst, "**** Setting New Y Axis Work Coordinate to: " ..NewWorkCoordYAxis)
mc.mcAxisSetPos(inst, mc.Y_AXIS, NewWorkCoordYAxis)
–Set new Z work coordinates
local CurrentWorkCoordZAxis = mc.mcAxisGetPos(inst, mc.Z_AXIS) --Get current Z axis work coord
CurrentWorkCoordZAxis = tonumber(CurrentWorkCoordZAxis) --Convert string to number
mc.mcCntlSetLastError(inst, "**** Current Z Axis Work Coordinate is: " …CurrentWorkCoordZAxis)
local NewWorkCoordZAxis = CurrentWorkCoordZAxis + ZOffset + LaserFocusHeight
mc.mcCntlSetLastError(inst, "**** Setting New Z Axis Work Coordinate to: " ..NewWorkCoordZAxis)
mc.mcAxisSetPos(inst, mc.Z_AXIS, NewWorkCoordZAxis)
end