Hello Guest it is April 17, 2024, 11:38:54 PM

Author Topic: "SetTriggerMacro" Function is not Working When Gcode Programs are Running  (Read 785 times)

0 Members and 1 Guest are viewing this topic.

Hello Mach3 Experts:

Thank you for providing some great information on programming Mach 3; I did not know Mach 3 had this much capability.

I used your information to turn on and off my spindle by a panel button through an external serial controlled relay. I used the "SetTriggerMacro" function to turn off the spindle during an ESTOP event.

Works great when I am not running a program. Meaning my ESTOP will trigger the set trigger Macro (M1000.m1s) and turn off my external spindle relay when Gcode programs are not running.  I ran the road runner Gcode program (Came with Mach3) to test the code on an ESTOP condition and the spindle stays on.

The code is listed below. Can any of you you provide some input of why this is happening? I appreciate your help.


Thanks,

Jim



**** M1000.m1s Macro ****

'Macro for Turning Off Spindle Relay to be Asssociated with OEM code 301

Declare Function Relay Lib "KMSerial.dll" (ByVal comPort As Integer,ByVal numberRelay As Integer,ByVal command As String) As Boolean

'Constants
LEDSindle=1000    'Spindle Status User LED Number

SetUserLED(LEDSindle,0)
a = Relay(3,1,"OFF")


**** M1001.m1s Macro ****

'Macro to Turn Off Spindle Relay on ESTOP
'OEMTrigger1 Configuration: Config>Ports and Pins> Input Signals: Parallel Port 1, Pin 10
'OEMTrigger1 Associated with OEM code 301: Config>Hot Keys Setup (External Buttons-OEM Codes), Trigger#1, OEM Code301
'SetTriggerMacro defines M-Macro 1000 (m1000.m1s) as the Macro to Execute when the OEM Button code 301 is Executed
'Now, when OEMTrigger1 is driven to it's active level, M1000.mls will be executed
'm1001.m1s Macro is activated by placing the file name in the: Config>General Logic Configuration> Startup Modals> Initialization String Line
'Use Init String on ALL "RESETS" box must be checked

SetTriggerMacro(1000)

Offline TPS

*
  •  2,505 2,505
    • View Profile
in this case i would use macropump macro and place the code there.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Thank you for taking the time to steer me in the right direction. I put some simple code into the macropump file to turn off the spindle relay and panel LED when the Emergency LED is ON (ESTOP Button Active). Works solid. Thanks again for your help.

'Macropump.m1s VB Code
'Turn Off Spindle Relay If Emergency LED is ON (ESTOP Active)

Declare Function Relay Lib "KMSerial.dll" (ByVal comPort As Integer,ByVal numberRelay As Integer,ByVal command As String) As Boolean

'Constants
LEDEmergency=19    'Spindle Status OEM LED Number
LEDSpindle=1000    'Spindle Address Number for User Spindle LED

LEDEmergencyStatus=GetOEMLed(LEDEmergency)

If GetOEMLED(LEDEmergency) Then      'If Emergency LED "ON" Turn off Spindle LED and Relay
 
SetUserLED(LEDSpindle,0)             'Turn OFF Spindle LED on Panel 
a = Relay(3,1,"OFF")               'Turn OFF Spindle Relay 

Else

'Do Nothing

End If