Swap the Y and Z Axes on a CNC router with Mach3

reverse Y and Z axes in Mach3For an upcoming project I needed to swap the Y and Z Axes on my CNC router.  There are two ways to accomplish this.

The first way is to go into the text editor on your Gcode after your CAM software generates it and do a “replace” command.  Replace Y with Z and vice versa.  Since you’re replacing one with the other, you’ll have to first replace Y or Z with another letter (like A or B) so you don’t end up with two Y’s or Z’s.  Replace this interim letter or symbol again with the actual letter you want (See this ZTW forum discussion).

The second, and best IMO, way to do this would be to swap the axes in your control software, Mach3 in this case.  In Mach3, just click on the config drop down menu then select “Ports and Pins.”  Go into the motor outputs Config screen as seen in the picture and swap the values for the axes in question.  If the screw pitches are the same, as they were for me, this is all you’d have to do.  If you’re using a different screw (like the ZTW F8 leacscrew) to control one of the axes in question,you’ll have to swap things out in the motor tuning (Config => Motor Tuning) screen as well.

clone Mach3 configurationsIf you’re planning to use this configuration more than once, you’ll probably want to clone your original configuration using the Mach3 Launcher, then do this swap.  When I did this, for some reason the jog was turned off.  You can change this in the Program Run screen under “Tool Information”, or just hit ctrl-alt-j and it will toggle the setting.

I suppose the third way to swap axes would be to draw whatever you want on the YZ plane, but I’m using Draftsight, a 2D package so I’m not sure if it can do this.  I’m not sure CAMBam, my CAM package could handle this either, so since I’m basically just doing “vertical engraving”, this seems to be the best option.

light painted pac man in greenAs for what you could use this for, if you had a non-standard setup of the new ZTW foam cutter attachment, it might be useful.  There’s a project I’ve been working on that it’s essential for, but you’ll have to check back to see what it is.  Here’s a small clue:

Edit: Answer – light painting!


  1. Great idea! I have a home built cnc machine and use Mach and CamBam… and I have done basic light painting with it, but never tried swapping the axes. I cut foam, as well, and see great possibilities. Thanks for the tips!

  2. There is a rotate plane command that accomplishes this. Just use G68 to rotate the axes and G69 to cancel rotation. Just add the amount of rotation required as an argument in the G68 command.

  3. Thank you! This helped me swapp my X and Y axis on my machine. It was driving me nuts having to flip everything around.

    Thank you again!