Hello Guest it is May 06, 2021, 09:02:17 PM

Author Topic: oiler woes  (Read 2139 times)

0 Members and 1 Guest are viewing this topic.

Offline mark4

*
  •  167 167
    • View Profile
oiler woes
« on: November 28, 2016, 10:45:00 PM »
hi all
i am retrofitting a bridgeport mill and the oiler is on an electric timer motor the timer orriginally ran when the spindle contactors were engaged. i have added a vfd and removed the contactors then added a relay to run the oiler. now with mach upgrade we can also probe and when probing the spindle doesnt run however we still need to run the oiler. mach 3 had a vb command ismoving and i have used this in the past effectively. i am trying to do the same with mach 4 but am still fuzzy on lua or you could say clueless. this is the code i have come up with.

if (machEnabled == 1) then
   runLube()
end
function runLube()
    local inst = mc.mcGetInstance()
    local hsig,rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT0)
    if (mc.mcCntlIsStill(inst)==1) then
        mc.mcSignalSetState(hsig, 0)
        wx.wxMessageBox("output 0 on")
    else
        mc.mcSignalSetState(hsig, 1)
        wx.wxMessageBox("output 0 off")
    end
end

this ran in plc script but didnt run when homing or when g-code was running, however when i jogged it ran as planned also i remmed out the message boxes when i saw the output working. i tried to get this to run in signal script without success. all i need is for it to turn on the output when an axis ismoving if you can help me thank you
mark

Offline mark4

*
  •  167 167
    • View Profile
Re: oiler woes
« Reply #1 on: December 02, 2016, 12:38:21 AM »
hi
the first question is where is the proper place to program this script plc or signal if i get that i can try to build it myself the problem i have is knowing where to start. thank you
Re: oiler woes
« Reply #2 on: December 02, 2016, 04:45:12 PM »
Mark4,
This should be in the signal script, just put it near the bottom before the functions are defined.   You can put the if(machEnabled ==1) above the function area where the inputs are typically checked.  The signal script runs repeatedly looking for any input changes.

Russ

Offline mark4

*
  •  167 167
    • View Profile
Re: oiler woes
« Reply #3 on: February 03, 2017, 05:10:01 PM »
hi
with a little push in the right direction from brett i added this to my plc script seem to work fine

-------------------------------------------------------
-- 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

thank you
mark
Re: oiler woes
« Reply #4 on: February 03, 2017, 06:13:51 PM »
Hi Mark4,
something to be aware of, I noted that you put a wx.wxMessageBox statement in your PLC script. I have done the same thing and crashed and
burned. The problem is that the PLC script runs repeatedly and the MessageBox will too, requiring you click OK at each occasion. The machine is
effectively stopped while the MessageBox is active and so you only have 50ms before the machine generates another MessageBox and stops.
Worse is that the PLC script is in the screen set and you will not be able to open the screen editor to remove it and a backup profile wont help
unless you backed up your screen set as well.

Daz-The-Gaz told me about a way to go straight to the editor by starting Mach4 from the Windows Command line.

I've had this problem twice, once when I put a MessageBox statement in the PLC script and on another occasion when I put one in the Signal Script.
The PLC script runs every 50ms (default) and the signal script every time one of Machs many many signals change state. Both scripts can be expected
to run many times per second. If you want to put a message on screen as digagnostic/confirmation use mc.mcCntlSetLastError() instead.

Craig
My wife left with my best friend...
     and I miss him!

Offline mark4

*
  •  167 167
    • View Profile
Re: oiler woes
« Reply #5 on: February 03, 2017, 11:52:08 PM »
hi did it to myself once go to your startup short cut and change the /p to /e this will boot you directly into the edit screen and you can change it. says that in another post just about pulled my hair out over that.
mark