Hello Guest it is April 29, 2024, 03:36:33 AM

Author Topic: activate macro when input is triggered  (Read 4993 times)

0 Members and 1 Guest are viewing this topic.

Offline tmead

*
  •  62 62
    • View Profile
activate macro when input is triggered
« on: March 11, 2010, 12:50:14 PM »
OK, so I found the following in a post, which is fine, except I'm stuck right at the beginning. I'm not sure where the 'trigger code box' is for option 1. I'm scared of writing a brain - out goes number 2, and I can't find anywhere to tell me which command to use to access the input in a macro. I'm assuming it must be something like GetInput (INPUT1) ?

All help welcome - I've been creating screens and simple macros for a while, but it's time to go a little further ! We're using Mach to drive lab rigs, and it's working a treat, but I want to use a couple of hardware buttons to do certain things.

Tim



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.

M333.m1s

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
   Wend
   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
   Wend
   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
Else
 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

Offline tmead

*
  •  62 62
    • View Profile
Re: activate macro when input is triggered
« Reply #1 on: March 11, 2010, 12:59:55 PM »
OK - Probably a little quick on the draw there.

I'm hoping that what I need will be in here : http://www.machsupport.com/forum/index.php/topic,12740.0.html

Tim