Instructions - How To Make And Set Up A Z-Probe On The M4

(UPDATED 2024.11.13 FOR FIRMWARE V0.85 CHANGES)

A z-probe is a super handy addition to your M4 allowing you to accurately and quickly set the z-home position of your router bit on top of your material anytime that you are getting ready to make a cut. They are easy and cheap to make. This post is intended as a step-by-step walk-through of the process I used to build and configure a z-probe for my M4 (with photos for most steps). (Note, I have tried to make this walk-through as explicit and comprehensive as possible, so please forgive the parts that are very straightforward and obvious.)

Essential Parts: (1) Flat piece of metal long enough to slide under your M4 (I picked up a 8" by 14" metal plate at Ace Hardware for ~$15, but any flat piece of conductive metal should be fine); (2) Wiring (if you want to be resourceful, wires from old broken headphones, RCA cables, or something similar could work); (3) JST-HX connectors, solder, or some other means of connecting wires.

Required Tools: (1) Wire cutters; (2) Crimpers, soldering iron, or other components necessary for you to connect the wires where needed; (3) Allen key included with your M4 in order to unscrew the screws of the M4 control board cover.

Optional Tools: (1) Electric multimeter; (2) Heat-shrink tubing or electrical tape.

Cost: ~$0-$20. You may have spare parts sitting around for some or all of the build.

Time: Less than 30 minutes to build and less than 15 minutes to configure your machine. (It could take longer or shorter depending on your parts and how fancy you want things to be in the end.)

Z-Home/Probe Goal: The ideal goal in setting the z-home is to lower the router bit until it just comes into contact with the work material (no lower, no higher) and set the position exactly there. After that, when the machine is cutting, it will go precisely the depth into the material that you set in your toolpaths. If the Z-home is off, your cuts will be either deeper or shallower than you programmed them to be (depending on what you’re making, this may not be a big deal to you, but becomes very important for smaller and/or more detailed designs and parts). The M4 is different than many other CNC machines in that the sled (and router) ride along the surface of the cutting material rather than hovering above the material independently on a gantry or other support system. For purposes of the z-axis, this means that, when the M4 is resting flat on the material, the bottom/underside of the sled is the same as the maximum height of the material (i.e., the ideal z-home position). Since the bottom of the sled and the position of the material are the same, lowering the router bit and setting the z-home to the bottom of the sled will also set the router bit right on top of the material, precisely where you want it to be.


Build Goal/Mechanics: When a circuit is complete, electricity can flow through the circuit. A basic switch operates by breaking and re-connecting a circuit. With these simple principle in mind, you can build a z-probe that acts just like a basic switch and completes a circuit when the router bit reaches the bottom of the sled. When the router bit is in the ideal z position, the circuit is connected (or switched on) and you can set the z-home right where you want it. To build the circuit here, you will need to slide a flat piece of conductive metal under the machine (any flat piece of metal can work but I recommend something at least a few inches wide so that the machine rests flatly on the metal) this metal acts as our material for purposes of setting the z-home position. For the most basic wiring, simply connect a wire to the router bit or collet and the other end of the wire to the metal plate. A circuit will be completed when the router bit touches the plate. However, with that circuit, we wouldn’t know when the bit touches the plate. Instead, we will be wiring the plate and the bit to pins on the M4 control board and the M4 will tell us when the circuit is complete (i.e., the switch turns on).

Alternate Build/Easiest Build: If you want to avoid taking anything apart on your M4 and/or tweaking the configuration of your maslow.yaml file, you can instead do the same job with a cheap electric multimeter (~$5 at Harbor Freight). The process will be a little more manual but still very easy and cheap and much more accurate than attempting to manually set the z-home. For this, (1) take your multimeter, (2) set the multimeter to check circuit resistance (ohms/omega sign), (3) touch one probe of the multimeter to the metal plate under the M4, (4) touch the other probe to either the bit or a wire attached to the bit (alligator clips can help), and (5) lower the M4 slowly until the circuit is complete. When a circuit is completed the multimeter will read resistance (depending on your multimeter, it may even make a beeping noise to signal the connection). For higher accuracy, you can then raise the bit 1 step, set your z-jog increment to a smaller distance (e.g., 0.5mm or 0.1mm) and lower the bit a step or so until the connection is again completed. Repeat until you are satisfied with the accuracy. Set the z-home at the position where the circuit is complete. (Note, after setting the z-home, I like to raise the z position up a centimeter or so in order to avoid having the bit scratch something if I move the machine around or turn the router on.)

