Hello Guest it is April 19, 2024, 09:08:34 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Ya-Nvr-No

461
Mach4 General Discussion / Re: Signal Scripts
« on: May 04, 2014, 02:27:01 PM »
Quote
Brian had said put this script === Then in the signal script I do this:

ahh... based on that I need to pass the
sig = THE_SIGNAL_NAME_I_want_to_use;

I though sig was looking at all the inputs and just looking for the changing state

462
Mach4 General Discussion / Re: Signal Scripts
« on: May 04, 2014, 01:57:32 PM »
I posted everything above in the text file

but here is just the PLC script

Code: [Select]
local inst = mc.mcGetInstance();
local rc = 0;
testcount = testcount + 1
machState, rc = mc.mcCntlGetState(inst);
local inCycle = mc.mcCntlIsInCycle(inst);

--mc.mcCntlSetLastError(inst, 'machWasEnabled = ' .. tostring (machWasEnabled) .. 'machEnabled = ' .. tostring(machEnabled));

if ((machWasEnabled == 0) and (machEnabled == 1)) then
    --mc.mcCntlSetLastError(inst, 'Enable!');
    scr.SetProperty('btnEnable', 'Label', 'Disable');
    scr.SetProperty('btnEnable', 'Bg Color', '#FF0000');

    --Enable controls!
elseif ((machWasEnabled == 1) and (machEnabled == 0)) then
    --mc.mcCntlSetLastError(inst, 'Disable!');
    scr.SetProperty('btnEnable', 'Label', 'Enable');
    scr.SetProperty('btnEnable', 'Bg Color', '');

    --Diaable controls!
    scr.SetProperty('CycleStart', 'Enabled', '0');

    enableBlink = 0;
    enableBlinkCount = 0;
end

--Blink the enable button.
if (machEnabled == 0) then
    enableBlinkCount = enableBlinkCount + 1;
    --mc.mcCntlSetLastError(inst, 'enableBlinkCount = ' .. tostring(enableBlinkCount));
    if (enableBlinkCount == 10) then
        enableBlink = not enableBlink;
        --mc.mcCntlSetLastError(inst, 'enableBlink = ' .. tostring(enableBlink));
        if (enableBlink == true) then
            scr.SetProperty('btnEnable', 'Bg Color', '#00FF00');
        elseif(enableBlink == false) then
            scr.SetProperty('btnEnable', 'Bg Color', '');
        end
        enableBlinkCount = 0;
    end
end

