Adding homing-sensor to 4th axis on CNC

  1. Next project: updated mount for Z axis homing sensor


I have a 4th axis on (both) my CNC milling machine(s).
I want a home switch that indicates a perfect 0°.
So I can stop a job, switch off the machine and later home all 4 axis to their homing switches, jog to the last position and continue the program.

Later I'd like to do the same for a planned 5th axis.


Ordered the sensor. Not started doing it yet. Stay tuned... (this blog posting will be updated)

Hardware choices

This is my 4th axis. (50:1 harmonic drive gearbox with a K11-100mm 3 way chuck attached.)

M8 2mm sensing DC 5 V NPN LJ8A3-2-Z/BX-5V zylinder induktive näherungsschalter sensor arbeitsspannung 5VDC spezielle für MCU

This is the sensor "Finglei Electric LJ8A3-2-Z/BX-5V" (5V NPN induction sensor) I'd like to mount as a home switch.

Why inductive?

The sensor needs to not block the movement of the 4th axis past 360°.
For a simple, mechanical switch that can be solved by attaching a ramp to the disc.
However it also needs to allow movement in the opposite direction. That doesn't work well with mechanical switches.

Optical switches can get confused by dust and shavings.

So I have chosen an inductive sensor as the most reliable and simple option.


I have taken my information from this tutorial and this discussion.

  • connect blue to GND
  • connect brown to +5V supply voltage for the sensor (I could have used a 48V sensor but I wanted to play it safe)
  • connect the remaining black wire to +5V via a 100KOhm pull-up resistor
  • and also connect the black wire to the input.
My PLCM-E3P CNC (used with the PLCM-B1 breakout board) provides me with 15 inputs to use here. They can work with 5V signals.

You can't use the +5V from the stepper-enable outputs to drive the sensor inputs.
(e.g. for a tool-height probe).
I had to add an extra 5V supply just for that existing tool-height probe.


My plan is to
3D print a mount for the sensor on the side of the gear box.
(Possibly using the slots that already mount the gear box to the table to not accidentally drill into the gears inside)

Then attach a modified wascher to one of the bolts securing the chuck to the plate to detect when it passes the sensor once every 360°

The sensor must have a gap of no more then 2mm to it's metal target.
Update: In  MK2 I forgot to leave clearance for the heads of the M6x30 machine bolts. So I had to change the design slightly for MK3.

Here is the 3d printable design of the sensor holder:


Multi Axis G-Code generation with CNC-Toolkit

Yes, CNC-tookit is ancient. But since Fusion 360 doesn't do the job...so well...
Here are my notes about how to get cnc-tookit running on a modern Windows 10 and create 4 and 5 axis toolpathes with it.

I may add screenshots to illustrate my notes at a later point.


I'm trying to figure out if and how to generate 4 and 5 axis G-Code in CNC-Toolkit to run on my heavily modified YooCNC 6040 machine.

Getting the software

  1. get GMax
  2. get CNC-Toolkit
  3. The registration website for the (always free) GMax software no longer exists... GMax registration workaround 
  4. I haven't looked at these yet  

Setting up Gmax

Before you start, you should select the system unit of meassurement in Gmax using Customize-Preferences... and then General-System Unit Scale.

Geometric assumptions

Some assumptions I do about the CNC machine:
  • We use a 4 axis machine with the A axis mounted on the bed of a carthesian CNC mill.
  • The A axis is running along the X axis (along Y it would be the B axis after all)
  • The center of rotation is at Y=0 Z=0
  • The stock starts at X=0 and ends at X>0
  • The stock is cylindrical. 
  • positive Z mean "up" from the center of rotation towards the spindle.
Further assumptions:
  • We use a ball nose cutter
  • We are only interested in FINISH-passes. (For roughing 3 axis milling of X+A+Z is enough)
  • STL-file and tool sizes and machine coordinates are in millimeter

From STL to G-Code 

I used this tutorial to make these notes.

  1. Make sure your object is already scaled to the right size.
  2. Orient your object along the Y axis.

Convert STL to 3DS

GMax doesn't seem to understand STL or the unual CAD file formats.
So we need a converter.

3D Exploration 1.5 can be found here : cnczone.com/forums/attachment.php?...
(Yes, you need a user account in the CNCZone forum.)
In Windows 10 you need to install this using compatiility settings.
It is discontinued but you should of cause still register it for 40.77 € +19% sales tax = 48.52 €.

If objects in the original file exceed the 64,000 faces per object limit for .3DS, it splits info face groups that you need to reunite inside Gmax using the Editable Mesh 'Attach' or 'Attach List function.

  1. Open "3D Exploration 1.5".
  2. Select your file on the right side.
  3. Select File-Save As... and the 3ds file format.

combine face groups

On the right side you have  a number of tabs,
  1. In the first tab, you can assign a name to your objects to identify them.
  2. In the "view" tab with the monitor icon, you can hide objects that clutter your view and render them as solid objects.
  3. In the tools tab, you can "attach" and "attach list" multiple face groups into a single mesh.

Load model

  1. File-Import your convertes mesh.
  2. Make sure it's oriented along the X axis due to limitations of cnc-toolkit.
  3. Note down the size of your stock.
  4. Select your object and in the top right panel, give it a name.

Run cnc-toolkit

  1. Run the "CNC-Toolkit-4.34b.ms" MaxScript file using the menu.