Full Build: The following steps are a full build of the z-probe as described above. This requires connecting the probe to pins on the control board (which requires removing three screws to get access to the control board), a little bit of simple wiring, and making minor changes to your maslow.yaml file (i.e., your M4’s configuration file). I’ve included photos along with most steps to make them as easy as possible to follow/copy.

Building/Assembling Steps (the order of most of these steps can be rearranged or followed in the order presented below):

  1. Gather necessary materials and tools (see above).
  2. Remove the three screws on the M4 control board cover.
  3. Locate the connector on the control board with your auxiliary connections (according to @Bar, only two auxiliary connections are not being used for essential machine functions, we will use Auxiliary 1 which is GPIO pin 48 on the control board). There are 2 identical connectors right next to each other, so be sure you have the correct connector. With the power cord pointing downwards, you are looking for the connector on the right.

  4. Take 2 lengths of wire (length depends on how you are setting things up but I used ~6"). These wires will be used to connect to the 2 control board pins. I only used ~6 inches of wires so that I could disconnect and store the rest of the z-probe while keeping the wires connected to the control board permanently connected to the board (since my wires hang out the side of the control board, I didn’t want them too long that they would get in the way of anything). A disconnect is highly recommended to avoid having to constantly remove the control board cover every time you go to use your probe.
  5. Attach some sort of connector to the ends of the 2 wires that will connect/disconnect from the rest of the z-probe. This is not strictly essential and you could just touch exposed ends of the wires together to make a connection, but having exposed wires just hanging out is not a good idea for a ton of reasons. Note: If you use a connector (as I did), it doesn’t matter where the wires are positioned in the connector as long as they match up with the wires coming in. That being said, the other end of these wires (step 6) must be connected to the correct pins).
  6. Connect a wire to the Aux. 1 pin on the Control board connector (see picture under step 3 for pin layout) and another wire to the 3v3 pin on the connector (3v3 is a 3.3 volt powered pin). I used a 4-pin female JST-HX connector (and some wire from a breadboard kit) in order to match the connector on the board. You could instead solder the connections (if so be careful not to accidentally jump any of the connections together) or use some other means of making a connection to each pin that won’t come loose after using the machine.
    WARNING! However, you make the connections, be careful not to permanently jump the pins to each other (especially, the 3v3 pin to the Ground pin). If you jump the 3V3 and the Ground pin, it will cause the board to reboot (though it didn’t seem to do any permanent damage to my board when I accidentally did it).
  7. Route the control board wires out to the side of the control board (I routed mine next to the USB port), and replace the control board cover and its 3 screws.
  8. Take 2 additional wires, and put a connector on one end to connect with the wires coming out of the control board. I used a JST-HX connector so that the wires can easily connect and disconnect with the wires going to the control board. You likely want a bit of extra length in these wires (~8"-12" or more depending on your build) since these will be going to the router bit and to the metal plate then connecting up with the connector that goes to the control board. You can use alligator clips for one or both of these wires. I recommend using at least one alligator clip for the wires going to the router bit/collet. To make the connection to the router bit even easier, I glued a couple small magnets to the end of an alligator clip (the magnets have a metal coating so still conductive). (Note, it doesn’t really matter which of the 2 wires connects with which of the wires in the connector going to the control board as long as one wire connects with each (i.e., if the circuit runs from the bit to the wire plate then to the control board or from the metal plate to the router bit then up to the control board–exact same results).)
  9. Connect one of the wires to the metal plate. For now, I just stripped back about an inch of wires and used some electrical tape to secure the wires to the metal plate. You could solder the wire to the plate, install some sort of screw to secure it, use a magnet, use an alligator clip, or however you want to do it. The biggest thing is to make sure that, however you connect it to the plate, the bottom of the plate stays flat and is not raised above the work surface.

With that, you are done building the z-probe. The next steps are for configuring the M4 to recognize the z-probe.

It is a very good idea to test all of your connections. You can do this with a multimeter in the same manner as described earlier. You just want to ensure that you have a complete circuit when the wires for the metal plate and for the router bit touch. If you’re like me and bad at crimping wires and connectors, then testing your connections is vital.

