Author Topic: Mach4 ESS Signal Script for Estop Noob ?  (Read 1327 times)

0 Members and 1 Guest are viewing this topic.

Offline lrid

  • Holding
  • Posts: 2
    • View Profile
Mach4 ESS Signal Script for Estop Noob ?
« on: April 16, 2017, 08:46:12 PM »
Hi everyone
This is probably a really easy fix but what i am trying to do is get a signal output when the Estop state changes. I would easily wire the estop to the the indicator but the logic is reversed for the Estop switch. So the system is a ESS the Estop switch functionality works in MACH4 with the diagnostics, i did setup the profile using the setup from ESS then i changed the panel load to be wx4 as stated in other posts to enable the signal script. i have the output signal tied to Output0 on MACH and mapped to port2pin1. the start script is below i do not see, any indication that the change is happening in diagnostics nor do i see it on a meter the code below is only that function

Code: [Select]
inst = mc.mcGetInstance()

---------------------------------------------------------------
-- Signal Library
---------------------------------------------------------------
SigLib = {
[mc.OSIG_MACHINE_ENABLED] = function (state)
    machEnabled = state;
    ButtonEnable()
end,

--[mc.ISIG_INPUT0] = function (state)
 --       mc.OSIG_OUTPUT0 = state
--end,

--[mc.ISIG_INPUT1] = function (state)
 --   mc.OSIG_OUTPUT0 = state
   -- if (state == 1) then   
--        CycleStart()
--    --else
--        --mc.mcCntlFeedHold (0)
--    end

--end,
[mc.ISIG_EMERGENCY] = function (state)
    mc.OSIG_OUTPUT0 = state
end,

[mc.OSIG_JOG_CONT] = function (state)
    if( state == 1) then
       scr.SetProperty('labJogMode', 'Label', 'Continuous');
       scr.SetProperty('txtJogInc', 'Bg Color', '#C0C0C0');--Light Grey
       scr.SetProperty('txtJogInc', 'Fg Color', '#808080');--Dark Grey
    end
end,

[mc.OSIG_JOG_INC] = function (state)
    if( state == 1) then
        scr.SetProperty('labJogMode', 'Label', 'Incremental');
        scr.SetProperty('txtJogInc', 'Bg Color', '#FFFFFF');--White   
        scr.SetProperty('txtJogInc', 'Fg Color', '#000000');--Black
   end
end,

[mc.OSIG_JOG_MPG] = function (state)
    if( state == 1) then
        scr.SetProperty('labJogMode', 'Label', '');
        scr.SetProperty('txtJogInc', 'Bg Color', '#C0C0C0');--Light Grey
        scr.SetProperty('txtJogInc', 'Fg Color', '#808080');--Dark Grey
        --add the bits to grey jog buttons becasue buttons can't be MPGs
    end
end,


--M6 messagebox
[mc.OSIG_TOOL_CHANGE] = function (state)
    local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)

if (selectedtool ~= currenttool) then
        if( state == 1) then
            mm.ToolChangeMsg("A tool change has been requested via M6. Change your tool then press Cycle Start to continue!", "Tool Change Active!")
        end
    end
end