if ((machState ~= machStateOld) or (machEnable ~= machWasEnabled)) then
    local enaCycleStart = ((machState == mc.MC_STATE_IDLE) or (machState == mc.MC_STATE_HOLD)
            or (machState == mc.MC_STATE_FRUN_PROBE_FH)
            or (machState == mc.MC_STATE_FRUN_THREAD_FH)
            or (machState == mc.MC_STATE_FRUN_MACROH)
            or (machState == mc.MC_STATE_MRUN_FH)
            or (machState == mc.MC_STATE_FRUN_FH)
            or (machState == mc.MC_STATE_MRUN_PROBE_FH)
            or (machState == mc.MC_STATE_MRUN_THREAD_FH)
            or (machState == mc.MC_STATE_MRUN_MACROH)
            or (machState == mc.MC_STATE_FRUN_SINGLE_BLOCK))
    enaCycleStart = (enaCycleStart and (machEnabled == 1))

    local enaStop = (machState ~= mc.MC_STATE_IDLE) and (machEnabled == 1) and (machState ~= mc.MC_STATE_JOG)
    local enaFeedHold = (machState ~= mc.MC_STATE_IDLE) and (machEnabled == 1) and (machState ~= mc.MC_STATE_JOG)
    local enaReset = (machEnabled == 1) and (machState == mc.MC_STATE_IDLE)
    local enaJog = ((machState == mc.MC_STATE_IDLE) or (machState == mc.MC_STATE_HOLD)
            or (machState == mc.MC_STATE_FRUN_PROBE_FH)
            or (machState == mc.MC_STATE_JOG)
            or (machState == mc.MC_STATE_FRUN_THREAD_FH)
            or (machState == mc.MC_STATE_FRUN_MACROH)
            or (machState == mc.MC_STATE_FRUN_MACROH_JOG)
            or (machState == mc.MC_STATE_MRUN_FH)
            or (machState == mc.MC_STATE_FRUN_FH)
            or (machState == mc.MC_STATE_MRUN_PROBE_FH)
            or (machState == mc.MC_STATE_MRUN_THREAD_FH)
            or (machState == mc.MC_STATE_FRUN_FH_JOG)
            or (machState == mc.MC_STATE_MRUN_MACROH)
            or (machState == mc.MC_STATE_MRUN_MACROH_JOG))
    enaJog = (enaJog and (machEnabled == 1))
   
    if (enaCycleStart) then
        scr.SetProperty('btnCycleStart', 'Enabled', '1');
    else
        scr.SetProperty('btnCycleStart', 'Enabled', '0');
    end

    if (enaStop) then
        scr.SetProperty('btnStop', 'Enabled', '1');
    else
        scr.SetProperty('btnStop', 'Enabled', '0');
    end

    if (enaFeedHold) then
        scr.SetProperty('btnFeedHold', 'Enabled', '1');
    else
        scr.SetProperty('btnFeedHold', 'Enabled', '0');
    end

    if (enaReset) then
        scr.SetProperty('btnReset', 'Enabled', '1');
    else
        scr.SetProperty('btnReset', 'Enabled', '0');
    end

--    if (enaJog) then
--        scr.SetProperty('pnlJog', 'Enabled', '1');
--        JogEnable();
--    else
--        scr.SetProperty('pnlJog', 'Enabled', '0');
--    end
end

if (machEnabled ~= machWasEnabled) then
    scr.SetProperty('btnRefAll', 'Enabled', tostring(machEnabled));
    scr.SetProperty('btnRefAll2', 'Enabled', tostring(machEnabled));
    scr.SetProperty('btnGotoZero', 'Enabled', tostring(machEnabled));
    scr.SetProperty('tabJogging', 'Enabled', tostring(machEnabled));
    if (machEnabled == 1) then
        AxisEnable();
    end
end

SigLib = {
    --Enable
    [mc.OSIG_MACHINE_ENABLED] = function (state)
        machEnabled = state;
    end,
    --HeadUp
    [mc.ISIG_INPUT1] = function (on_off)--mc.ISIG_INPUT1
        if( on_off==1 ) then
            -- On
        else
            -- Off
        end
    end,
    --HeadDn
    [mc.ISIG_INPUT2] = function (state)--mc.ISIG_INPUT2
        if( state == 1 ) then
            -- On
        else
            -- Off Call A function here if you wanted
        end
    end,
  [mc.ISIG_INPUT3] = function (state)--mc.ISIG_INPUT3 --Used as an enable button
        if( state == 1 ) then
            local inst= mc.mcGetInstance();
            local reg = mc.mcSignalGetHandle(inst, mc.OSIG_MACHINE_ENABLED)
            state = mc.mcSignalGetState(reg);
            if(state == 1)then
                state = 0
            else
                state = 1
            end
            mc.mcCntlEnable(inst, state);
        end
    end,
    [mc.ISIG_INPUT4] = function (state)--mc.ISIG_INPUT2 button to do feed hold
        if( state == 1 ) then
            local inst= mc.mcGetInstance();
            mc.mcCntlFeedHold(inst)
        end
    end,
    [mc.ISIG_INPUT5] = function (state)--mc.ISIG_INPUT2
        if( state == 1 ) then
            CycleStart() --Run my cycle start function
        end
    end
}

