----------------------------------------------------------------------------- -- Name: PMC Module --Created: 03/27/2015 ----------------------------------------------------------------------------- -- This is auto-generated code from PmcEditor. Do not edit this file! Go -- back to the ladder diagram source for changes in the logic -- U_xxx symbols correspond to user-defined names. There is such a symbol -- for every internal relay, variable, timer, and so on in the ladder -- program. I_xxx symbols are internally generated. local RouterCTP = {} local pmcvars = {} -- One local variable to conatain all pmc generated variables local hIo, hReg, hSig, rc -- Generated function for MachAPI. local function Read_Register(mInst, path) local value if (path:find('AnalogInput/')) then local index = string.gsub(path, 'AnalogInput/', '') index = tonumber(index) value, rc = mc.mcAnalogInputRead(mInst, index) if (rc == mc.MERROR_NOERROR) then return value end elseif (path:find('AnalogOutput/')) then local index = string.gsub(path, 'AnalogOutput/', '') index = tonumber(index) value, rc = mc.mcAnalogOutputRead(mInst, index) if (rc == mc.MERROR_NOERROR) then return value end else hReg, rc = mc.mcRegGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then value, rc = mc.mcRegGetValue(hReg) if (rc == mc.MERROR_NOERROR) then return value end end end return 0 end -- Generated function for MachAPI. local function Write_Register(mInst, path, value) if (path:find('AnalogOutput/')) then local index = string.gsub(path, 'AnalogOutput/', '') index = tonumber(index) rc = mc.mcAnalogOutputWrite(mInst, index, value) if (rc == mc.MERROR_NOERROR) then return end else hReg, rc = mc.mcRegGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then rc = mc.mcRegSetValue(hReg, value) if (rc == mc.MERROR_NOERROR) then return end end end return end -- Generated function for MachAPI. local function Read_Signal(mInst, path) hSig = 0 rc = mc.MERROR_NOERROR hSig, rc = mc.mcSignalGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then local state = 0; state, rc = mc.mcSignalGetState(hSig) if (rc == mc.MERROR_NOERROR) then return state end end return 0 end -- Generated function for MachAPI. local function Write_Signal(mInst, path, v) hSig = 0 rc = mc.MERROR_NOERROR hSig, rc = mc.mcSignalGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then mc.mcSignalSetState(hSig, v) end end -- Generated function for MachAPI. local function Read_Io(mInst, path) hIo = 0 rc = mc.MERROR_NOERROR hIo, rc = mc.mcIoGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then local state = 0 state, rc = mc.mcIoGetState(hIo) if (rc == mc.MERROR_NOERROR) then return state end end return 0 end -- Generated function for MachAPI. local function Write_Io(mInst, path, v) hIo, rc = mc.mcIoGetHandle(mInst, path) if (rc == mc.MERROR_NOERROR) then mc.mcIoSetState(hIo, v) end end -- Generated function for MachAPI. local function JogStart(mInst, axis, dir) local type = 0 type, rc = mc.mcJogGetType(mInst, axis) if (rc == mc.MERROR_NOERROR) then if (type == 0) then -- velocity mc.mcJogVelocityStart(mInst, axis, dir) else -- incremental local inc = 0 inc, rc = mc.mcJogGetInc(mInst, axis) if (rc == mc.MERROR_NOERROR) then inc = inc * dir mc.mcJogIncStart(mInst, axis, inc) end end end end local function JogStop(mInst, axis) local type = 0 type, rc = mc.mcJogGetType(mInst, axis) if (rc == mc.MERROR_NOERROR) then if (type == 0) then -- velocity mc.mcJogVelocityStop(mInst, axis) end end end pmcvars.I_b_mcr = 0 local function Read_I_b_mcr() return pmcvars.I_b_mcr; end local function Write_I_b_mcr(x) pmcvars.I_b_mcr = x; end pmcvars.I_b_rung_top = 0 local function Read_I_b_rung_top() return pmcvars.I_b_rung_top; end local function Write_I_b_rung_top(x) pmcvars.I_b_rung_top = x; end pmcvars.I_b_parOut_0000 = 0 local function Read_I_b_parOut_0000() return pmcvars.I_b_parOut_0000; end local function Write_I_b_parOut_0000(x) pmcvars.I_b_parOut_0000 = x; end pmcvars.I_b_parThis_0000 = 0 local function Read_I_b_parThis_0000() return pmcvars.I_b_parThis_0000; end local function Write_I_b_parThis_0000(x) pmcvars.I_b_parThis_0000 = x; end -- Generated function for signal read. local function Read_U_b_FXhomed() return Read_Signal(0, 1129) end -- Generated function for signal write. local function Write_U_b_FXhomed(v) Write_Signal(0, 1129, v) end -- Generated function for signal read. local function Read_U_b_FYhomed() return Read_Signal(0, 1130) end -- Generated function for signal write. local function Write_U_b_FYhomed(v) Write_Signal(0, 1130, v) end -- Generated function for signal read. local function Read_U_b_FZhomed() return Read_Signal(0, 1131) end -- Generated function for signal write. local function Write_U_b_FZhomed(v) Write_Signal(0, 1131, v) end -- Generated function for signal read. local function Read_U_b_FChomed() return Read_Signal(0, 1134) end -- Generated function for signal write. local function Write_U_b_FChomed(v) Write_Signal(0, 1134, v) end -- Generated function for signal read. local function Read_U_b_FJogOverride() return Read_Signal(0, 1112) end -- Generated function for signal write. local function Write_U_b_FJogOverride(v) Write_Signal(0, 1112, v) end -- Generated function for signal read. local function Read_U_b_GJogInhibit() return Read_Signal(0, 187) end -- Generated function for signal write. local function Write_U_b_GJogInhibit(v) Write_Signal(0, 187, v) end pmcvars.I_b_parOut_0001 = 0 local function Read_I_b_parOut_0001() return pmcvars.I_b_parOut_0001; end local function Write_I_b_parOut_0001(x) pmcvars.I_b_parOut_0001 = x; end pmcvars.I_b_parThis_0001 = 0 local function Read_I_b_parThis_0001() return pmcvars.I_b_parThis_0001; end local function Write_I_b_parThis_0001(x) pmcvars.I_b_parThis_0001 = x; end -- Generated function for signal read. local function Read_U_b_FVac_on() return Read_Signal(0, 1111) end -- Generated function for signal write. local function Write_U_b_FVac_on(v) Write_Signal(0, 1111, v) end pmcvars.I_b_parOut_0002 = 0 local function Read_I_b_parOut_0002() return pmcvars.I_b_parOut_0002; end local function Write_I_b_parOut_0002(x) pmcvars.I_b_parOut_0002 = x; end pmcvars.I_b_parThis_0002 = 0 local function Read_I_b_parThis_0002() return pmcvars.I_b_parThis_0002; end local function Write_I_b_parThis_0002(x) pmcvars.I_b_parThis_0002 = x; end -- Generated function for signal read. local function Read_U_b_FVac_Valve() return Read_Signal(0, 1078) end -- Generated function for signal write. local function Write_U_b_FVac_Valve(v) Write_Signal(0, 1078, v) end -- Generated function for signal read. local function Read_U_b_FPopuppins() return Read_Signal(0, 1079) end -- Generated function for signal write. local function Write_U_b_FPopuppins(v) Write_Signal(0, 1079, v) end pmcvars.I_b_parOut_0003 = 0 local function Read_I_b_parOut_0003() return pmcvars.I_b_parOut_0003; end local function Write_I_b_parOut_0003(x) pmcvars.I_b_parOut_0003 = x; end pmcvars.I_b_parThis_0003 = 0 local function Read_I_b_parThis_0003() return pmcvars.I_b_parThis_0003; end local function Write_I_b_parThis_0003(x) pmcvars.I_b_parThis_0003 = x; end -- Generated function for signal read. local function Read_U_b_FDrillbanksim() return Read_Signal(0, 1113) end -- Generated function for signal write. local function Write_U_b_FDrillbanksim(v) Write_Signal(0, 1113, v) end pmcvars.I_b_parOut_0004 = 0 local function Read_I_b_parOut_0004() return pmcvars.I_b_parOut_0004; end local function Write_I_b_parOut_0004(x) pmcvars.I_b_parOut_0004 = x; end pmcvars.I_b_parThis_0004 = 0 local function Read_I_b_parThis_0004() return pmcvars.I_b_parThis_0004; end local function Write_I_b_parThis_0004(x) pmcvars.I_b_parThis_0004 = x; end -- Generated function for signal read. local function Read_U_b_FTCUP() return Read_Signal(0, 1065) end -- Generated function for signal write. local function Write_U_b_FTCUP(v) Write_Signal(0, 1065, v) end -- Generated function for signal read. local function Read_U_b_FTooldown() return Read_Signal(0, 1068) end -- Generated function for signal write. local function Write_U_b_FTooldown(v) Write_Signal(0, 1068, v) end -- Generated function for signal read. local function Read_U_b_FToolUp() return Read_Signal(0, 1067) end -- Generated function for signal write. local function Write_U_b_FToolUp(v) Write_Signal(0, 1067, v) end pmcvars.I_b_scratch = 0 local function Read_I_b_scratch() return pmcvars.I_b_scratch; end local function Write_I_b_scratch(x) pmcvars.I_b_scratch = x; end pmcvars.I_b_oneShot_0000 = 0 local function Read_I_b_oneShot_0000() return pmcvars.I_b_oneShot_0000; end local function Write_I_b_oneShot_0000(x) pmcvars.I_b_oneShot_0000 = x; end pmcvars.I_b_parOut_0005 = 0 local function Read_I_b_parOut_0005() return pmcvars.I_b_parOut_0005; end local function Write_I_b_parOut_0005(x) pmcvars.I_b_parOut_0005 = x; end pmcvars.I_b_parThis_0005 = 0 local function Read_I_b_parThis_0005() return pmcvars.I_b_parThis_0005; end local function Write_I_b_parThis_0005(x) pmcvars.I_b_parThis_0005 = x; end -- Generated function for signal read. local function Read_U_b_FTCup() return Read_Signal(0, 1065) end -- Generated function for signal write. local function Write_U_b_FTCup(v) Write_Signal(0, 1065, v) end -- Generated function for signal read. local function Read_U_b_FToolup() return Read_Signal(0, 1067) end -- Generated function for signal write. local function Write_U_b_FToolup(v) Write_Signal(0, 1067, v) end -- Call this function to retrieve the PMC cycle time interval -- that you specified in the PmcEditor. function RouterCTP.GetCycleInterval() return 10 end -- Call this function once per PLC cycle. You are responsible for calling -- it at the interval that you specified in the MCU configuration when you -- generated this code. */ function RouterCTP.PlcCycle() Write_I_b_mcr(1) -- start rung 1 Write_I_b_rung_top(Read_I_b_mcr()) -- start series [ -- start parallel [ Write_I_b_parOut_0000(0) Write_I_b_parThis_0000(Read_I_b_rung_top()) -- start series [ -- start contact [ if (Read_U_b_FXhomed() == 0) then Write_I_b_parThis_0000(0) end -- ] finish contact -- start contact [ if (Read_U_b_FYhomed() == 0) then Write_I_b_parThis_0000(0) end -- ] finish contact -- start contact [ if (Read_U_b_FZhomed() == 0) then Write_I_b_parThis_0000(0) end -- ] finish contact -- start contact [ if (Read_U_b_FChomed() == 0) then Write_I_b_parThis_0000(0) end -- ] finish contact -- ] finish series if (Read_I_b_parThis_0000() == 1) then Write_I_b_parOut_0000(1) end Write_I_b_parThis_0000(Read_I_b_rung_top()) -- start contact [ if (Read_U_b_FJogOverride() == 0) then Write_I_b_parThis_0000(0) end -- ] finish contact if (Read_I_b_parThis_0000() == 1) then Write_I_b_parOut_0000(1) end Write_I_b_rung_top(Read_I_b_parOut_0000()) -- ] finish parallel -- start coil [ if (Read_I_b_rung_top() == 1) then Write_U_b_GJogInhibit(0) end -- ] finish coil -- ] finish series -- start rung 2 Write_I_b_rung_top(Read_I_b_mcr()) -- start series [ -- start parallel [ Write_I_b_parOut_0001(0) Write_I_b_parThis_0001(Read_I_b_rung_top()) -- start contact [ if (Read_U_b_FXhomed() == 1) then Write_I_b_parThis_0001(0) end -- ] finish contact if (Read_I_b_parThis_0001() == 1) then Write_I_b_parOut_0001(1) end Write_I_b_parThis_0001(Read_I_b_rung_top()) -- start contact [ if (Read_U_b_FYhomed() == 1) then Write_I_b_parThis_0001(0) end -- ] finish contact if (Read_I_b_parThis_0001() == 1) then Write_I_b_parOut_0001(1) end Write_I_b_parThis_0001(Read_I_b_rung_top()) -- start contact [ if (Read_U_b_FZhomed() == 1) then Write_I_b_parThis_0001(0) end -- ] finish contact if (Read_I_b_parThis_0001() == 1) then Write_I_b_parOut_0001(1) end Write_I_b_parThis_0001(Read_I_b_rung_top()) -- start contact [ if (Read_U_b_FChomed() == 1) then Write_I_b_parThis_0001(0) end -- ] finish contact if (Read_I_b_parThis_0001() == 1) then Write_I_b_parOut_0001(1) end Write_I_b_rung_top(Read_I_b_parOut_0001()) -- ] finish parallel -- start contact [ if (Read_U_b_FJogOverride() == 1) then Write_I_b_rung_top(0) end -- ] finish contact -- start coil [ if (Read_I_b_rung_top() == 1) then Write_U_b_GJogInhibit(1) end -- ] finish coil -- ] finish series -- start rung 3 Write_I_b_rung_top(Read_I_b_mcr()) -- start series [ -- start contact [ if (Read_U_b_FVac_on() == 1) then Write_I_b_rung_top(0) end -- ] finish contact -- start parallel [ Write_I_b_parOut_0002(0) Write_I_b_parThis_0002(Read_I_b_rung_top()) -- start coil [ if (Read_I_b_parThis_0002() == 1) then Write_U_b_FVac_Valve(1) end -- ] finish coil if (Read_I_b_parThis_0002() == 1) then Write_I_b_parOut_0002(1) end Write_I_b_parThis_0002(Read_I_b_rung_top()) -- start coil [ if (Read_I_b_parThis_0002() == 1) then Write_U_b_FPopuppins(0) end -- ] finish coil if (Read_I_b_parThis_0002() == 1) then Write_I_b_parOut_0002(1) end Write_I_b_rung_top(Read_I_b_parOut_0002()) -- ] finish parallel -- ] finish series -- start rung 4 Write_I_b_rung_top(Read_I_b_mcr()) -- start series [ -- start contact [ if (Read_U_b_FVac_on() == 0) then Write_I_b_rung_top(0) end -- ] finish contact -- start parallel [ Write_I_b_parOut_0003(0) Write_I_b_parThis_0003(Read_I_b_rung_top()) -- start coil [ if (Read_I_b_parThis_0003() == 1) then Write_U_b_FVac_Valve(0) end -- ] finish coil if (Read_I_b_parThis_0003() == 1) then Write_I_b_parOut_0003(1) end Write_I_b_parThis_0003(Read_I_b_rung_top()) -- start coil [ if (Read_I_b_parThis_0003() == 1) then Write_U_b_FPopuppins(1) end -- ] finish coil if (Read_I_b_parThis_0003() == 1) then Write_I_b_parOut_0003(1) end Write_I_b_rung_top(Read_I_b_parOut_0003()) -- ] finish parallel -- ] finish series -- start rung 5 Write_I_b_rung_top(Read_I_b_mcr()) -- start series [ -- start contact [ if (Read_U_b_FDrillbanksim() == 0) then Write_I_b_rung_top(0) end -- ] finish contact -- start parallel [ Write_I_b_parOut_0004(0) Write_I_b_parThis_0004(Read_I_b_rung_top()) -- start coil [ if (Read_I_b_parThis_0004() == 1) then Write_U_b_FTCUP(0) end -- ] finish coil if (Read_I_b_parThis_0004() == 1) then Write_I_b_parOut_0004(1) end Write_I_b_parThis_0004(Read_I_b_rung_top()) -- start coil [ if (Read_I_b_parThis_0004() == 1) then Write_U_b_FTooldown(0) end -- ] finish coil if (Read_I_b_parThis_0004() == 1) then Write_I_b_parOut_0004(1) end Write_I_b_parThis_0004(Read_I_b_rung_top()) -- start coil [ if (Read_I_b_parThis_0004() == 1) then Write_U_b_FToolUp(1) end -- ] finish coil if (Read_I_b_parThis_0004() == 1) then Write_I_b_parOut_0004(1) end Write_I_b_rung_top(Read_I_b_parOut_0004()) -- ] finish parallel -- ] finish series -- start rung 6 Write_I_b_rung_top(Read_I_b_mcr()) -- start series [ -- start contact [ if (Read_U_b_FDrillbanksim() == 1) then Write_I_b_rung_top(0) end -- ] finish contact -- start one shot rising [ Write_I_b_scratch(Read_I_b_rung_top()) if (Read_I_b_oneShot_0000() == 1) then Write_I_b_rung_top(0) end Write_I_b_oneShot_0000(Read_I_b_scratch()) -- ] finish one shot rising -- start parallel [ Write_I_b_parOut_0005(0) Write_I_b_parThis_0005(Read_I_b_rung_top()) -- start coil [ if (Read_I_b_parThis_0005() == 1) then Write_U_b_FTCup(1) end -- ] finish coil if (Read_I_b_parThis_0005() == 1) then Write_I_b_parOut_0005(1) end Write_I_b_parThis_0005(Read_I_b_rung_top()) -- start coil [ if (Read_I_b_parThis_0005() == 1) then Write_U_b_FTooldown(1) end -- ] finish coil if (Read_I_b_parThis_0005() == 1) then Write_I_b_parOut_0005(1) end Write_I_b_parThis_0005(Read_I_b_rung_top()) -- start coil [ if (Read_I_b_parThis_0005() == 1) then Write_U_b_FToolup(0) end -- ] finish coil if (Read_I_b_parThis_0005() == 1) then Write_I_b_parOut_0005(1) end Write_I_b_rung_top(Read_I_b_parOut_0005()) -- ] finish parallel -- ] finish series end return RouterCTP