Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: KatzYaakov on February 05, 2021, 06:53:53 AM

Title: service timer
Post by: KatzYaakov on February 05, 2021, 06:53:53 AM
what is the best way to make timing for auto service(like run electric oil pump)
for example each 100 working h (h can be when Enable) force lubrication 1 minutes
thanks
yaakov
Title: Re: service timer
Post by: Brian Barker on February 05, 2021, 08:29:41 AM
2 ways that are easy... You can do an on screen timer in screen edit mode OR you can make a PMC file. https://www.youtube.com/watch?v=jVhH9qyjjf0
Title: Re: service timer
Post by: KatzYaakov on February 05, 2021, 09:06:17 AM
please give me sample how do it with screen timer
,i didnt find any manual and i rea understand when you mean screen timer
Title: Re: service timer
Post by: Bill_O on February 05, 2021, 09:14:07 AM
Here is what I use.
You need to make a couple of registers also.

In PLC
-------------------------------------------------------
--  Cycle time label update
-------------------------------------------------------
--Requires a static text box named "CycleTime" on the screen
if (machEnabled == 1) then
   local running = mc.mcCntlIsInCycle(inst)
   if (running == 1) then
      local cycletime = mc.mcCntlGetRunTime(inst, time)
      scr.SetProperty("CycleTime", "Label", SecondsToTime(cycletime))
   
      --run time
      local hRun = mc.mcRegGetHandle(inst, 'iRegs0/RunningTime')
      RunTime = cycletime
      mc.mcRegSetValue(hRun, RunTime)
   
   end
end


In PLC First Run section
---------------------------------------------------------   
   --Pop up message for maintenance
   --Keep at bottom
   ---------------------------------------------------------      
   local MaintReg = mc.mcRegGetHandle(inst, 'iRegs0/MaintTime')
   local MaintRegVal = mc.mcRegGetValue(MaintReg)
   if (MaintRegVal >= 144000) then
      mc.mcRegSetValue(MaintReg, 0.0)
      wx.wxMessageBox("Please perform maintenance")
   end



In the Cycle Start function in Screen Load Script
         --Set time on Maintenance timer
         local hMaint = mc.mcRegGetHandle(inst, 'iRegs0/MaintTime')
         local MaintTime = mc.mcRegGetValue(hMaint)
         local hRunning = mc.mcRegGetHandle(inst, 'iRegs0/RunningTime')
         local RunningTime = mc.mcRegGetValue(hRunning)
         MaintTime = (MaintTime + RunningTime)
         mc.mcRegSetValue(hMaint, MaintTime)
         mc.mcRegSetValue(hRunning, 0.0)
         
Title: Re: service timer
Post by: Brian Barker on February 05, 2021, 09:22:19 AM
At the top of the screen in screen edit mode you can mouse over the icons. The 2nd one from the right looks like a stopwatch. That is an on screen timer object. Place that on the screen and you can use that to call your code at your intervals you would like.
Title: Re: service timer
Post by: KatzYaakov on February 05, 2021, 09:24:24 AM
brian its not angular meter?
Title: Re: service timer
Post by: Brian Barker on February 05, 2021, 10:57:38 AM
It is in the newer versions I guess ..... I don't run old LOL
Title: Re: service timer
Post by: KatzYaakov on February 06, 2021, 11:25:16 AM
Where can download?
Title: Re: service timer
Post by: smurph on February 06, 2021, 01:14:09 PM
http://www.machsupport.com/ftp/Mach4/DevlopmentVersions/

Get the latest one.  4609, I believe

Steve