Hello Guest it is March 28, 2024, 04:56:54 PM

Author Topic: how to stop macros from executing until 2nd cyclestart?  (Read 4183 times)

0 Members and 1 Guest are viewing this topic.

how to stop macros from executing until 2nd cyclestart?
« on: May 02, 2015, 07:31:34 AM »
When I run his macro (attached,) I wanted it to stop all activity at the statement 'DoOEMbutton(1003)', but this doesn't stop the macro call afterwards, which then executes some gcode moves when I had wanted no gcode moves...

Obviously DoOEMbutton(1003) isn't the right command to use.

What should I use instead, that will stop the macro from running (preferably as well as any gcode that's running) until I press cyclestart?

Thanks again

M21

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: how to stop macros from executing until 2nd cyclestart?
« Reply #1 on: May 02, 2015, 10:06:38 AM »
E-Stop
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: how to stop macros from executing until 2nd cyclestart?
« Reply #2 on: May 02, 2015, 10:22:57 AM »
Sorry I meant how to make the macro stop itself and wait for cyclestart to be pressed
« Last Edit: May 02, 2015, 10:25:11 AM by moorea21 »

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: how to stop macros from executing until 2nd cyclestart?
« Reply #3 on: May 02, 2015, 11:36:29 AM »
You seemed to be trying to run most of your  machine from Macros ??  NOT a good idea.  Also you are calling macros from inside macros REALLY not a good idea.  To call another macro from inside another macro Use RunScript().

To have it wait you are going to have to use a Wait Loop. I would monitor the Cycle Start LED for the trigger to end the wait  loop.


Message "Load Rack 3 and press CYCLESTART to continue"
   Sleep 3000
   DoOEMbutton(1003)
While Not GetLED(4)
Wend
   
Message" Cycle Start"

   Code "M112"



(;-) TP



« Last Edit: May 02, 2015, 11:41:19 AM by BR549 »
Re: how to stop macros from executing until 2nd cyclestart?
« Reply #4 on: May 02, 2015, 01:15:09 PM »
Ok, ta. It seems like 'Wend' is the key command I didn't understand properly, I guess it means wait, rather than 'move towards' as it would have been in Olde English, if I remember right. Anyway...

Why is it a bad idea to run bits of gcode in macros? Not even thought of that being a no-no. Not much at all of my code is in macros; it just seemed to make more sense that bits of code that will get repeated on every file I run should be coded in separately, and called as needed.

Similarly, I didn't realise that calling macros from macros can be problematic. Is it unreliable or something?

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: how to stop macros from executing until 2nd cyclestart?
« Reply #5 on: May 02, 2015, 01:47:03 PM »
Here is the problem in  a nut shell.. The Gocde side of Mach3 and the Macros side of Mach3 "CB" are NOT synced together well. One can get out of order sync from the other resulting in some ODD things occuring.  The key is you have to Safeguard the operational order of execution with wait states OR code to prevent it from happening. Also when you apply a wait state you never really know how LONG to allow so you have to add time to it incase of it running short. What can happen is it can skip OVER sections of code and the skipped code either does NOT run or is run out of order.

Another problem is the more you protect the script the LONGER it takes to run (;-) This can add unwated delays to some scripts making it drag along .


Same problem with calling a macro from a macro only worse. That is why RunScript() was developed it helps ensure the order of execution is maintained. RUNscipt() will HOLD the execution of the next line from  running UNTIL the execution of the RunScript() is finished.

NOT saying you should not run Motion and CB macro in the same script BUT be warned "There be Dragons in the woods".

I personally make the bulk of motion in a gcode program then use macros to make decisions or to program a function  and occasionally have the emacro make a NON important Motion move (positional) with safeguards.  Remember that mach3 was designed as a CNC controller not a general purpose motion controller.  Straight Gcode it does Well. Mixed not so well.

Just my opinion, Your mileage may vary (;-).

(;-) TP

(;-) TP
« Last Edit: May 02, 2015, 01:54:44 PM by BR549 »
Re: how to stop macros from executing until 2nd cyclestart?
« Reply #6 on: May 02, 2015, 02:27:00 PM »
Thanks for outlining that for me, I am now warned!

The example for runscript in the manual is a bit baffling; if I want to run a script from within a macro, do I code something like this into the macro:-

RunScript(macros/Mach2mill/M4000)

or have I misread it?

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: how to stop macros from executing until 2nd cyclestart?
« Reply #7 on: May 02, 2015, 07:18:26 PM »
I think it assumes the macro will be in the Macro directory of the current profile you are running.

For a standard Mach3 load it would be C:\mach3\macros\Mach3mill\  . That is where you put your "M4000.m1s "macro.

Then call it with RunScript("M4000")   , Note the "  " and no extension.

You need to try that as that is from memory, (;-)
Re: how to stop macros from executing until 2nd cyclestart?
« Reply #8 on: May 03, 2015, 10:10:41 AM »
You were right about errors when executing movement from macros; total mayhem. Won't be doing that again...