Hello Guest it is March 28, 2024, 05:50:42 PM

Author Topic: Run a macro from a button press??  (Read 19953 times)

0 Members and 1 Guest are viewing this topic.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Run a macro from a button press??
« Reply #20 on: September 27, 2016, 04:49:14 AM »
Ok, thanks

looks like the line should be RunScript("M889") but i had RunScript(M889)

will try again tonight ;)

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Run a macro from a button press??
« Reply #21 on: September 28, 2016, 01:25:35 PM »
Well, tried several styles of issuing a runscript command from within the macro pump and none of them worked.

The pump is running as the last attempt was...

Code: [Select]
Dim Response
If IsActive(INPUT1) Then
Response = RunScript("M889")
end if

Message "Result = " & Response

That little lot returned a value of 1, trouble is I have no idea what a result of 1 means, but it proved the pump and script is running :)

Nothing happens, no errors or any activity, if i MDI M889 it functions as expected so the target macro is fine.

Looks like runscript does not function in this version?

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Run a macro from a button press??
« Reply #22 on: September 28, 2016, 02:37:41 PM »
I remember trying this a long time ago and never got any joy but likely it was in the older versions that don't work.

See though that you are using a Mach Input, is there a reason for that? Personally I would use GetInBit(90,1) or whatever.
Hood

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Run a macro from a button press??
« Reply #23 on: September 28, 2016, 03:04:43 PM »
Thats a thought, thanks.

I'll try that way tomorrow, BUT as i said - the macro-pump does seem to be triggering its just that runscript does nothing or is not recognised?

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Run a macro from a button press??
« Reply #24 on: September 28, 2016, 03:11:36 PM »
As said I could never get it to work back in time but whether it was a broken version I tried with I am not sure as it was a long time ago.
I used MachMad from Scott Schaefer on the Beaver  Mill and it worked well, might be worth a go for all it costs.

Hood

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Run a macro from a button press??
« Reply #25 on: September 29, 2016, 04:35:31 AM »
Gonna have a poke of fun with you here Dave - but it's all done in the best possible taste  ;D

When you built your magnificent traction engines - did you have to follow any instructions? or did you just make it up as you went along?

runScript (as clearly stated in the manual) requires a fully qualified filename which is relative to the Mach install directory.

so... cutting to the chase - try this: (it works just fine here with your version of Mach3)

Code: [Select]
Const script As String = "M889"
'note: script does NOT have to be an M code

If isActive(INPUT1) Then
  If runScript("macros\" & GetActiveProfileName() & "\" & script) < 0 Then
    message "runScript failed"
  End If
End If

Note that I'm assuming you put your M889 in the macros directory for your current profile. But note that a script is NOT a macro (M code) so you can put it wherever you like.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Run a macro from a button press??
« Reply #26 on: September 29, 2016, 04:43:19 AM »
Poke fun all you like, most of the time i ask for it ;)

Got it, it was the qualified name bit i didn't grasp, there are no examples of it in the manual at all :(

I will insert your code tonight and have a go, no doubt it will run.

Thanks


BTW, the tractions engines - all you get is a set of dimensioned drawings, no instructions, no tips, how you make it is entirely up to you :)

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Run a macro from a button press??
« Reply #27 on: September 29, 2016, 04:58:36 AM »
Just one potential gotcha. You haven't said (or I missed it) what your M889 macro actually does.

How long does it take to execute?

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Run a macro from a button press??
« Reply #28 on: September 29, 2016, 05:28:55 AM »
It runs a z-height sense routine using G31, the usual style - fast then slow, using a touch-plate.

Probably takes 10-15s to run.

It will certainly take longer than the button-down time so multiple runs should be avoided there if that was the gotcha?

I also need to add in some code to prevent it running if the stop LED is off i.e. in run or feed-hold modes.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Run a macro from a button press??
« Reply #29 on: September 29, 2016, 07:23:38 AM »
OK - for that length of time and given that you only run it when no other gcode is happening, a trigger macro would be better. The problem is that you're going to be blocking the macropump. Does it matter? well - depends if you have anything else in it and how Mach will like having it blocked.