Before and after macros
-
Where are the settings, or the name of the macro I need to write, that can send the spindle to a specific location, after a job is complete.
At the moment the spindle returns to 5mm(ish) above the original start point, but I would prefer it to move to my preferred 'safe' place, or at least 3mm below Z(max). I don't want this to affect the Work Zero, so if can run the same program without having to reset the X, Y and Z Axes.
I understand I could just run a macro once the job has finished, but I'd rather it just went where I wanted it to go.
Thank you.
-
@nightowl999 said in Before and after macros:
Where are the settings, or the name of the macro I need to write, that can send the spindle to a specific location, after a job is complete.
At the moment the spindle returns to 5mm(ish) above the original start point, but I would prefer it to move to my preferred 'safe' place, or at least 3mm below Z(max). I don't want this to affect the Work Zero, so if can run the same program without having to reset the X, Y and Z Axes.
I understand I could just run a macro once the job has finished, but I'd rather it just went where I wanted it to go.
Thank you.
There are two relevant things about CNC mode that I don't know:
- if CNC mode works the same as normal "printer mode" when it comes to needing "job start" gcode and "job end" gcode
- if the program used to generate the gcode for the job has places to enter user code to be executed at the start of the job and at the end of the job
The slicers I use for printing all have a place for user code that will be executed at the start of the print job and at the end of the print job.
In those places I put M98 P"print_begin.g" and M98 P"print_end.g"
Those two files reside in the Duet sys folder and they contain the code I want to execute at those times.
Perhaps the same can be done in the CNC world.
Frederick
-
It doesn't do that specifically, although it's probably simple enough to add code at the beginning and/or the end.
Here's the start and end of a CNC toolpath...
; VECTRIC POST REVISION ; A long string of random text T1 G17 G21 G90 G0Z5.090 G0X0.000Y0.000 M3P0S18000 G0X31.755Y28.580Z5.080 G1Z-1.000F762.0 G1X71.755F3683.0 ==== Deleted code... ==== G3X107.470Y51.755I0.000J-14.285 G3X121.755Y37.470I14.285J0.000 G3X136.040Y51.755I0.000J14.285 G3X121.755Y66.040I-14.285J0.000 G1Y68.580 G3X104.930Y51.755I0.000J-16.825 G3X121.755Y34.930I16.825J0.000 G3X138.580Y51.755I0.000J16.825 G3X121.755Y68.580I-16.825J0.000 G0Z5.080 M5 G0Z5.090 G0X0.000Y0.000
...so I could add the M98 codes at the points you suggest, but I'm guessing it's the post-processor that's deciding where the spindle ends up, rather than the machine.
Hmm.
-
@nightowl999
You can create macros start.g and stop.g in the /sys directory.
If start.g is present it runs before any other code when you start a job.
You can do things like home, start spindle, start pumps etc here.
Essentially anything that is always required when a job starts.Depending on your post processor there will normally be a GCode that defined the end of the job.
RRF uses M0 or optionally M1
This needs to be at the end of your job.
It will normally run stop.g
In that you can put the code to move the tool to a safe place and do an orderly shutdown.
Be aware not all post processors will output those codes.
Some of the cnc plasma controllers use M2 to denote the end of a job.
This isn't supported in RRF
You should research all these codes and macros before use! -
That's really helpful, thank you @OwenD
As you can see from the code sample, the Vectric PP doesn't use either command at the end, but as it's being edited anyway, maybe I could add a M0 command somehow. PPs are a bit scary to me, at the moment!
-
@nightowl999
So what program do you use to generate the Gcode for your machine?
Frederick
-
@fcwilt Vectric Cut2D at the moment.
-
@nightowl999 said in Before and after macros:
@fcwilt Vectric Cut2D at the moment.
I was thinking of trying the free version to look at the issues we discussed.
What version do you use?
Frederick
-
@fcwilt I wouldn't ask you to go to that, extreme!
I'm beginning to wonder if this line of enquiry is actually worth it, to be honest.
It's not as if this is a problem, unless the moving back to Work Zero takes a direct route which could pass through an uncut piece of stock and snapping the tool - or worse.
On completing the job the Z height retracts to the rapids (safe) height in the gcode file, I think, but Z(max-3), for example, would be much better - and a lot safer!