Next select your machine type.
  • XYZ is a 3 axis mill
  • XYZA has 
    • a 4th axis mounted on the work-surface that rotates around X
  • XYZAB has 
    • a 4th axis mounted on the work-surface that rotates around X and
    • an additional 5th axis "B" mounted on the Y gantry, rotating the spindle around Y
  • XYZABC has a trunnion arm mounted on the Y gantry
    • C mounted on the trunnion rotating around the vertical axis
    • B mounted on the C axis to rotate perpendular to to C
  • XYZAC has a 4th and 5th axis combination mounted on the work surface. 
    • A rotating the table and 
    • B rotating the part on the table surface
The offsets are the distance from center of rotation to the tip of the tool.
For an axis mounted to the work table,  as with XYZA and XYZAC I assume it's the distance from center of rotation to the origin point.

Create a cylinder of splines

  1. In the "parallel splines" section choose "helical" or "cylindrical"
  2. Enter apropriate X, Y and Radio -dimensions for your stock.
  3. Click "Make parallel splines" and wait a second for them to apear.
  • "Stepover Distance" controls the distance of parallel toolpathes at the outher diameter.(Oviously the closer they are to the center, the closer they get. Keep that in mind for stock that can melt or catch fire.)
  • Despite the name "Stepover" is an absolute distance between tool passes and ignoring the tool diameter.
  • "Stepover" also ignores any changes in radius during the later projection. As the spline gets near the center of rotation during projection, the resulting toolpathes are much closer then the initial "Stepover" distance.

Project splines onto surface

  1. In the "project spline" section, click "object" and select your object.
  2. Select the spline.
  3. Click "project around X axis"
  4. Delete the unprojected spline using edit-delete (it's no longer needed and can be re-created with just 1 button)
It should now wrap the surface of your object.
  • Height offset is otherwise known as a skin depth and allows for roughing passes

Create tool vectors along projected spline

  1. Up in the "angle control" section, choose "Use Reference Surface".
  2. Then "Pick Reference Surface".
  3. Select your object and the button should not read "Ref Mesh = ". 
  4. Select the projected spline. (Not the original spline. You can delete that one.)
  5. In the "toolpath generator" section, choose "Toolpath from Shape".
You may have to wait for a few seconds.

Generate g-code and show animation

Now you can use the "Tool Control" and "Postprocessor Options" sections to export your g-code to the "Script listener window" to copy and paste it.
(The other options here work in 3D Studio MAX but not in GMAX)

You can find that windows with F11 or in "MaxScript"- "MAXScript Listener..." .

After postprocessing, you can use "/" or the play-button in the lower right to see an animation of the milling process.


I have not yet fully understood how to compensate for the tool shape.
The tangent mode seems to use the entered tool diameter and offset it along the surface normal.
This simple method would of cause be problematic in pockets narrower then  1.0x the tool diameter that can not be milled with a tool of this size. However an infinitely small tool will try and the applied offset will cut widen the pocket beyond the intended geometry.

As an alternative I should test importing an existing 3 axis toolpath and having cnc-toolkit perform the too-orientation only. Aparently toolpathes from CamBam (trial versions) can be exported as DXF and imported into GMAX. I don't think that works for gcode -toolpathes of my favorite 3 axis CAM software.

I have also not understood yet how to use your own geometry to represent your machine for better visualision and for collision detection. Aparently you can "link" your own geometry to follow the path of the generated stand-ins and then hide the stand-ins.


Multi Axis G-Code generation with Fusion 360


I'm trying to figure out if and how to generate 4 and 5 axis G-Code in Fusion 360 (Hobbyist version = ultimate features) to run in MACH3 on my modified YOOCNC 6040 machine.
Because even the new "5 axis operations" in Fusion 360 don't work for organic shapes without contours. Any I only ever need/want 4 and 5 axis milling for organic shapes to get perfect surface finish on curved surfaces.


This is a WORK IN PROGRESS and I'm using this blog posting to collect the links and bits and pieces I found so far.

Machine compatibility

I could not yet determine if the machine control program (in my case MACH3) is required to support TCP (tool center point) compensation.
This means that X+Y+Z coordinates in G-Code refer to the center of the tip of the tool and A+B+C refer to the angle of attack.

During G-Code Generation Fusion 360 has absolutely no idea if a given orientation is mechanically impossible for the machine to perform and thus cannot aproximate it with a less then ideal angle of attack or a similar mitigation strategy.

It is clear that all calculations happen in the Machine Configuration.
To get there you already need to have a toolpath. It's in "postprocess"->Open Config.
"Tip: Ask your reseller about customization of the setup sheets and post proces" is not very helpful if you build the machine yourself and therefore ARE the "reseller".

Milling Strategies 

There is no German documentation yet.

Trying OpenBuilds linear actuators with end stops

I'm trying out expensive but (up to this step) well done OpenBuilds kits combined with cheap 20x20 I-Type aluminium profiles for a machine I'm building.

However uppon installing the OpenBuilds End-Stop kits I just got a big WTF moment....
(Images directly from the OpenBuilds Part Store website. So nobody can claim the photographer got it wrong...)

1) How the *** am I supposed to attach a micro switch to an aluminium plate like this? There is no thread for the screw to fasten to. It's just 2 oversized holes in the mounting plate. Inserting the screws liks shown just means to loosely stick them in there and want for them to simply fall out on their own.

No you can't insert them the other way around because these are not sink hole screws with tappered holes in the aluminium plate. So you don't get a flush surface to mount this crap to the aluminium profile rail.

2) Why is +Open Builds requiring a different tool-size (1mm hex) for "Micro Limit Switch Kit with Mounting Plate" then the 3 different tool sizes they already need for the "V-Slot™ Linear Actuator Bundle" (1.5mm, 2mm and a tiny one for the stepper)?

3) Why no use a smaller screw that fits THROUGH the holes in the micro switch instead of eating their own thread into the plastic.