Hello Guest it is November 18, 2019, 04:14:35 AM

Author Topic: output on/off from same button  (Read 1211 times)

0 Members and 1 Guest are viewing this topic.

Re: output on/off from same button
« Reply #10 on: April 24, 2018, 03:47:20 PM »
Hi,
sometimes it is easier to program a function, in this case a toolchange, without too many or even any interlocks. Once you have the function working THEN start applying
interlocks for safety.

If I understand your machine requires air pressure to run. Thus if you'll have an air pressure switch. It is a fairly simple matter to have the function not start if the air pressure is not OK, but what happens
if the pressure drops part way through the toolchange? I can well imagine you want your program to respond to that situation and that is very much harder. May I suggest that to start with do the easy
option and later decide whether the extra protection is really required and how you might do it.

As an example, say:
ISIG_INPUT10=air pressure OK
ISIG_INPUT11=tool present
ISIG_INPUT12=door closed

Then:
Function m6()
local hsig=mc.mcSignalGetHandle(inst,mc.ISIG_INPUT10)
AirOK=mc.mcSignalGetState(hsig)
hsig=mc.mcSignalGetHandle(inst,mc.ISIG_INPUT11)
ToolPresent=mc.mcSignalGetState(hsig)
hsig=mc.mcSignalGetHandle(inst,mc.ISIG_INPUT12)
DoorClosed=mc.mcSignalGetState(hsig)

If AirOK ~=1 then
         mc.mcCntlSetLastError(inst,' Air Pressure Fault')
         return          --If the air pressure is bad then message the fault then abort the toolchange by returning to the calling program
else
         -go to position
         -release tool
         -....
         -....       -- the body of the toolchange function
end
if (AirOK and DoorClosed and ToolPresent)==1 then
        m3
        mc.mcCntlCycleStart(inst)     -- if all the interlocks are OK THEN start the spindle and 'push' cycle start
end
end

Maybe a few ideas.

Craig
My wife left with my best friend...
     and I miss him!
Re: output on/off from same button
« Reply #11 on: April 25, 2018, 11:32:10 AM »
thanks Craig,
I had taken many steps forward, up to this problem.
do you know what it's due to?
thanks

Danilo
Re: output on/off from same button
« Reply #12 on: April 25, 2018, 11:46:20 AM »
I solved alone, it was a banality
Re: output on/off from same button
« Reply #13 on: April 25, 2018, 12:52:25 PM »
Hey Danilo
Here is a way to wait for a signal.

--Wait for signal.  
--The number on the end of the statement tells Mach how long to wait before continuing.  Use 0 on the end to wait indefinitely.  10 would be 10 seconds.  ETC...
--This is all the code you have to have to wait for a signal.

mc.mcSignalWait(inst, mc.ISIG_INPUT1, mc.WAIT_MODE_HIGH, 0)


--Wait for signal with rc.  This will let you know if there is an error while waiting for the signal.
--rc is the return code.  If it takes longer than the allotted time or another error occurs it will return something besides 0.
--if rc == 0 then there was no problem.  If rc ~= 0 there is a problem.

rc = mc.mcSignalWait(inst, mc.ISIG_INPUT1, mc.WAIT_MODE_HIGH, 0)
if (rc ~= 0 then)
    wx.wxMessageBox("There is a problem")
   mc.mcCntlCycleStop(inst)
end
« Last Edit: April 25, 2018, 12:55:30 PM by Cbyrdtopper »
Chad Byrd
Re: output on/off from same button
« Reply #14 on: April 25, 2018, 06:35:01 PM »
Hi Danilo,
I've used that API too, it works well. Be aware though it works only with input signals numbered 0 to 63,
ie ISIG_INPUT1 through ISIG_INPUT64.

Also it is highly advisable to test the return code for all possible returns, its easy to get caught out by a return
that you did not expect.

Craig
My wife left with my best friend...
     and I miss him!
Re: output on/off from same button
« Reply #15 on: April 28, 2018, 08:58:53 AM »
Hello to all guys,
Thank you so much for the support.  Now I'm able to use all the necessary safety devices in the tool change.  I have included preliminary checks in the PMC editor (door, air, etc.).
I attach my script to other users who will need it in the future, at the end, the right G43 H, which is in the tool table, is also set, the next step will be to set it automatically by a touch probe.
Use with caution.

Now the other problem is: how to behave to put the tool at 0?
I made a macro that works alone, but with the current script I can not insert it.
moreover it does not manage the tool 0, it would not know where to start to resume the selected one