Dynamic disable/enable motors binded to one axis
This feature allows you to disable and enable each of the motors assigned to a specific axis (or several axes).
Let's consider a situation where it is necessary to control a machine with two supports. Each of them is driven by its own motor along the Z axis. In this case you can modify the M6 macro so that when changing a tool the old one is first retracted to a safe height and then the active motors are switched.
In the SwitchMotors(0, 1) function the first parameter is the motor index (starts from scratch) to disable. The second parameter is the motor index to enable. Thus the active engine will be switched from the first to the second from the list in the Settings → Motors menu when executing this command.
if (Is_THC_Mode() or Is_Oxy_Mode()) then
return
end
local toolSlot = GetSelectedToolSlot()
local previousToolSlot = GetToolSlot()
ExecuteMDI("G53 G0 Z0")
if (toolSlot == 2) then
SwitchMotors(0,1)
else
SwitchMotors(1,0)
end
local delta = 200 -- distance between two "heads"
if (toolSlot == 2 and toolSlot ~= previousToolSlot) then
local CurrX = AxisGetPos(Axis.X)
local CurrY = AxisGetPos(Axis.Y)
local NewY = CurrY - delta
ExecuteMDI("G55")
ExecuteMDI("G10L20P0 X"..str(CurrX).." Y"..str(NewY))
ExecuteMDI("G90 G0 Y"..str(CurrY))
elseif (previousToolSlot == 2 and toolSlot ~= previousToolSlot) then
local CurrX = AxisGetPos(Axis.X)
local CurrY = AxisGetPos(Axis.Y)
local NewY = CurrY + delta
ExecuteMDI("G54")
ExecuteMDI("G10L20P0 X"..str(CurrX).." Y"..str(NewY))
ExecuteMDI("G90 G0 Y"..str(CurrY))
end
SetToolSlot(toolSlot)
end
After work with the second tool is completed you can switch to using the first support using the M6T1 command, in which the SwitchMotors(1,0) function will be called. This will automatically restore the Z-axis machine coordinate to the value it had when the first motor was active.
You can use the MotorDisable and MotorEnable functions which take one parameter (the motor index) if you need to control the disable/enable of each motor separately.
The Diagnostics tab displays a red "Motor Disabled" indicator for disabled motors. Turn on all motors, i.e. return the default state, you can using the “Set active motors all” button.