Machine Space and Homing - bdring/Grbl_Esp32 GitHub Wiki
Machine space and machine coordinates are terms used for the range of motion on an axis that Grbl_ESP32 uses internally. The coordinates do not change when you zero an axis or change work coordinate systems (G54-G59). Work coordinates are just offset from the machine coordinates. The only thing that resets machine coordinates is homing to limit switches.
Grbl traditionally creates a negative machine space. If the length of your axis is 300, the valid machine space goes from -300 to 0. This is regardless of the direction the machine travels when homing the axis. The only thing that does change with homing direction is the current location when you are done homing. If you home in a positive direction your position will be 0. If you home in the negative direction you position will be -300. This is assuming your homing pulloff is 0.
Some people get a little confused by the negative space, but it is very important to know that gcode does not use machine coordinates. Gcode runs in a work coordinate system that you can zero anywhere. It should not matter what your machine coordinates are.
With that said, Grbl has two rarely used compile time options to change machine coordinate behavior. These are HOMING_FORCE_SET_ORIGIN
and HOMING_FORCE_POSITIVE_SPACE
We are trying to move as many compile time features to settings as possible. In doing so, we had a long discussion about these options and possible alternatives.
We determined that we could implement the two options by adding one new setting. This setting sets the machine coordinate position of the limit switch touched.
This allows you to keep the traditional negative space, create a positive machine coordinate space or even create a space like -150 to 150.
Here are the settings that affect machine coordinate space and homing.
- $X/MaxTravel The length of the axis
- $Homing/DirInvert Which direction the axis homes in. Set $Homing/DirInvert=XZ to have X and Z home in the negative direction
- $X/Home/Mpos The value to set the machine coordinate to at the limit switch
- $Homing/Pulloff How far to pull off the switch after homing.
- $X/MaxTravel=300
- $X/Home/Mpos=0
- $Homing/DirInvert= (all axes home positive)
- $Homing/Pulloff=1
The machine will home in the positive direction. It will set positive end to 0. It sets the negative end to -300, so your range is -300 to 0. The actual machine position after homing will be -1, due to the pulloff.
- $X/MaxTravel=300
- $X/Home/Mpos=0
- $Homing/DirInvert= X
- $Homing/Pulloff=1
The machine will home in the negative direction. It will set the negative end to 0. It sets the positive end to 300, so your range is 0 to 300. The actual machine position after homing will be 1, due to the pulloff.
- $X/MaxTravel=300
- $X/Home/Mpos=150
- $Homing/DirInvert=X
- $Homing/Pulloff=1
The machine will home in the negative direction. It will set the negative end to 150. It sets the positive end to 450, so your range is 150 to 450. The actual machine position after homing will be 151, due to the pulloff.
- $X/MaxTravel=300
- $X/Home/Mpos=10
- $Homing/DirInvert=
- $Homing/Pulloff=1
The machine will home in the positive direction. It will set positive end to 10. It sets the negative end to -290, so your range is -290 to 10. The actual machine position after homing will be 9, due to the pulloff.
Soft limits prevent the machine from moving outside the range of motion as described above. When using soft limits you must home the machine first. If you want soft limits to ignore one of the axes, set the $ <axis>/MaxTravel value to 0.
If you do not use homing, machine space is mute. The machine does not know where it is at any time. Soft limits should not be used. Hard limits could be used, but if you have switches, you are likely to home. You can still zero a work space anywhere you want. The machine space you created with MaxTravel and Home/Mpos will be ignored and you can freely travel past the ends.
There is no good way to automatically set the new setting during upgrading. It will be set to 0. This will be correct for traditional negative space machines that home towards the positive end.
You should check your machine behavior after upgrading and set the machine space accordingly. If something is not right it will affect any previously zero'd coordinate systems, G28 and G30.
If you want to keep your traditional behavior, set $<axis>/Home/Mpos on any axis that homes negatively to the negative of your travel.