2012-03-18 19:30:14 (CET)

Homing and coordinate systems

 As I am like most people and don’t want to read a comprehensive manual, but start right away. So I have written this little tutorial, it explains how to home the machine and use the coordinate systems in a simple way. This part is very important to read, you will enjoy operating the machine more if you use the coordinate systems the right way!
 When your machine is switched on, all axes can be at any position, these positions are unknown by the software. The software however needs to know the position to show a correct graphic in the graph screen and also for preventing damage to your machine by running beyond the machine limits.  The process to match the machine position with the software is called homing. Homing can be done either manually or automatic if end of stroke switches are mounted. This tutorial describes homing.

Here are the homing buttons, F2 from the main menu.



With F2 .. F4 the X..Z axes can be homed individually. With F8, the home sequence can be started to home all axes in a sequence. F11 is the same as the button besides the %100 feedOverride display.



What happens is that a few subroutines are called. The subroutines are in the macro.cnc file in your USBCNC installation folder. They look like this:




Homing per axis


Sub home_x    

      home  x




Sub home_y    

       home y




Sub home_z    

       home z




;Home all axes, uncomment or comment the axes you want.

sub home_all    

gosub home_z    

gosub home_x    

gosub home_y


 A good reader has seen that the order of homing is defined by the home_all subroutine and can be customized to your own needs.


Manual homing the machine

 Homing is the first thing you always do after switching on the machine, I recommend making a habit of it.  Suppose your machine limits are:
 X:  +300 mm and -300 mm
 Y:  +200 mm and -200 mm
 Z:  +100 mm and 0 (0 is the bottom surface of the bed).


Set the Home velocity to 0 for all axes that have no EOS switch.


 Mark a point somewhere on the machine that you want to use as home reference point, let’s say X= -200.0mm, which is 100.0mm from the left edge and Y= -150, which is 50.0 mm from the lower edge. For Z we take to bottom of the bed at Z=0 mm. This position x=-250, Y=-150, Z=0 is entered in the Home Position values in the set up screen, this need to be done once.


 Using the arrow keys, jog the X,Y axes to the marked position on the bed and move the Z completely up to the surface of the machine. When the machine is at the position press the Home button in the Home submenu, F2-F7 for X-C.

  Be sure that you have set the home velocities of the axes to zero, otherwise the axes will start to move. Now click the buttons X, Y, Z, and A if you have an A-axis. That is all, the axes are now homed and the software now knows the  machine position.

As a side effect, now also the software limit switches are enabled which protect you from jogging further than the machine can go. Also the Software limit guard is on that will stop a running program when going beyond the limits.


 You may also have noticed that the position mode is set to “machine”, this is because homing directly affects the machine coordinate system. From this point the machine coordinate system, is not changed any more, it stays as is.


 HINT: Move your machine always back to the home position if you are done with the machine. You don’t have to move manually to this point next time when you switch back on the  machine. You can do a fast move in machine coordinates like this: g53 g0 x0 y0 z0, or first undo the preset (preset dialog, undo preset) and then do a regular G0.


Another possibility to move quickly to the home positions is using g28,

In the variable window set G28 home positions to the same value as the home positions in the set up window. Now you have to type only g28 to go to the home position.


Automatic homing the machine and HomeIsEstop

 The machine needs a homing sensor or switch for each axis connected the its home input on the CPU board.

 The homing switch is placed at a small distance of the mechanical end of the machine. This distance is needed to ramp down the velocity after the switch is activated. The sensor should be mounted such that it remains active until the mechanical limit of the machine.

For automatic homing the home velocity needs to be set to another value than zero, use an equal or lower speed than the axis maximum speed. The axis should start to move in the direction where your homing switch is mounted, when it is needed to reverse the direction add a minus sign to the homing velocity. Setup the HomeInputSenseLevel correctly. When the led’s are green when the input is not activated put a 1 here, when the led’s are red when the switch is not activated, put a 0. This depends whether you have used normally open or normally closed switch. I recommend normally closed switches here. Use the homing sub menu to home your axes.

1st  Move: The machine first moves until the switch activates, then ramps down and stops.

2nd Move: Then the direction reverses and ramps down when the switch releases. At the moment of the release of the switch, the position is captured and used to set your machine position correctly.



Tandem axes homing


Tandem axes, one main axis has 2 motors, the correct rotation  axis option is set to be slave of  X, Y or Z.  If the TANDEM axis has individual home sensors for master and slave, the home sequence can be customized such that the TANDEM sets itself straight after homing.


 For tandem axes these special interpreter commands exist:






For the explanation, I assume that the master axis is X and the Slave axis is A.


1. PrepareTandemHome X, Both slave and master are moved towards the home sensor. The axes stop when both axes are on the sensor. When one axis reaches the home sensor first, this one is stopped and the other moves further. This movement is done when both axes have reached.


2. Home X, home the X, the slave will just follow. Because the axes are on the sensor, the move will be off the sensor. The position is latched at the moment the sensor de-activates. Then the movement stops and then the correct position is calculated end set for the X.


3. Home A, exactly the same, but now the A is master temporarily and X will follow. At the end the position is calculated and set for the A.


4. At this point both master and slave have a correct known position. It is very important that the home position in the setup matches the actual machine. Now we can straighten the bridge by the command MoveSlaveToMaster A. The slave will move to the same position as the master. The bridge is set straight and we are done. (If the bridge is not straight, the home positions in the setup are not correct).


To make this whole sequence more easy, the HomeTandem X can be used to do it all at once.


When testing with the individual commands PrepareTandemHome, Home master, Home slave, MoveSlaveToMaster is done, the HomeTandem command can be used.

 So if X has a slave Axis, then modify the macro.cnc so that subroutine home_x contains:

Sub home_x    

      homeTandem X



For a normal, non tandem it would contain:


Sub home_x    

       home x



 Work versus Machine coordinate system and zeroing

The machine coordinate system does not change, however we want to be able to do the milling of our part anywhere we want on the machine. We will normally use the “work” coordinate system, we can shift it anywhere we want. This can be done with several G-Codes, which are explained in chapter 3, it can also be done using the “preset” button on the operator screen, we’ll see this in a minute.

Suppose our g-code file containing the work piece is created with an origin of X=0, Y=0, Z=0.  This is because you have drawn your part in a CAD program beginning from these coordinates and then converted to G-Code. Now you have put your raw material somewhere on the machine, probably not at coordinates X=0, Y=0, Z=0. By the way, I prefer to define the upper surface of the material as Z=0, such that a negative Z value goes into the material.

Just move to the zero point of the work piece and there press the zero buttons in the operate screen besides the position display.

For the advanced users: The zeroing can also be done using a measuring probe connected to the probe input. An example is provided in the standard macro.cnc file. Under user_1 you find automatic zeroing. Under user_2 you find interactive tool length measurement.


If you want to do it a more advanced way, look at G55 .. G59.3 and also at the G92 variants.

When homing and zeroing is performed, the milling can start:


When the program is loaded, go to the graphics screen (Alt-g) and press update preview, you will now see exactly where the part is going to be milled at the surface of you machine bed.


Now press the F4 key or the run button to start milling, go to the graphic screen and switch real time graph on to see what the machine is doing.


That’s all for this tutorial, happy milling!