Maslow.yaml Configuration:

  1. Connect to your M4 at maslow.local and go to the second tab for FluidNC Settings.

  2. Make a backup of your maslow.yaml file in case you need to revert back to it for some reason. It is a good idea to make a backup occasionally regardless.
  3. Make an additional copy of your maslow.yaml file to edit.
  4. Open the yaml file in Notepad (or a similar file editor).
  5. Scroll down the yaml file until you find the default probe configuration options:
  6. Replace the default probe settings with the following:

    All lines of code under “probe:” must start with two spaces (creating a small indent before each line). If you use a different GPIO pin than pin 48, simply change the pin number accordingly. The “pd” activates a resistors in order to prevent EMI from causing false positives while probing.
  7. Save the changes to the yaml file and upload the file back to your M4.
  8. Reboot.
  9. Go to the “Preferences” tab in the upper-right corner on maslow.local and click to enable the probe settings.

  10. Go to FluidNC controller tab.
  11. Go down to the Probe options.
  12. Adjust the Probe settings to your liking. These can also be set in the Preferences before (see step 9). See the photo below for descriptions of the settings.
  13. Start your probe. Click the Start Probe button to start the probing. (If clicking “Start Probe” outputs a "G38.6 "command in the Commands info box below the probe settings, update the machine to the latest firmware, and try again.) (Note: Before probing, you can enter “?” into the Commands info box to show the current positioning of the machine and the status of any switches. If the probe is working and a circuit is currently active, you will see “PN: p” in the Commands info box along with the machine’s position. In FluidNC, “PN” means there is currently a switch in the active/connected state, and the “p” after “PN:” is specifically for a probe-type switch. So, “PN:p” is FluidNC saying that it is currently reading a switch as active and that switch is a probe. If you’ve built and configured everything, you can test your probe by touching the bit probe-wire to the metal plate (creating a circuit). If everything is working, you should now see “PN: p” in the Commands box when the connection is made, and, if you break the connection, PN:p should go away.)
  14. The machine will lower (no farther down than the “Z-” number/distance). If the bit makes contact and the probe triggers then the machine will stop there, set the machine’s z-home position where contact was made (you do not need to manually tell the machine to set the z-home position), and raises back up the “Retract distance” (see Step 12). Based on my own testing, the z-home position set automatically by the machine after clicking Start Probe is accurate to within 0.1mm (I was testing in 0.1mm increments, so that is a lower bound of its accuracy and it very well may be even more accurate than that).
  15. Disconnect the bit and plate probe-wires from the wires going to the control board, and remove the metal plate. You are ready to make your cut.
19 Likes

A much needed QoL mod. Thanks for the write-up.

2 Likes

This is a phenomenal write up! I’ll link it in the newsletter today, I think it will be beneficial to a lot of folks!

1 Like

Thanks! I’m really glad others find it useful.

2 Likes

@jwolter

Can we add this post to the wiki.

2 Likes

Just saw it in the news letter. Great contribution!

Dano

2 Likes

Thank you! This is so helpful!

Paul.

2 Likes

This is an excellent how-to, and has just become a priority project for me!

Mahalo nui loa!

3 Likes

@bar , is this something that can be readily remedied? My Maslow 4 is going to go into a shared space after I finish the current scenery project, and I want to write something of a manual for the other(s) who may want to make use of it; it would simplify things some if clicking “Start Probe” just worked for setting Z-Home.

2 Likes

Yes! It’s on my todo list. I’m prepping for Bay Area Maker Faire which is this weekend so I might not get to it until next week, but I’m on it!

3 Likes

Has there been any progress on getting this to work because I still get a failure when I use G38.2 Z-50 F30. It show moving z 15mm but only moves it 1mm and always fails.

Devin Draper wrote:

Has there been any progress on getting this to work because I still get a failure when I use G38.2 Z-50 F30. It show moving z 15mm but only moves it 1mm and always fails.

stupid thought, but some systems are sensitive to capitalization, try Z and F
instead of z and f

David Lang

As you can see made no difference.

Here is the full command list when running G38.2 after a reset

