you guys went way over my head so i programmed it into the screen load and plc script with a few modifications
screen load
--2CNC433--Mach4 4381
pageId = 0
screenId = 0
testcount = 0
machState = 0
machStateOld = -1
machEnabled = 0
machWasEnabled = 0
inst = mc.mcGetInstance()
---------------------------------------------------------------
-- Signal Library
---------------------------------------------------------------
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
machEnabled = state;
ButtonEnable()
end,
[mc.ISIG_INPUT0] = function (state)
if (state == 1) then
wx.wxMessageBox('Way Oiler Empty Add Oil')
end
end,
[mc.ISIG_INPUT1] = function (state)
if (state == 1) then
CycleStart()
end
end,
[mc.ISIG_INPUT2] = function (state)
if (state == 1) then
mc.mcCntlFeedHold (0)
end
end,
[mc.ISIG_INPUT3] = function (state)
if (state == 1) then
CycleStop()
end
end,
[mc.ISIG_INPUT4] = function (state)
if (state == 1) then
mc.mcCntlEStop(0)
wx.wxMessageBox('Vfd Fault')
end
end,
[mc.ISIG_INPUT5] = function (state)
if (state == 1) then
mc.mcCntlEStop(0)
wx.wxMessageBox('Drive Fault')
end
end,
[mc.ISIG_INPUT9] = function (state)
if (state == 1) then
AxisSelect()
end
end,
[mc.ISIG_INPUT10] = function (state)
if (state == 1) then
AxisSelect()
end
end,
[mc.ISIG_INPUT11] = function (state)
if (state == 1) then
AxisSelect()
end
end,
[mc.ISIG_INPUT12] = function (state)
if (state == 1) then
AxisSelect()
end
end,
[mc.ISIG_INPUT13] = function (state)
if (state == 1) then
AxisSelect()
end
end,
[mc.ISIG_INPUT14] = function (state)
if (state == 1) then
IncSelect()
end
end,
[mc.ISIG_INPUT15] = function (state)
if (state == 1) then
IncSelect()
end
end,
[mc.ISIG_INPUT16] = function (state)
if (state == 1) then
IncSelect()
end
end,
and this is my plc modifications
--2CNC433--Mach4 4381
local inst = mc.mcGetInstance()
local rc = 0;
testcount = testcount + 1
machState, rc = mc.mcCntlGetState(inst);
local inCycle = mc.mcCntlIsInCycle(inst);
-------------------------------------------------------
-- Coroutine resume
-------------------------------------------------------
if (wait ~= nil) and (machState == 0) then --wait exist and state == idle
local state = coroutine.status(wait)
if state == "suspended" then --wait is suspended
coroutine.resume(wait)
end
end
---------------------------------------------------------------
--Axis Selection
---------------------------------------------------------------
function AxisSelect()
local hsigInput9, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT9)
local NoneSelected, rc = mc.mcSignalGetState(hsigInput9)
local hsigInput10, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10)
local Xselection, rc = mc.mcSignalGetState(hsigInput10)
local hsigInput11, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT11)
local Yselection, rc = mc.mcSignalGetState(hsigInput11)
local hsigInput12, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT12)
local Zselection, rc = mc.mcSignalGetState(hsigInput12)
local hsigInput13, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT13)
local Aselection, rc = mc.mcSignalGetState(hsigInput13)
if NoneSelected == 1 then
mc.mcMpgSetAxis(inst, 0, -1)
--mc.mcCntlSetLastError(inst, "No Axis Selected")
elseif Xselection == 1 then
mc.mcMpgSetAxis(inst, 0, 0)
--mc.mcCntlSetLastError(inst, "X Selected")
elseif Yselection == 1 then
mc.mcMpgSetAxis(inst, 0, 1)
--mc.mcCntlSetLastError(inst, "Y Selected")
elseif Zselection == 1 then
mc.mcMpgSetAxis(inst, 0, 2)
--mc.mcCntlSetLastError(inst, "Z Selected")
elseif Aselection == 1 then
mc.mcMpgSetAxis(inst, 0, 3)
--mc.mcCntlSetLastError(inst, "A Selected")
end
end
---------------------------------------------------------------
--Increment Selection
---------------------------------------------------------------
function IncSelect()
local hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT14)
local Step01, rc = mc.mcSignalGetState(hsig) -- increment .01
local hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT15)
local Step001, rc = mc.mcSignalGetState(hsig) -- increment .001
local hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT16)
local Step0001, rc = mc.mcSignalGetState(hsig) -- increment .0001
if Step01 == 1 then
mc.mcMpgSetInc(inst, 0, .010)
--mc.mcCntlSetLastError(inst, "X1 Selected")
elseif Step001 == 1 then
mc.mcMpgSetInc(inst, 0, .001)
--mc.mcCntlSetLastError(inst, "X10 Selected")
elseif Step0001 == 1 then
mc.mcMpgSetInc(inst, 0, .0001)
--mc.mcCntlSetLastError(inst, "X100 Selected")
end
end
-------------------------------------------------------
--Run Lube
-------------------------------------------------------
local inst = mc.mcGetInstance()
local hsig,rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT0)
if (machState == 0)then
mc.mcSignalSetState(hsig,0)
else
mc.mcSignalSetState(hsig,1)
end
now i get this error
signal script error
lua:error while running chunk
[string ""]:75:attempt to call global 'AxisSelect' (a nil function)
stack traceback
[string ""]:75: in function '?'
[string ""]:706: in function <[string ""] 703>
correct the error and restart
i also started a help ticket but here can help more people
as i said this worked fine i switched and switched and played with it. it was faster and more responsive.
then i boot up today and it gives me this error which i dont have the foggiest idea how to find much less solve.
thank you
mark