M2 G-Code -- Reduce Y-Travel

I am using Shapeoko XXL, Carbide Motion, and Vectric V-Carve Pro (Grbl post processor).

The last step of my G-Code file is M2. This raises my spindle, pauses so I can turn off the spindle, raises the spindle and then moves the spindle straight to the back of the machine.

My work-piece is up toward the front of the machine. I would like to stop the Y movement so that it doesn’t go all the way to the back of the machine. I would like to stop it just behind my work-piece. I am batching out parts I have to rapid move to the X0,Y0 and then run the program. I’d like to just run program…

I know I can just wipe out M2 and write other code but…
I do still like that it pauses, allows me to turn spindle off, includes a pop-up (in carbide motion) to change bit/resume, and then raises the spindle and starts the backward movement. I just don’t like that it goes all the way back.

QUESTIONS:

  • can I change the M2 line so that it does everything else and then stops the Y movement at my designated location?
  • much less desirable solution - what are the steps involved in M2 and can I actually create the code to mimic all steps of M2 except reduce the Y travel?

M2 is simply a program end command. Carbide Motion intercepts that command and does all the other stuff.

You could replace it with:
G90 ; absolute positioning
G21 ; mm mode
G53 G0 Z-5 ; raise Z to 5mm below limit
M5 ; stop spindle
G53 G0 Y-100 ; move Y back 100mm short of back limit
M30 ; program end (I think CM doesn’t act on this)

Note: That was all just typed on my phone during an episode of Cobra Kai, so test it with caution.

4 Likes

So, will the M30 command just end the program and leave everything as is or will it drive the spindle back as M2 does?

I know I need to end the program, I just don’t want anything else to happen.

I plan on running a couple quick test programs this evening to see what happens.

I thought those commands were interpreted differently by CM at one point.
If you need to remove the M30, you’ll just need to send a soft reset (can’t remember off hand how to do that with CM… been a while since I used it).
I can try something a little later in the day today and get back to you.

1 Like

Thank you @neilferreri for your help.
I did some messing around with this to try to figure out the best method (for me) to run batch jobs without the spindle traveling all the way back in the ‘Y’ direction. Basically, I want it to stay close to the job and just be able to restart after I have replaced the work piece. It does require a bit of modification to the G-Code but is simple enough. The beginning of the program is the same as all code written by Vectric VCarve but I changed the last line of code “M2”. By the way, M30 does the same thing that M2 does in Carbide Motion. Below is the code for just a simple circle profile cut. The highlighted items are the replacement for “M2”. I also removed the step to move spindle to X0Y0 and added a step to send a pop up to the screen (this gives me a chance to turn off the spindle).

T1
G17
G20
G90
G0Z0.6250 (move spindle to new Z location)
G0X0.0000Y0.0000 (move spindle to X0Y0)
S00001M3 (stop to change spindle speed; pop up window in CM)


G0X0.6250Y4.8438Z0.2500 (move spindle to new XYZ location)
G0Z0.2000 (move spindle to new Z location)
G1Z-0.0820F10.0 (move spindle to new Z location, set feed speed to 10)
G2X0.5938Y4.8750I0.0000J0.0313 (simple circular profile cut, next four steps)
G2X0.6250Y4.9063I0.0313J0.0000
G2X0.6563Y4.8750I0.0000J-0.0313
G2X0.6250Y4.8438I-0.0313J0.0000
G0Z1.250 (spindle to 1.250")
S00025M3 (stop to change spindle speed; pop up window in CM --> I am using this to turn off spindle)

G0X0.0000Y6.0000 (move spindle to new XY location)
(The program ends here with option to start job or load new file)

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.