# Automating z-axis zeroing

**URL:** <https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886>\
**Category:** Wiki - Store and maintain knowledge\
**Created:** [August 17, 2018, 4:29am UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886 "2018-08-17T04:29:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dag83](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dag83/32/2603_2.png) [@Dag83](https://forums.maslowcnc.com/u/Dag83)\
**Post date:** [August 17, 2018, 4:29am UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/1 "2018-08-17T04:29:04Z")

</div>

You can automate the zeroing of the z-axis if you want to. It makes it a lot more precise and convenient.

1. Solder pins on AUX4 on the motor shield. While you’ve got your soldering gear out, attach pins to aux1 as well, it can automatically start and stop the router. Never mind about the others, they aren’t used yet.

2. Attach a wire (2m should be fine) to the AUX4 and one to the GND output

3. Attach a piece of sheet metal, I like to use a ruler, to the AUX4 wire

4. Attach a small metal clamp to the GND wire  

5. In settings, make a macro called “touch zero” and in it put

- Imperial

> G20 G90 G38.2 Z-.15 F1 G20 G90 M02

- Metric

> G21 G90 G38.2 Z-10 F1 G21 G90 M02

1. Insert your bit into the router if you haven’t allready

2. Attach the clamp somewhere a metal piece of the router body

3. Put the metal ruler under the sled so that it covers the middle of the opening  

4. Use the Z axis panel to move the bit so that it is just above the ruler but not quite touching - within .15" of touching.

5. Press the macro button

Now your z-axis will lower till it touches the metal ruler and automatically zero, or the Maslow will ‘Stop’ if the bit hasn’t touched down yet. If that is the case, click the ‘Stop’ button to acknowledge the alarm and run the macro again - the bit will lower another time trying to touch down on the ruler connected to AUX4

Et voila, workflow improved 🙂

For the connector, [here](https://www.robotshop.com/en/sea-03-servo-extender-cable-24.html) is a cable that could be made to work. It includes a 3-pin male connector you could solder onto the board and the mating 3-pin connector wired to 24" leads. That’s certainly not long enough to get from the board to your sled, you’ll need to cut one of the connectors off and solder on pieces of wire to make up the difference. Note that the middle pin is VCC (i.e. +5 volts), so not needed for the Z axis zeroing.

---

<div class="post-metadata">

**Author:** ![HansPeterHaastrup](https://avatars.discourse-cdn.com/v4/letter/h/dbc845/32.png) [@HansPeterHaastrup](https://forums.maslowcnc.com/u/HansPeterHaastrup)\
**Post date:** [August 17, 2018, 5:57am UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/2 "2018-08-17T05:57:08Z")

</div>

Really nice guide! I will do this very soon! Maybe you could add it to the garden as well? I think a lot of people would want this.

Just a quick question (and may be some clarification)  
I’m guessing that you’re using inches on your machine?  
I haven’t tried the G38 command but I would suspect that it gives an error if it doesn’t find the zero after 0.15inch of travel? is that correct?  
If the machine is set to mm this would not be very much (coming in from +20 mm maximum) so by simply changing the value to something larger would make it probe deeper.

Is the feedrate set as low as possible to increase the precision? My z-axis is pretty slow already so I usually just max it out 😉

---

<div class="post-metadata">

**Author:** ![Dag83](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dag83/32/2603_2.png) [@Dag83](https://forums.maslowcnc.com/u/Dag83)\
**Post date:** [August 17, 2018, 7:28am UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/3 "2018-08-17T07:28:07Z")

</div>

The g20 sets the commands to inches, so it doesn’t matter is everything alse is in mm, i’m a metric guy myself.

---

<div class="post-metadata">

**Author:** ![scottscnc](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/scottscnc/32/7556_2.png) [@scottscnc](https://forums.maslowcnc.com/u/scottscnc)\
**Post date:** [August 17, 2018, 10:59am UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/4 "2018-08-17T10:59:17Z")

</div>

@Dag83 I see you have three wires on pins, one is to ruler and ground to clamp. Wheres the third wire going to? Also does the top wire go to ruler or second one down? My X-Carve has a probing feature where you put clamp on collet and set puck on work piece (2wires setup) and hit probe button and it automatically probes puck and raises to automatic hight. Also do you have a link to where we can get pins and black wire clip to go on pin?  
Thank you very much for this post.

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 17, 2018, 3:38pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/5 "2018-08-17T15:38:29Z")

</div>

> [@scottscnc](#):
>
> three wires on pins

I usually don’t put a wire on the VCC pin unless it is needed, and in this case I would leave it off.

> [@scottscnc](#):
>
> a link to where we can get pins and black wire clip to go on pin?

For the connector, [here](https://www.robotshop.com/en/sea-03-servo-extender-cable-24.html) is a cable that could be made to work. It includes a 3-pin male connector you could solder onto the board and the mating 3-pin connector wired to 24" leads. That’s certainly not long enough to get from the board to your sled, you’ll need to cut one of the connectors off and solder on pieces of wire to make up the difference. Note that the middle pin is VCC, so not needed for the Z axis zeroing.

---

<div class="post-metadata">

**Author:** ![scottscnc](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/scottscnc/32/7556_2.png) [@scottscnc](https://forums.maslowcnc.com/u/scottscnc)\
**Post date:** [August 17, 2018, 4:21pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/6 "2018-08-17T16:21:00Z")

</div>

@blurfl what does VCC stand for? Sorry for probably silly question to you. I haven’t had time to see if new laptop fixes my USB lost problem but I for sure wanna do this feature when i do get it going properly. Thanks for replying bud! 🙂

> [@blurfl](#):
>
> I usually don’t put a wire on the VCC pin unless it is needed

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 17, 2018, 5:14pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/7 "2018-08-17T17:14:00Z")

</div>

Sorry for adding confusion, in this case VCC means 5V , the 5 volt power for the Arduino logic and the encoders.

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 17, 2018, 5:35pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/8 "2018-08-17T17:35:52Z")

</div>

> [@Dag83](#):
>
> The g20 sets the commands to inches, so it doesn’t matter is everything alse is in mm, i’m a metric guy myself.

If you are in the middle of a cut using metric and it stops for a tool change, will this macro cause a problem? If you set it to inches mode and never set it back to metric, would the firmware misinterpret the gcode as inches from that point on? If so, perhaps a better solution is to have code for macro for metric and macro for inches.

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 17, 2018, 7:03pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/9 "2018-08-17T19:03:11Z")

</div>

> [@madgrizzle](#):
>
> If you are in the middle of a cut using metric and it stops for a tool change,

I loaded a metric file and ran the macro, and the units of the main screen did not change. I don’t have a way to do other testing at the moment though.

The macro could be written for metric as well:

```auto
G21
G90
G38.2 Z-5 F1
G21
G90
M02

```

---

<div class="post-metadata">

**Author:** ![madgrizzle](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/madgrizzle/32/1372_2.png) [@madgrizzle](https://forums.maslowcnc.com/u/madgrizzle)\
**Post date:** [August 17, 2018, 7:08pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/10 "2018-08-17T19:08:14Z")

</div>

Well, might be good to hear from others that do this and see what their experience is. If I get around to it this weekend, I can try to run a test.

What’s the purpose of the second G21 & G90 commands? G21 puts it into metric, G90 sets it for absolute positioning… but why issue that again when the next line is M02 (program end)?

---

<div class="post-metadata">

**Author:** ![Dag83](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dag83/32/2603_2.png) [@Dag83](https://forums.maslowcnc.com/u/Dag83)\
**Post date:** [August 17, 2018, 7:19pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/11 "2018-08-17T19:19:37Z")

</div>

I have no idea, i don’t read gcode, i just copy pasted 🙂  
I tried to add a command to raise the bit a bit, bit it didn’t work.  
Appearantly i have  
G21 G90 G38.2 Z-30 F1 G21 G90 M02

The other macro is G21 G0 Z5.0 to raise the z-axis to a safe transfer height.

But when i tried  
G21 G90 G38.2 Z-30 F1 G0 Z5.0 G21 G90 M02 it didn’t raise the bit

> [@scottscnc](#):
>
> I see you have three wires on pins, one is to ruler and ground to clamp. Wheres the third wire going to?

The third wire is not connected, but i can’t remember which wire it is. Halfway they are soldered together with another wire, so the colors change. :-s

> [@scottscnc](#):
>
> Also do you have a link to where we can get pins and black wire clip to go on pin?

The pins are called “header pins”, guess the cable should be next to it when you find a webshop.

Edit, never mind, forgot this was a wiki, someone already completed it 🙂

---

<div class="post-metadata">

**Author:** ![aluminumwelder](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/aluminumwelder/32/9362_2.png) [@aluminumwelder](https://forums.maslowcnc.com/u/aluminumwelder)\
**Post date:** [August 17, 2018, 8:04pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/12 "2018-08-17T20:04:13Z")

</div>

[https://www.digikey.com/product-detail/en/wurth-electronics-inc/61300311121/732-5316-ND/4846825](https://www.digikey.com/product-detail/en/wurth-electronics-inc/61300311121/732-5316-ND/4846825)  
[https://www.digikey.com/product-detail/en/te-connectivity-amp-connectors/640456-3/A19470-ND/259010](https://www.digikey.com/product-detail/en/te-connectivity-amp-connectors/640456-3/A19470-ND/259010)

Above are 3 pin male board connectors with 0.1" spacing between the pins. Not sure if that is a match for maslow’s motor shield

---

<div class="post-metadata">

**Author:** ![RavenWall](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/ravenwall/32/7597_2.png) [@RavenWall](https://forums.maslowcnc.com/u/RavenWall)\
**Post date:** [August 17, 2018, 8:27pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/13 "2018-08-17T20:27:04Z")

</div>

The holes are not in a complete straight line, but straight enough to get a line of three pins in it.  
I just used some standard pins laying around for arduinos and stuff. Some soldering and done!

I’ve also added pins on the other AUXs. You never know when you need them 🙂

---

<div class="post-metadata">

**Author:** ![blurfl](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/blurfl/32/9_2.png) [@blurfl](https://forums.maslowcnc.com/u/blurfl)\
**Post date:** [August 17, 2018, 9:24pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/14 "2018-08-17T21:24:38Z")

</div>

> [@RavenWall](#):
>
> The holes are not in a complete straight line

That’s a PCB layout trick that aids in assembling the board. The holes are just enough offset that the pins of the header touch the sides of the holes so that the part stays in place by friction before is is soldered, and will stand perpendicular to the board on its own.

---

<div class="post-metadata">

**Author:** ![Bee](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/bee/32/2160_2.png) [@Bee](https://forums.maslowcnc.com/u/Bee)\
**Post date:** [August 17, 2018, 10:58pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/15 "2018-08-17T22:58:30Z")

</div>

FWW -

Explanation of VCC in detail

[https://www.pcmag.com/encyclopedia/term/53705/vcc](https://www.pcmag.com/encyclopedia/term/53705/vcc)

Thank you

---

<div class="post-metadata">

**Author:** ![RavenWall](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/ravenwall/32/7597_2.png) [@RavenWall](https://forums.maslowcnc.com/u/RavenWall)\
**Post date:** [August 18, 2018, 4:37am UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/16 "2018-08-18T04:37:25Z")

</div>

Learned something new. During soldering I was thinking indeed: not bad, stays nicely in place 🧐

---

<div class="post-metadata">

**Author:** ![PaulDeLisle](https://avatars.discourse-cdn.com/v4/letter/p/58956e/32.png) [@PaulDeLisle](https://forums.maslowcnc.com/u/PaulDeLisle)\
**Post date:** [August 21, 2018, 11:09am UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/17 "2018-08-21T11:09:42Z")

</div>

Try [THIS](https://www.amazon.com/Pin-Sleeved-Fan-Cable-extension/dp/B006YZ7DJQ/ref=ya_od_pd_dx_gr_4?_encoding=UTF8&pd_rd_i=B006YZ7DJQ&pd_rd_r=c3a5a921-9a85-48db-93a7-c120b8b7318e&pd_rd_w=3SiqZ&pd_rd_wg=Iz1IJ&psc=1&refRID=JNP8NZHS580DC745N5ZJ) for a longer cable…I think it should work.

---

<div class="post-metadata">

**Author:** ![LakeWorthB](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/lakeworthb/32/4071_2.png) [@LakeWorthB](https://forums.maslowcnc.com/u/LakeWorthB)\
**Post date:** [August 23, 2018, 11:29pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/18 "2018-08-23T23:29:19Z")

</div>

So I see in GroundControl that there is a touch Zero button that sends the G38.2 command, but mine is greyed out. What do I have to do enable this button?

---

<div class="post-metadata">

**Author:** ![dlang](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/dlang/32/859_2.png) [@dlang](https://forums.maslowcnc.com/u/dlang)\
**Post date:** [August 23, 2018, 10:54pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/19 "2018-08-23T22:54:12Z")

</div>

I believe there is a toggle to enable it under advanced settings.

David Lang

---

<div class="post-metadata">

**Author:** ![LakeWorthB](https://yyz1.discourse-cdn.com/flex031/user_avatar/forums.maslowcnc.com/lakeworthb/32/4071_2.png) [@LakeWorthB](https://forums.maslowcnc.com/u/LakeWorthB)\
**Post date:** [August 24, 2018, 7:29pm UTC](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886/20 "2018-08-24T19:29:26Z")

</div>

I can’t see anything there. Looking in the code I don’t see anything either. Has anyone ever used that button?

[Next page](https://forums.maslowcnc.com/t/automating-z-axis-zeroing/5886.md?page=2)