--local CurrentLine = scr.GetProperty('droCurrent', 'Value', mc.mcCntlGetGcodeLineNbr);
local TotalLines = mc.mcCntlGetGcodeLineCount(inst);
local GcodeCurrentLine = mc.mcCntlGetGcodeLineNbr(inst);
local GcodePercent = (GcodeCurrentLine/TotalLines) * 100;

--scr.SetProperty('droCurrent', 'Value', tostring(CurrentLine));
scr.SetProperty('droTotal', 'Value', tostring(TotalLines+1));
scr.SetProperty('droPercent', 'Value', tostring(GcodePercent));

local Xval = mc.mcAxisGetPos(inst,0);
local Yval = mc.mcAxisGetPos(inst,1);
local Zval = mc.mcAxisGetPos(inst,2);

getAngle(Xval,Yval);
scr.SetProperty('droXY', 'Value', tostring(angle));
getAngle(Xval,Zval);
scr.SetProperty('droXZ', 'Value', tostring(angle));
getAngle(Yval,Zval);
scr.SetProperty('droYZ', 'Value', tostring(angle));

getHypot(Xval,Yval);
scr.SetProperty('droXYhyp', 'Value', tostring(Hyp));
getHypot(Xval,Zval);
scr.SetProperty('droXZhyp', 'Value', tostring(Hyp));
getHypot(Yval,Zval);
scr.SetProperty('droYZhyp', 'Value', tostring(Hyp));

--This is the last thing we do.  So keep it at the end of the script!
machStateOld = machState;
machWasEnabled = machEnabled;


463
Mach4 General Discussion / Re: Signal Scripts
« on: May 04, 2014, 01:43:35 PM »

I see the sig and the state it is looking for,
Have keyboard emulation signal Input 5 setup as function key F2
Just cant get by the startup error to try it out for the cycle start button.
when the script is not running I can trigger the output led I created so I know that's working.


464
Mach4 General Discussion / Re: Signal Scripts
« on: May 04, 2014, 12:34:03 PM »
If I just change screen sets to one that does not have your script in it, I still have the same issue until I restart Mach4. Then the Enable/Disable buttons works correct again and the emulation keys work. Makes me think it is tied in to the machine.ini file too.

465
Mach4 General Discussion / Re: Signal Scripts
« on: May 04, 2014, 10:23:10 AM »
Here is my complete Lua script
other than the rem lines, please enlighten me, what causes your Signal Script not to work for me?
when rem's are removed and restarted the error message shows.
The Green Disable button only flashes and does not visually change states when pressed.

This ability to see everything, is priceless, and think their file should be posted when having issues.

So that everyone knows; the "Lua Script" (found under the Operator Menu) has every script for everything in your selected running screen.set

466
Mach4 General Discussion / Re: Signal Scripts
« on: May 04, 2014, 08:52:49 AM »
"had to comment this out to get the enable button to work again."

Nothing works if I dont rem them out

467
Mach4 General Discussion / Re: Signal Scripts
« on: May 04, 2014, 08:12:01 AM »
After adding and a restart I receive this Error message.

had to comment this out to get the enable button to work again.

--if(SigLib[sig] ~= nil)then
--SigLib[sig](state);
--end

468
General Mach Discussion / Re: probe guard
« on: May 04, 2014, 07:27:21 AM »
Then sign me up to help in anyway. That is other than going to the airport and getting on a plane.  ;)

469
General Mach Discussion / Re: probe guard
« on: May 04, 2014, 06:51:37 AM »
Sounds great, though not sure how a g31 can trigger a disable output whenever used.

470
Mach4 General Discussion / Re: Mach4 Keyboard Emulation
« on: May 03, 2014, 08:55:02 PM »
Removed both the "mach4 inputs enabled for the three" and then "deleted the three names in the Mach4 keyboard config", seems to be working again for me.

Mine starting crashing everytime I tried to use the spindle start button, but would work running a gcode program.