Hello Guest it is March 02, 2021, 06:47:59 AM

Author Topic: Fire macro when input is triggered.  (Read 3612 times)

0 Members and 1 Guest are viewing this topic.

Fire macro when input is triggered.
« on: April 11, 2008, 10:29:07 AM »
I'm trying to figure out how to run a macro when a momentary switch is pressed. So far I’ve got that input setup in my ports and pins as an OEMInput. How do I configure a macro to run when this input goes high? Also can anyone give me some tips on writing the macro? (I’m a programmer so the VB is no problem). I want the macro to do the following:

If machine Is Not running
1.)   Clear the ESTOP if there is one
2.)   Home the X & Y Axis
3.)   Load a GCode file even if one is already loaded.
4.)   Execute the GCode file.
5.)   Cut the grass and paint the house
    ‘Do nothing because we are already running.
End if

Offline poppabear

  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Fire macro when input is triggered.
« Reply #1 on: April 11, 2008, 12:41:37 PM »
you can do it three ways..... for example macro  "M333.m1s"

1).  Put OEM code 301 into your trigger code box next to the OEM input your bringin in. Then put SetTriggerMacro(333) into your init line under general.

2) you can use Brains: put the same init line above, then have your imput map to the terminator under buttons "execute button script"

3). You can have Macro pump watch for your trigger input to go hot, then in an if statement it can run the macro as a Code Call.

here is a Macro that does what you want.


If GetOEMLED(800) Or Not GetOEMLED(999) Then  'machine in estop or not moving so reset and load run file
   If GetOEMLED(800) Then  'if in reset
   DoOEMButton(1021)   'push reset
   End If
   Code("G4 P0.5")      'Pause here is required from first boot up to give time from reset
   While IsMoving()   'time to complete code/move
   If Not GetOEMLED(999) Then   'if machine is NOT moving (note 804 "run led" doesnt work well)
   DoOEMButton(1022)   'Home the X
   DoOEMButton(1023)   'Home the y
   While IsMoving()   'time to complete code/move
   Loadrun("C:/Mach3/GCode/mygcodefile.TAP") 'this will load and execute this file replace with your path and file
   Message("   Hey Wife, I will let you spend alot of money at walmart if you cut the grass and paint the house")
   End If
 If GetOEMLED(999) Then  'If machine is moving
 Message("     Currently Running a Part!, see if wife finished with Grass and house")
 End If
End If

'Note you will need to push the "clear" button to clear the
'messages it is next to the Reset button

'sample G code file is attached in match it to the above directory.
'the macro M333.m1s is also attached to this post

'enjoy, and welcome to the support group

'Scott S
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.