Hello Guest it is October 19, 2019, 01:53:32 PM

Author Topic: Enable output at startup and disable output at EStop  (Read 1659 times)

0 Members and 1 Guest are viewing this topic.

Enable output at startup and disable output at EStop
« on: January 02, 2018, 10:29:52 AM »
Hi

For the turret toolchanger of my Emco C5 CNC the motor is set to reverse all the time to lock the turret. It is controlled by two direction and one PWM output.
The direction output and PWM is set in the M6 script after the toolchange and is working well so far.
Now I would like that on first startup / enable the PWM frequency and direction of the toolchange motor are set to the correct value. Also when an EStop occurs i would like to disable both direction outputs for the toolchanger so it stops immediately.
Is there a easy way to do this? As a motion controller I use PoKeys 57 CNC.

Thanks,
Martin
Re: Enable output at startup and disable output at EStop
« Reply #1 on: January 02, 2018, 10:50:34 AM »
I forgot to mention that during toolchange the direction of the motor must be reversed to change the tools. If that was not the case I would just add it to the PLC script. Or is there a way to check if a toolchange is running?
Re: Enable output at startup and disable output at EStop
« Reply #2 on: January 03, 2018, 03:54:45 AM »
After reading every post that I think has something to do with this topic I think what I want can be done with a signal script.
However I don’t know where all the available signals are documented. If someone could give me an example (see description below) it would help a lot and I think
I can do the rest from there.

-   Machine is disabled via Mach4 button or Estop (is it the same signal internally?
-   Output 1 and 2 are disabled

Martin
Re: Enable output at startup and disable output at EStop
« Reply #3 on: January 03, 2018, 05:53:02 AM »
Hi Martin,
that idea will work, the signal is ISIG_EMERGENCY. If you include it in your signal library you could easily set/reset outputs.

What happens in other situations is not clear. For instance if a limit switch goes active it is common for Mach to stop and disable. Whether that is the same as an
Estop I don't know but if it is then your outputs would not be set/reset as you desired because it was a signal OTHER than ISIG_EMERGENCY that caused it.

There are a couple of API calls that may be of use:
Quote
rc = mc.mcCntlEStop(
   number mInst)
which allows you to invoke an Estop programatically.

Quote
rc = mc.mcCntlEnable(
   number mInst,
   number state)
which allows you to enable/disable Mach at will.

Quote
mcState, rc = mc.mcCntlGetState(
      MINSTANCE mInst)
which allows you to read Machs state at any given time.

It should be easy enough to monitor signals like ISIG_EMERGENCY or maybe others signals which you have attached to screen buttons or physical switches
and they could directly cause the outputs to change in a manner that you determine. In addition it would be necessary to monitor Machs state to see if some other
event caused Mach to disable, like a limit event. The problem would be that once you detect Mach has been disabled its too late to set/reset outputs....I think!

My suggestion would be to experiment with some cut down code to determine what if any functionality remains active when Mach is disabled. If this phase/mode of
operation still allows you to set/reset outputs at will then the most problematic part of your proposal will achievable.

Craig
My wife left with my best friend...
     and I miss him!
Re: Enable output at startup and disable output at EStop
« Reply #4 on: January 03, 2018, 06:26:04 AM »
Hi,
I tried this small piece of code:

Code: [Select]
function m100()
local inst=mc.mcGetInstance()
local hsig=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT1)
mc.mcSignalSetState(hsig,1)
wx.wxMessageBox('enabled, output set')
mc.mcCntlEnable(inst,0)
mc.mcSignalSetState(hsig,0)
wx.wxMessageBox('disabled, output reset')
end
if (mc.mcInEditor()==1)then
    m100()
end

It seems to work. In order to run m100 as MDI mach must be enabled. Output#1 is set as seen on the machine diagnosics page and the message box is displayed.
When the message box is dismissed then Mach disables AND THEN Output#1 is reset and a new message box is displayed.

It would appear therefore that you could indeed monitor Machs Enable state and on Disable set/reset outputs at will despite Mach being disabled. Nifty!!

Craig
My wife left with my best friend...
     and I miss him!
Re: Enable output at startup and disable output at EStop
« Reply #5 on: January 03, 2018, 06:58:12 AM »
Hi Craig,

You are great, thank you very much for the information. I will try it as soon as i get home tonight.
Do you also know if there is a signal like  ISIG_EMERGENCY for ENABLE? When i press the estop Mach is also disabled at the same time but when i press the disable button mach is not in estop.
Therefore i would rather use the enabled signal. Maybe i don't get it and these signals are the same, i will try  :)

Martin
Re: Enable output at startup and disable output at EStop
« Reply #6 on: January 03, 2018, 07:16:31 AM »
Hi Martin,
no there is to my knowledge no signal like that. Enabled is a 'state' not a signal.

I suspect that Estop causes Mach to disable but I would also suspect that you cannot change outputs for instance when Mach is in Estop. You can however
change outputs when Mach is disabled as the little piece of code establishes. You could monitor a signal including ISIG_EMERGENCY and have it disable Mach,
change the required outputs AND THEN Estop. If however you allow the internal function to proceed the machine will Estop before you can set the outputs.

You will in effect have to monitor the Enable state.

Craig
My wife left with my best friend...
     and I miss him!
Re: Enable output at startup and disable output at EStop
« Reply #7 on: January 03, 2018, 07:48:32 AM »
Ok, i think I will start with monitoring mach's enable state.
Is there any documentation about what

mcState, rc = mc.mcCntlGetState(
      MINSTANCE mInst)

returns in enabled or disabled state

About the estop behaviour: Is there even a way to change the behaviour when an estop occurs like you described it?
I'm sorry to ask so many questions but I'm more of a mechanics guy and Mach4 and the different functions are quite overwhelming...
If nothing works, i will disable the signals with a relay :)

Martin

Offline Chaoticone

*
  • *
  •  5,607 5,607
  • Precision Chaos
    • View Profile
Re: Enable output at startup and disable output at EStop
« Reply #8 on: January 03, 2018, 09:23:11 AM »
Would this work?

Motor control
Use a relay or relays to swap rotation direction. It would be wired so that when the relay/s are off it rotates in the default direction (no output required). To change direction you fire a single output (which if I'm not mistaken will deactivate in an estop).

Motor power should come from or be made available to motor only if estop loop is closed. If estop loop opens for any reason (estop button, onscreen button, servo fault, etc.) an estop contactor should drop out removing power from the motor so that even if the control side was telling it to rotate, it couldn't.

Remember, no software should be involved in any way in an estop (or other safety) loop. Hardware and wiring strategy should put the machine in a safe state if the estop loop is broken. Only use an estop input from estop contactor to simply notify Mach an estop has occurred and stop it from running.

;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Enable output at startup and disable output at EStop
« Reply #9 on: January 03, 2018, 09:32:04 AM »
Another way you can test Mach's enabled state is to use:

   local machEnbld = mc.mcSignalGetState (mc.mcSignalGetHandle (inst, mc.OSIG_MACHINE_ENABLED))

This returns 0 or 1.

Allan