Hello Guest it is April 25, 2024, 05:57:53 AM

Author Topic: Z positioning gets disturbed during headswap  (Read 553 times)

0 Members and 1 Guest are viewing this topic.

Offline DAAD

*
  •  103 103
    • View Profile
Z positioning gets disturbed during headswap
« on: November 28, 2020, 02:30:00 PM »
Hello,

At the moment i have a working dual head setup with some hickups:

If i probe both spindles after each other, all is good. If i don't (because only one tool gets changed), strange things happen with my Z offset.
The spindle last probed is correct, but the other spindle gets the wrong settings, as if some measures get accumulated.

Same thing happens when i put the call for the module function in a toggle button. If i manually swap between the router and spindle, the z value keeps adding up and i loose my correct Z height.

Strangest thing is this works perfectly during usage with my m6 file. Ik can swap multiple times between router/spindlewithout losing my Z refence height. This can be done for multiple gcode files after each other also.

The problem starts when i do a button swap or don't probe both after each other..

same code used for M6/probing/button.

Do i need to tackle this differently to get these problems sorted?

code below:

Code: [Select]
function zControl.UseRouter()
if (zControl.UnmapMotors() == 1) then  --Return out of UseRouter if unmapmotors returns an error
return 1 --failure
end

mc.mcAxisMapMotor(inst, mc.Z_AXIS, Router)
mc.mcAxisMapMotor(inst, mc.A_AXIS, Spindle)
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_X, OffsetX)
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Y, OffsetY)
local TempZ = mc.mcAxisGetPos(inst, mc.Z_AXIS) -- Get work position of Z-Axis
local TempA = mc.mcAxisGetPos(inst, mc.A_AXIS) -- Get work position of A-Axis
mc.mcAxisSetPos(inst, mc.A_AXIS, TempZ) -- Replace A-axis value with Z value
mc.mcAxisSetPos(inst, mc.Z_AXIS, TempA) -- Replace Z-axis value with A value
local h_OUTPUT4 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT4) --Spindle-Router swap output
local h_OUTPUT5 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5) --Spindle dust pneumatics
local h_OUTPUT6 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6) --Router dust pneumatics
mc.mcSignalSetState(h_OUTPUT4, 0)
mc.mcSignalSetState(h_OUTPUT5, 0)
mc.mcSignalSetState(h_OUTPUT6, 1)
--mc.mcSignalSetState(h_RELAY2, 1) --Future dust collection
local axisID, rc = mc.mcMotorGetAxis(inst,Router) --Z axis maakt deel uit van variable rc om return code te bekomen
local state = mc.mcSignalGetState(h_OUTPUT4)
if ((axisID == mc.Z_AXIS) and (state == 0)and (rc==mc.MERROR_NOERROR)) then
mc.mcCntlSetLastError(inst, 'Router active - Output set')
return

else
mc.mcCntlSetLastError(inst, "Router or output not activated / process stopped")
mc.mcCntlEnable (inst, false)
end
end

Code: [Select]
function zControl.UseSpindle()

if (zControl.UnmapMotors() == 1) then --Return out of UseRouter if unmapmotors returns an error
return 1 -- failure
end

mc.mcAxisMapMotor(inst, mc.Z_AXIS, Spindle)
mc.mcAxisMapMotor(inst, mc.A_AXIS, Router)
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_X, 0)
mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Y, 0)
local TempZ = mc.mcAxisGetPos(inst, mc.Z_AXIS) -- Get work position of Z-Axis
local TempA = mc.mcAxisGetPos(inst, mc.A_AXIS) -- Get work position of A-Axis
mc.mcAxisSetPos(inst, mc.A_AXIS, TempZ) -- Replace A-axis value with Z value
mc.mcAxisSetPos(inst, mc.Z_AXIS, TempA) -- Replace Z-axis value with A value
local h_OUTPUT4 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT4) --Spindle-Router swap output
local h_OUTPUT5 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5) --Spindle dust pneumatics
local h_OUTPUT6 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6) --Router dust pneumatics
--local h_RELAY2 = mc.mcSignalGetHandle(inst, mc.OSIG_MISTON) --Future dust collection
mc.mcSignalSetState(h_OUTPUT4, 1)
mc.mcSignalSetState(h_OUTPUT5, 1)
mc.mcSignalSetState(h_OUTPUT6, 0)

local axisID, rc = mc.mcMotorGetAxis(inst,Spindle) --Z axis maakt deel uit van variable rc om return code te bekomen
local state = mc.mcSignalGetState(h_OUTPUT4)
if ((axisID == mc.Z_AXIS) and (state == 1) and (rc==mc.MERROR_NOERROR)) then
mc.mcCntlSetLastError(inst, 'Spindle active - Output set')
return
else
mc.mcCntlSetLastError(inst, "Spindle or output not activated / process stopped")
mc.mcCntlEnable (inst, false)
end
end