OK, some weird-ass shiznit is going on.
I copied my old machine.ini to the new profile, then changed the screenset (by editing the .ini file) to point at wxLathe.set.
That worked - it started up without error, axis responded to movement, etc.
Oddly, the jogging tab is unresponsive - it won't let me click on any of the buttons in that tab. But keyboard jogging works, although only in incremental mode (?)
Next was to add the LUA that enables my control panel. So I edited the screen set, immediately saved it as something else, then copied and pasted my functions to the bottom of the screen script. Saved that, restarted the machine, and... weirdness.
Jogging using the MPG works, and the enable/speed selector switch works, but the axis select switch was backwards, and would intermittently fail. As in, Mach would detect the switch state change 100% of the time, but sometimes the code would fall through.
Let's look at this in detail:
Here is the jog axis change code:
----------------------------
-- We use MPG 7
local MachMpgNumberForPendant = 7
local PendantStepSize = 0.001
local PendantDistanceX1 = PendantStepSize * 1 -- Multiply by one (0.001)
local PendantDistanceX10 = PendantStepSize * 10 -- Multiply by ten (0.01)
local PendantDistanceX100 = PendantStepSize * 100 -- Multiply by one hundred (0.1)
-- Constants for readability
local UnmapMPG = -1 -- Use this one for when Axis selector switch is set to OFF
local AxisNumber_X = 0 -- Linear axis X
local AxisNumber_Z = 2 -- Linear axis Z
---------------------------------------------------------------
-- The Pendant's Axis switch changed.
-- Need to handle this for when the axis switch is flipped while jogging is active
---------------------------------------------------------------
function PendantAxisChange()
-- handles
local hAxis_X
local hAxis_Z
local SelectAxis_X
local SelectAxis_Z
-- Before we do anything, we need to check if the jog handle is assigned to axis -1
-- If it is, jog is DISABLED, so we do nothing (the act of enabling jog will read the axis switch)
-- Otherwise we enable jog, which is BAD
local AxisState
AxisState, rc = mc.mcMpgGetAxis(inst, MachMpgNumberForPendant)
if (AxisState ~= UnmapMPG) then
hAxis_X, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT5)
SelectAxis_X, rc = mc.mcSignalGetState(hAxis_X)
hAxis_Z, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT4)
SelectAxis_Z, rc = mc.mcSignalGetState(hAxis_Z)
-- Now actual axis Selection Switch processing code
if (SelectAxis_X == 1) then
mc.mcMpgSetAxis(inst, MachMpgNumberForPendant, AxisNumber_X) -- Map the MPG to control the X Axis
mc.mcCntlSetLastError(inst, "Pendant Axis X Selected") -- Show a message in the Screen Set
elseif (SelectAxis_Z== 1) then
mc.mcMpgSetAxis(inst, MachMpgNumberForPendant, AxisNumber_Z) -- Map the MPG to control the Z Axis
mc.mcCntlSetLastError(inst, "Pendant Axis Z Selected") -- Show a message in the Screen Set
else
-- This is a problem, because the axis select switch is one or the other
-- We have no high pin - so shut off jogging
mc.mcMpgSetAxis(inst, MachMpgNumberForPendant, UnmapMPG ) -- Unmap the MPG, so it won't control any axes
mc.mcCntlSetLastError(inst, "ABEND - no valid axis selected on control panel!") -- Show a message in the Screen Set
end
else
mc.mcCntlSetLastError(inst, "Changed axis select while jog disabled - IGNORED")
end
end
It's very straightforward. The switch on the control panel that enables jog maps the MPG to the axis when jog is active, and unmaps the MPG when jog is off. The test:
if (AxisState ~= UnmapMPG) then
checks to see if the axis is not unmapped (-1), and if it is unmapped, it falls through to
else
mc.mcCntlSetLastError(inst, "Changed axis select while jog disabled - IGNORED")
end
because an axis change request when jogging is inactive can be safely ignored, and we check the state of the jog axis select switch when we enable jogging.
But here's the weirdness:
I enable jogging.
I switch the axis switch - and it works.
I switch it back - and it works.
I switch it again - and it fails.
It isn't consistent - sometimes it fails on the first switch, sometimes the fifth. But even though jogging is still enabled and the axis is mapped, that test is failing.
Even weirder, I have a button on the control panel for manual spindle on/off (it's a lathe, I use it for tailstock drilling and polishing).
Buttons generate two signals, a PRESS and a RELEASE.
Here is the code:
---------------------------------------------------------------
-- Control Panel Manual Spindle
---------------------------------------------------------------
function InputManualSpindle()
-- Momentary pushbutton, so we get TWO signals with each button press:
-- an "ON" and an "OFF"
-- So check state and ignore the "OFF"
local hSpindleButton
local SpindleButtonState
hSpindleButton, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT8) -- signal 3
SpindleButtonState, rc = mc.mcSignalGetState(hSpindleButton)
if (SpindleButtonState == 1) then
mc.mcCntlSetLastError(inst, "Control Panel Manual Spindle PRESS")
local hsig = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEFWD)
local spinstate = mc.mcSignalGetState(hsig)
if (spindstate == 0) then -- If spindle is off, turn it on
mc.mcSignalSetState(hsig, 1)
mc.mcCntlSetLastError(inst, "Control Panel Manual Spindle ON")
else -- Otherwise, turn it off
mc.mcSignalSetState(hsig, 0)
mc.mcCntlSetLastError(inst, "Control Panel Manual Spindle OFF")
end
else
mc.mcCntlSetLastError(inst, "Control Panel Manual Spindle RELEASE")
end
end
That code now only triggers the RELEASE message, even though the Mach4 diagnostics show a distinct PRESS and RELEASE signal (and if I hold the button down, it never generates the release signal)
So the signal script is correctly catching the button press, but it is failing
hSpindleButton, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT8) -- signal 3
SpindleButtonState, rc = mc.mcSignalGetState(hSpindleButton)
if (SpindleButtonState == 1) then
in here.
Whiskey Tango Foxtrot?