Locking two axes; leaving one free

This may seem like an oddball request, but I’ve often found myself wishing for this feature:

I want to be able to use the CNC like a manual milling machine. I can certainly create complex multi-tool g-code procedures in Fusion 360, but sometimes (for example when I just want to cut a simple trench) all that toolpath creation is just a huge pain in the butt. So I want to be able to set my height (Z) and set the X and then lock those both in place whilst leaving the Y axis free to push by hand! I know right? People are scratching their heads. The whole purpose of a CNC is to automate… I know, I know… but…

Anyone know of a way to do this? Marlin has custom commands, but there doesn’t seem to be g-code to lock and unlock axes.

Perhaps with GRBL?

Thanks Everyone

Why not just by unplugging your Y connectors/motors ?
Quite easy if you have aviation plugs but it depends on your setup…

I am not by my machne to confirm functionality, but i think M84 does exactly what you are asking for. Try:
M84 Y
To disable y steppers.

General, you should avoid unplugging and plugging in steppers while the drives are powered.

I have also done simple linear moves with the jog buttons or simple gcode commands:
G91 ; relative positioning
G1 Y250 F600 ; move only y 250mm from where it is at 10mm/s
G90 ; restore absolute positioning


You shouldn’t unplug active motors. Unpower the controller before unplugging motors to be safe. They are a significant inductive load and can have huge voltage spikes when you break the circuit.


If you go the disable-the-stepper route, be aware that if you push your Axis too fast, you can generate current which can shut down your electronics.

Also, I’ve seen a video where the user created a movable fence and kept the router fixed. He would use the CNC like a router table and push the stock through (rather than move the router like you are planning). There is probably some safety issues using the CNC this way, but I don’t think they are any worse than you are planning.

1 Like

I don’t think you need a gcode command to “lock” an axis, as the axis is held in position as long as you don’t disable the steppers or give a movement command.

What about using the manual jog controls in something like cncjs or Repetier Host? You woudn’t have the “feel” of moving the machine by hand, but you wouldn’t need to generate gcode and would have the benefit of a DRO.


I have a button in cncjs that unlocks my X and Y axis so that when I finish a cut I can push the router out of the way but z stays engaged so it doesn’t drop to the table. No reason why you can’t do this for one axis.

@rmarino Robert, Ohh mate! This is what I was looking for the other day! M84 Y! I will test this out!

@olijouve Olijouve, I was thinking along those lines, putting in a double pole switch to disconnect the motors if there was no software option, but @jeffeb3 raises a thoughtful concern: inductive load response to disconnection.
Inductors like to keep current constant and if you disconnect them whilst they are conducting, they put up a fight to keep the current going in the form of negative voltage spikes. However, during normal stepper motor operation, the magnetic fields are forming and collapsing constantly, so the stepper drivers should handle that. They cannot have flyback diodes because they need to support current driven in both directions… Alarmingly, according to the datasheet for the DRV8825 drivers I use, the only protection circuitry they have is for over current and thermal overload - there is no advertised protection for induced voltages.

@ttraband This a good suggestion. I gave up jogging on my platform (Arduino Mega running Marlin) because its jogging is just woeful. You have to rotate the knob and stop before the movement begins, and you have no way of setting the speed or stopping it once it begins. I will look into CNCJS, from what I understand Repetier host is another 3D printer firmware… I wondered also whether the anyone uses GRBL firmware and if the jogging on that is better? What is a DRO?

@RobP This sound good, I assume you used gcode m84 for this button.

Great help guys, as always. Much appreciated.

1 Like

I use grbl firmware on the CNC shield/Arduino Uno controller in my MPCNC Burly but I haven’t tried this kind of semi-manual machining.

DRO - Digital Read Out. Shows position of tool/workpiece on a digital display rather than reading the relative marks on a handwheel.

Not sure about M84 but I used M18 X Y which disables X and Y axis but holds z. I think M17 enables the steppers

In my mental model, they do handle the current, but it is at lower voltages (because the resistance to that current is lower when they are connected). When you pull the plug, the air gap is a huge resistance, and so the voltage spike is enormous (for the same current) to close the gap.

The wall outlet can handle running a vacuum cleaner all day. But if you unplug one while it is running, it will arc and everything between the plug an sufficient metal to sink the charge is going to experience huge voltages.

In the driver, I would be worried about things like the capacitors feeling a couple hundred thousand volts for a brief moment.

I may be fear mongering. It is “accepted knowledge” to not hot ppug stepper motors, but I haven’t seen an experiment that confirms it with our hardware. It is very possible the HW is designed for that danger. There must be a lot of stepper motors coming loose every day.

1 Like

I can absolutely confirm at least one anecdotal data point. I unplugged a stepper motor from a RAMPS setup and it fried the A4988 stepper driver, instantly as far as I could tell. The driver didn’t have any marks or “magic smoke” release evidence, but it no longer moved the motor.

This was several years ago, and my experience is limited to A4988’s and RAMPS and CNC Shield setups, but I can confirm the danger is real for those situations.