G38.2 Z-10 F20
[GC:G38.2 G54 G17 G21 G90 G94 M5 M9 T0 F20 S0]
<Run|MPos:0.000,0.000,47.000|FS:20,0>
[MSG:WARN: Position error on Bottom Right axis exceeded 15mm while running. Error is -1664.534mm Counter: 1]
[MSG:WARN: Previous error was -1664.534mm]
[MSG:WARN: Position error on Top Right axis exceeded 15mm while running. Error is -1640.264mm Counter: 1]
[MSG:WARN: Previous error was -1640.264mm]
[MSG:WARN: Position error on Top Left axis exceeded 15mm while running. Error is -1638.502mm Counter: 1]
[MSG:WARN: Previous error was -1638.502mm]
[MSG:WARN: Position error on Bottom Left axis exceeded 15mm while running. Error is -1665.072mm Counter: 1]
[MSG:WARN: Previous error was -1665.072mm]
[MSG:WARN: Position error on Bottom Right axis exceeded 15mm while running. Error is -1664.534mm Counter: 2]
[MSG:WARN: Previous error was -1664.534mm]
[MSG:WARN: Position error on Top Right axis exceeded 15mm while running. Error is -1640.264mm Counter: 2]
[MSG:WARN: Previous error was -1640.264mm]
[MSG:WARN: Position error on Top Left axis exceeded 15mm while running. Error is -1638.502mm Counter: 2]
[MSG:WARN: Previous error was -1638.502mm]
[MSG:WARN: Position error on Bottom Left axis exceeded 15mm while running. Error is -1665.083mm Counter: 2]
[MSG:WARN: Previous error was -1665.083mm]
[MSG:WARN: Position error on Bottom Right axis exceeded 15mm while running. Error is -1664.534mm Counter: 3]
[MSG:WARN: Previous error was -1664.534mm]
[MSG:WARN: Position error on Top Right axis exceeded 15mm while running. Error is -1640.264mm Counter: 3]
[MSG:WARN: Previous error was -1640.264mm]
[MSG:WARN: Position error on Top Left axis exceeded 15mm while running. Error is -1638.502mm Counter: 3]
[MSG:WARN: Previous error was -1638.502mm]
[MSG:WARN: Position error on Bottom Left axis exceeded 15mm while running. Error is -1665.083mm Counter: 3]
[MSG:WARN: Previous error was -1665.083mm]
[MSG:WARN: Position error on Bottom Right axis exceeded 15mm while running. Error is -1664.534mm Counter: 4]
[MSG:WARN: Previous error was -1664.534mm]
[MSG:WARN: Position error on Top Right axis exceeded 15mm while running. Error is -1640.264mm Counter: 4]
[MSG:WARN: Previous error was -1640.264mm]
[MSG:WARN: Position error on Top Left axis exceeded 15mm while running. Error is -1638.502mm Counter: 4]
[MSG:WARN: Previous error was -1638.502mm]
[MSG:WARN: Position error on Bottom Left axis exceeded 15mm while running. Error is -1665.083mm Counter: 4]
[MSG:WARN: Previous error was -1665.083mm]
[MSG:WARN: Position error on Bottom Right axis exceeded 15mm while running. Error is -1664.534mm Counter: 5]
[MSG:WARN: Previous error was -1664.534mm]
[MSG:WARN: Position error on Top Right axis exceeded 15mm while running. Error is -1640.264mm Counter: 5]
[MSG:WARN: Previous error was -1640.264mm]
[MSG:WARN: Position error on Top Left axis exceeded 15mm while running. Error is -1638.502mm Counter: 5]
[MSG:WARN: Previous error was -1638.502mm]
[MSG:WARN: Position error on Bottom Left axis exceeded 15mm while running. Error is -1665.083mm Counter: 5]
[MSG:WARN: Previous error was -1665.083mm]
[MSG:WARN: Position error on Bottom Right axis exceeded 15mm while running. Error is -1664.534mm Counter: 6]
[MSG:WARN: Previous error was -1664.534mm]
[MSG:ERR: Emergency stop! Stopping all motors]
[MSG:WARN: The machine will not respond until turned off and back on again]
<Alarm|MPos:0.000,0.000,47.000|FS:0,0>
[MSG:ERR: Position error > 15mm while running. E-Stop triggered.]
ALARM:5
Probe fail. Probe did not contact the workpiece within the programmed travel for G38.2 and G38.4.
[PRB:0.000,0.000,0.000:0]

Devin Draper wrote:

As you can see made no difference.

Here is the full command list when running G38.2 after a reset

did you do the rehang dance (retract/extend/tension)? this looks like you didn’t
or your encoders are having serios problems.

This is causing it to generate an emergency stop before it finishes the Z
movement.

David Lang

1 Like

