Last modified by writer on 2024/06/11 14:25

Hide last authors
writer 1.1 1 {{info}}
Edgar Allan Poe 3.1 2 You must have the feature "**Dynamical motor to axis assignment**" for the function to work.  You also need to have the “**Create and edit macros**” or “**Auto Tool Change**” features to implement the motor switching logic.
writer 1.1 3 {{/info}}
4
Edgar Allan Poe 3.1 5 This feature allows you to disable and enable each of the motors assigned to a specific axis (or several axes).
writer 1.1 6
Edgar Allan Poe 3.1 7 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.
writer 1.1 8
Edgar Allan Poe 3.1 9 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.
10
writer 1.1 11 {{code language="lua"}}
12 function m6()
13 if (Is_THC_Mode() or Is_Oxy_Mode()) then
14 return
15 end
16
17 local toolSlot = GetSelectedToolSlot()
18 local previousToolSlot = GetToolSlot()
19
20 ExecuteMDI("G53 G0 Z0")
21
22 if (toolSlot == 2) then
23 SwitchMotors(0,1)
24 else
25 SwitchMotors(1,0)
26 end
27
Edgar Allan Poe 3.1 28 local delta = 200 -- distance between two "heads"
writer 1.1 29
30 if (toolSlot == 2 and toolSlot ~= previousToolSlot) then
31 local CurrX = AxisGetPos(Axis.X)
32 local CurrY = AxisGetPos(Axis.Y)
33 local NewY = CurrY - delta
34 ExecuteMDI("G55")
35 ExecuteMDI("G10L20P0 X"..str(CurrX).." Y"..str(NewY))
36 ExecuteMDI("G90 G0 Y"..str(CurrY))
37 elseif (previousToolSlot == 2 and toolSlot ~= previousToolSlot) then
38 local CurrX = AxisGetPos(Axis.X)
39 local CurrY = AxisGetPos(Axis.Y)
40 local NewY = CurrY + delta
41 ExecuteMDI("G54")
42 ExecuteMDI("G10L20P0 X"..str(CurrX).." Y"..str(NewY))
43 ExecuteMDI("G90 G0 Y"..str(CurrY))
44 end
45
46 SetToolSlot(toolSlot)
47 end
48 {{/code}}
49
Edgar Allan Poe 3.1 50 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.
writer 1.1 51
Edgar Allan Poe 3.1 52 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.
writer 1.1 53
Edgar Allan Poe 3.1 54 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.