Hello Guest it is October 17, 2019, 12:50:30 PM

Author Topic: Associate script to button while running code  (Read 4473 times)

0 Members and 1 Guest are viewing this topic.

Associate script to button while running code
« on: March 08, 2013, 06:29:02 AM »
Hi guys.
Been reading this forum for some time now, learned a lot but I need help now that I could not find an answer on my own.

I would like to associate a script to a button. Something similar to E-stop, but that instead would do feedhold, stop spindle and raise the Z axis.
This is to stop program if i think the part is cut all the way trough, but still be able to resume if it is not.

I can do a script that does this, but it will not run if a program is running. I assume you can't run Gcode in a script while the main Gcode is running.

Any thoughts?
Tks

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Associate script to button while running code
« Reply #1 on: March 08, 2013, 12:08:57 PM »
DoButton(1) 'Pause
While Ismoving()
Wend
DoSpinStop() 'Stop Spindle
DoButton(3) 'Stop
GotoSafeZ()  'Raise Z to SafeZ


(;-) TP
Re: Associate script to button while running code
« Reply #2 on: March 08, 2013, 02:19:32 PM »
Tks

Will try on monday.

Rgds
Re: Associate script to button while running code
« Reply #3 on: March 22, 2013, 10:23:20 AM »
Hi.

So the thing is can't get this to run.

I have OEM Trig #1 active and associated to a pin.
A macro called M1000 with a single line : SetTriggerMacro(1001)

(M1000 is in the init line of mach3)

And a macro called M1001 with your code.

Anything missing?

Regards



Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Associate script to button while running code
« Reply #4 on: March 22, 2013, 11:58:21 AM »
Mach3 Programmers reference manual

Page 119   " SetTriggerMacro () "

It is IN the manual,

(;-) TP
Re: Associate script to button while running code
« Reply #5 on: April 02, 2013, 09:19:49 AM »
Hi

Tks for the help but i am feeling dumb here.

I i think i have done all of that.





In C:\Mach3\macros\Mach3Mill i have M1000 that just has:

Code: [Select]
SetTriggerMacro(1001)
Message "Ready" 

And the Ready prints out when mach3 starts up or i press reset.

 M1001 has the code you suggested.

But nothing happens when the pin goes low (running program or not).

To debug i used your code in a button script and that works.
Do not think it is electric issue, since it work for probe and i can see the pin go low in diag screen.

Regards
Re: Associate script to button while running code
« Reply #6 on: April 02, 2013, 09:33:13 AM »
Did another debugging test.

If i put your code in a button script it works.

But if i instead in the button script i just put CODE("M1001") nothing happens if it is moving.

It seems i can run button scripts while machine is moving but i cant call macros...

Offline BR549

*
  •  6,902 6,902
    • View Profile
Re: Associate script to button while running code
« Reply #7 on: April 02, 2013, 11:05:07 AM »
OK just tested it HERE and it works fine. So lets go over it one more time.

1 Create your macros, M1000, M1001

M1000
SetTriggerMacro(1001)
Message" TriggerMacro#1001"
End

M1001
Message "Action code completed"
END

2. On the Genconfig page place the M1000 in the initialization line , Last entry

3 Setup ports and pins for OEMtrigger#1

4 Config Hotkeys  for OEMtrigger#1  = 301

press reset and then reset again to run init string. You should see the message form the M1000 in the message line

Press your switch and you should see the message from the M1001 macro in the message line.

(;-) TP
Re: Associate script to button while running code
« Reply #8 on: April 02, 2013, 11:37:14 AM »
Hi BR549

So i already had the M1000 in init line so with your new code i get TriggerMacro#1001 when mach3 starts or i double press reset.

With your new M1001, with a simple gcode( M3, G01 X100,G01 Y100) i press the probe during the movement but i only see the message when the program ends.

If i instead i assign the code to a button script i does show up in real time.

So trying you original code if i touch the probe it seems to try to run the code on the end of the program but says nothing to feedhold.
If i instead assign it to a button it pauses when i click but then says Terminating script. From the tests i made it seems the DoButton(3) 'Stop also stops the script execution so nothing else after that is runned.

Tricky tricky

Tks

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Associate script to button while running code
« Reply #9 on: April 02, 2013, 12:03:00 PM »
With your new M1001, with a simple gcode( M3, G01 X100,G01 Y100) i press the probe during the movement but i only see the message when the program ends.

If i instead i assign the code to a button script i does show up in real time.

That's cos trigger macros are broken. I raised the problem a while back here and here but unfortunately didn't get anywhere - well apart from some grief from Terry for me asking Brian to fix it.  :P

Brian did TRY to fix it but unfortunately his fix didn't work - haven't heard anything since.

Ian