Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: DAS on October 13, 2015, 11:58:08 AM

Title: HOTKEY TO OUTPUT RELAY
Post by: DAS on October 13, 2015, 11:58:08 AM
Hi all

I think this has been asked before but here goes again. I would like to set a hotkey to activate an output relay. I would like to replace or reuse one of the existing screen buttons re name it and have it activate an output relay only while the key or button is pushed. I have already done the button  in screen 4 now I need to know how to program it. I assume it needs a code installed in VB Script???? That's where I am stuck. code output  active and output deactivate   where does the code go and how do find where I put it and make it work  my output pin.
I have a keyboard full of keys to use do not really want to install a bank of switches


HELP PLEASE  DAS
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: fixittt on October 14, 2015, 07:42:09 AM
Looks like alt C is tied to the coolant so, could you not setup your output to the coolant and use that?
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: DAS on October 14, 2015, 08:28:41 AM
Hi All

the 3 available pre programmed outputs  coolant, mist and spindle ccw buttons are all in use. still need a couple more.

Thanks  DAS
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: TPS on October 15, 2015, 03:52:32 AM
Hi Das,

put this little script into the button


'GetOEMLed(77) -> Output4
'GetOEMLed(78) -> Output5
'GetOEMLed(79) -> Output6

If GetOEMLed(79) Then
   DeActivateSignal(Output6)
Else
   ActivateSignal(Output6)
End If


but dont forget to activate the output in port's & pin's

Thomas
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: DAS on October 15, 2015, 08:52:18 AM
Thanks   TPS  The code works great turns it on and off  I also need a momentary contact.  do you have a code for that.

really appreciate the info  I can build a machine  but programming codes are beyond me.

Thanks  DAS
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: TPS on October 15, 2015, 08:58:56 AM
Hello DAS,

as far i know, it is not possible to switch a output only while the key is pressed.

the macro is only trigged once when the key is pressed, not when the key ist released.
for the moment i know no way to realise this.

Thomas
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: DAS on October 15, 2015, 11:16:23 AM
I DID find a code somewhere that was for on and off but of course cant find it when you need it.Is it possible to have a code  input  4 on and then  a delay of around 5 seconds and then turn off  without pressing the button again??

Thanks   DAS
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: DAS on October 15, 2015, 01:31:01 PM
Hi All Sorry output 4 not input 4

DAS
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: TPS on October 16, 2015, 03:22:59 AM
OK,

put this code in macropump script:
Code: [Select]
If GetOEMLed(77) then ' Output4 is on
    If Timer - GetOEMDRO(1500) > 5 then
        DeActivateSignal(Output4)
    End if
Else
    SetOEMDRO(1500,Timer)
End If


make sure macropump is enabled in general config
restart Mach

Thomas
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: DAS on October 16, 2015, 01:15:11 PM
Hi TPS  tried the code even on 2 machines   it did nothing. what am I doing wrong.

DAS
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: Hood on October 16, 2015, 02:45:44 PM
If using an on screen button and putting VB in it then all you should need in the button is

ActivateSignal(OutPut4)
Sleep 5000
DeActivateSignal (OutPut4)

Hood
Title: Re: HOTKEY TO OUTPUT RELAY
Post by: DAS on October 17, 2015, 01:40:23 PM
Thanks Hood and everyone

This question was asked many times on the forum and I never found an answer   to it.

Thanks  DAS