Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: crg001 on August 03, 2022, 11:11:33 PM

Title: Start VB Script with button wired to input
Post by: crg001 on August 03, 2022, 11:11:33 PM
Hi there.

  I have a simple VB Script to Auto Zero my spindle.  Can I run this script by pushing a button wired to an input on my machine?  I have buttons wired (start/stop etc) I want to replace one of those with running my script.

Thanks!
Title: Re: Start VB Script with button wired to input
Post by: TPS on August 05, 2022, 04:41:11 AM
basicly OEMTriggers are used like regular input's but they Special functionalty

1st. you can assign in Config->System hotkeys oemcodes to a OEMtrigger witch will be done once if OEMTrigger comes true

2nd. you can define a triggermacro by SetTriggerMacro(number)

normaly done this way.

-add for example in Config->General Config ->Initialisation string  M333, that means every time you reset M333.M1s is called

-within M333.M1s add the VB code SetTriggerMacro(334)

-assign in Config->System hotkeys oemcodes to a OEMtrigger the code 301 witch means run triggermacro

so every time the OEMTrigger Comes True the VB Code within M334.M1S will run once.

hope i was able to explain the Basics of OEMTriggers in my bad bavarian english.
Title: Re: Start VB Script with button wired to input
Post by: crg001 on August 05, 2022, 06:12:41 AM
Thank you very much. That all made complete sense! Perfect. To push it one step further, what if I had more buttons wired to inputs? With the SetTriggerMacro option, using OEM code 304, this would only allow for one macro after button push. Is there a way to set up other buttons in this way?

Thanks again for your reply it was extremely helpful!!
Title: Re: Start VB Script with button wired to input
Post by: TPS on August 05, 2022, 06:16:49 AM
the oemcode for the triggermacro is allways 301!
in my example it will allway run macro M334.M1S

within this macro you can select the oemtrigger via script:

Code: [Select]
If Oemtrigger(1) Then
     'do code for Oemtrigger1
End If

If Oemtrigger(2) Then
     'do code for Oemtrigger2
End If

'and so on
Title: Re: Start VB Script with button wired to input
Post by: crg001 on August 05, 2022, 06:19:36 AM
Perfect, thanks again!