MPCNC part 6

By telleropnul, July 19, 2019

MPCNC Marlin config

This is where I keep my current MPCNC config in case I have to reflash it:

Single endstops software enabled (G53 Xpos Ypos only) –
Single endstops software disabled –

It is now time to plot the obligatory MPCNC crown test pattern with a pen holder and pen.

MPCNC Sharpie / Pen holder

Crown test


This is the actual result of the very first time the machine was used to plot a file.  I had to restart the operation as the pen tip was a fraction too close to the surface and started dragging.  The second attempt completed successfully.

Fusion 360


Rename *.txt to *.cps and place inside “C:\Users\…\Appdata\Roaming\Autodesk\Fusion 360 CAM\Posts”

When generating Gcode in Fusion360 select “Setup” and select ‘Use Personal Posts’ from the drop down list.


So as a first attempt I created a drill grid for a 920x920mm spoilboard consisting of a 9 x 9 points grid with 100mm spacing and a 60mm edge perimeter:

I then generated a center drilling toolpath and loaded the MPCNC Fusion360 Post processor to generate Gcode:

I had to leave some holes out as the machine could not reach.

The resulting code looks as follows: spoilboard.gcode

When I ran the Gcode on the machine I realized my machine does not do absolute negative machine coordinates.  I have dual steppers enabled, but not dual endstops (X1min + X2min + Y1min + Y2min) in Config_adv.h.  I do however have Xmin and Ymin enabled in Config.h.  I do not have limit switches installed as of yet.  As soon as you have Xmin and Ymin enabled, the machine will force you to stay within the bed area.  This means absolute negative machine coordinates are not allowed; you cannot move beyond the lower left corner.  When I power up the machine with the spindle located in the center of the spoilboard, this effectively becomes X0 Y0 Z0 and I cannot move to the left or to the bottom from here as that is considered outside of the bed area.

G54 Work (offset) Coordinates

I tried this:

  • Place the spindle in the bottom left corner as if Xmin and Ymin limit switches endstops had been triggered.
  • This would be my machine coordinates origin X0 Y0 Z0 when I power up the machine and gives me positive machine coordinates for all my moves from here.
  • Power up the machine
  • Enter G21 for millimeters.
  • Enter G91 for relative coordinates.
  • Use G0 X… Y… to move the spindle to the center of the spoilboard.
  • Switch to work offset coordinates system G54.
  • Zero the X and Y work coordinates.
  • Adjust spindle height and zero Z height.

This should enable me to use positive machine coordinate throughout and be able to run my Gcode using work (offset) coordinates from the center of the spoilboard, using both positive and negative move values.

Note that CNC.js sends a G10 L20 P1 X0 Y0 to zero the work coordinates.  Marlin firmware does not support G10 L20 P1 X0 Y0 commands.

A more detailed explanation can be found here:

‘P’ represents work coordinate system (1-6) and corresponds to G54 – G59, respectively.   G53 is the machine coordinate system.  Marlin does support G54 – G59 work coordinate systems:

* CNC Coordinate Systems
* Enables G53 and G54-G59.3 commands to select coordinate systems
* and G92.1 to reset the workspace to native machine space.

CNC_Coordinate_Systems is enabled in my [Configuration_adv.h].  However, Marlin does not recognize G10 L20 P1 X0 Y0 Z0 commands unfortunately.

I have lodged a feature request with the great developer community of Marlin:


G55 Work (offset) Coordinates + G92 X0 Y0

G10 L20 P1 X0 Y0 Z0 is identical to executing G54 followed by G92 X0 Y0 Z0 and then returning to the original coordinate system.

I did some more research and discovered Marlin treats G53 (machine coordinate system) and G54 (1st work offset coordinate system) the same.  You cannot set a new origin in G54 without it also affecting the origin of G53 and vice versa (!)

I have reported this as a bug on the Marlin github page issue tracker:

I discovered using G55 (2nd work offset coordinate system) works fine however.  I have implemented a bugfix that allows G54 to work as well.

So all I have to do is the following:

  1. Power up MPCNC machine with spindle in lower left corner.
  2. G21 ; millimeters
  3. G90 ; absolute coords or G91; relative coords
  4. G0 X270 Y340 ; move to center of spoil board.  Make sure CNC.js Axes widget shows machine / work offset coordinates.  Do not move spindle by hand (!)  You can use keypad jogging.
  5. G54 ; Switch to 1st work offset coordinate system
  6. G92 X0 Y0 Z0 ; set new origin
  7. G91 ; relative coords – this isn’t strictly necessary as the Gcode script should always specify G20/G21 (inches / millimeters) and G90/G91 (absolete coords / relative coords) in the header.  Most scripts would use G91 anyway as all movement is relative to the origin.
  8. Run my Gcode script.

I tested this and it works properly.  Xmin and Ymin enstop positions also work correctly and are relative to the G53 machine coordinate system origin as they should.  Even if I am in G54 I cannot go past Xmin and Ymin, which is a nice safety feature.

The one disadvantage is that CNC.js Axes widget does not display work (offset) coordinates.  This is because Marlin only outputs a single set of coordinates at a time.

More detailed information here:

CNC.js keypad jogging

In order to use CNC.js keypad jogging you will need to first disable / hide the Console Widget as otherwise the Console Widget will hijack all keyboard input.  Then, click on the keyboard symbol in the Axes Widget to enable keypad jogging.  Make sure to set the step size to a safe value before pressing Arrow Keys or Page Up / Page Down.:

Disable software endstops

I noticed when the machine hits an endstops Marlin simply skips any gcode operations in the restricted area and simply continues when it returns to the work bed area.  This is undesirable; I would expect an emergency stop.

After all this I decided to simply disable software endstops and work in G53 unrestricted.  This will allow me to simply move the spindle by hand to the origin of choice and power up the logic board from there.




<To be continued>


1. Spot drill hole pattern in spoilboard.
2. Manually drill through using suitable bit.
3. Insert (glue?) threaded inserts.

1. Spot drill hole pattern in CNC bed to hold down spoilboard.
2. Manually drill through using suitable bit.
3. Insert (glue?) threaded inserts.

Z axis min/max endstop.
Dual endstop micro switch calibration using Xmax and Ymax:
(MKS Gen L v1.0 + color/touch LCD)  -> LCD = extra CPU load + distraction ?)
Emergency stop ideas
Multimeter Z probe