Yes! I submitted an issue request on github. Bar made the change and I tested the change last week to be sure things worked. It worked great. I believe that he intends to incorporate the change with the new build this week. That being said, you can use the test file (it’s a change to the index.html.gz file). The file can be found in the comments to the issue request. It would probably be good to see the results of someone else trying it out too. (Problem: "Start Probe" Button Produces Incorrect GCode · Issue #156 · BarbourSmith/FluidNC · GitHub)

Despite the above-noted change, your problem is different. The issue I noticed (and was recently addressed) had to do with the “Start Probe” button issuing a G38.6 command. However, your issue is with the G38.2 command. The above-fix changes the button to issue a G38.2 command. If you problem is with G38.2, then this fix will not help you and we need to figure out your underlying issue.

1 Like

Sorry, I’ve been away for a bit. Rather than copying the post and taking it out of the context of the larger discussion, I linked to this thread from the Maslow 4 Wiki.

2 Likes

I have an idea to combine it with this fantastic solution.
I found this DC 3v laser switch and my idea is to place the diode next to one of the two linear shafts, make a small hole in the sled just below the dust cover where the laser diode light passes through, on the opposite side of the other linear shaft place the sensor switch module and drill a hole in the sled on this side as well just below the dust cover so that when the cutter goes down it interrupts the diode light and gives us a mark for the Z home, with all the other steps described here and at the end add the fixed height that the light beam has.
I wonder if the 3.3v that come out of this connector are capable of powering this device and if there is also a way to activate and deactivate the device from the panel or if a manual switch or a connector is necessary to turn it on and off

1 Like

a problem with using a laser to detect the end of the bit is that the shape of
the bit may make it hard to detect the tip. It may vary depending on how the bit
is rotated (the edges of the bit may be at a different height than the center of
the bit, an extreme case would be plug cutting bits like

)

but even a sharp v bit may be hard to detect.

a touch sensor is very reliable.

David Lang

Date: Fri, 08 Nov 2024 03:08:55 +0000
From: Javier Betancourt via Maslow CNC Forums
notifications@maslowcnc.discoursemail.com
Reply-To: Maslow CNC Forums
incoming+5fda378cf41f340161804ca05ee7ee67@maslowcnc.discoursemail.com
To: david@lang.hm
Subject: [Maslow CNC] [Wiki] Instructions - How To Make And Set Up A Z-Probe
On The M4

I have an idea to combine it with this fantastic solution.
I found this DC 3v laser switch and my idea is to place the diode next to one of the two linear shafts, make a small hole in the sled just below the dust cover where the laser diode light passes through, on the opposite side of the other linear shaft place the sensor switch module and drill a hole in the sled on this side as well just below the dust cover so that when
the cutter goes down it interrupts the diode light and gives us a mark for the Z home, with all the other steps described here and at the end add the fixed height that the light beam has.

2 Likes

This sounds like a really cool solution. Though, I ultimately agree with @dlang. In practice, I think this would be hard to pull off and get to work consistently. David mentioned the differences in bits, but I think, in general, it would require getting things set up very accurately, and, after being in place, staying perfectly in place in spite of all the vibrations the machine throws off while cutting. If it is permanently mounted, it may also prevent the z-axis from lowering all the way on either one or both z-axis stepper motors. If it wasn’t permanently mounted, then it would require calibrating the laser every time.

Building a z-probe as described above is pretty easy for a whole range of skill levels, and it is very accurate. With the latest firmware updates, the “Start Probe” button is now working, so the entire z-homing process is just setting a bit, sliding the metal plate under, connecting the plate wires, and clicking “Start Probe”, and you’re done. The machine will lower until contact and save the z-position automatically now. From my testing, it is extremely accurate (less than 0.1mm error in position). It’s also pretty cheap build, really easy to source the parts (or even have them lying around), and quite sturdy.

If you try out the laser probe, please share the results! Though, I would recommend first trying to build and use the z-probe described above, and then trying to build the laser probe if you aren’t happy with the results from the metal plate z-probe (or just want to experiment).

1 Like

I’ve updated the instructions here to reflect that the “Start Probe” button is now working as of firmware V0.85.

I highly recommend using the Start Probe button to activate your z-probe. Not only does it trigger the probing without having to type a custom command into the Commands info box, but it also automatically saves the correct z-home position for you and raises the bit back up to a safe distance after contact (this safety distance is based on the “Retract distance” that you set in the probe setting; I like 10-20mm of safety clearance personally).

I was a bit suspect of the accuracy of the machine setting the z-home automatically (with the machine lowering quickly during the probing, I wasn’t sure if it would over-shoot the actual position by some degree). However, I tested the results, and it looks to be very accurate. After using the “Start Probe” button, I tested its accuracy by lowering the machine back down at 0.1mm increments until contact was made again and comparing these results with what the machine had set. The results matched perfectly. I tested this way a few times, and each time they matched. I didn’t bother trying to test a smaller travel increment because that is more than good enough for me.

2 Likes