# Align milling to rotated workpiece (around z-axis)

**URL:** <https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281>\
**Category:** Uncategorized\
**Created:** [April 29, 2021, 1:08am UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281 "2021-04-29T01:08:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![robbe](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@robbe](https://forum.onefinitycnc.com/u/robbe)\
**Post date:** [April 29, 2021, 1:08am UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/1 "2021-04-29T01:08:53Z")

</div>

Hi all,

I just ordered my OF and I was wondering the following: I understand how to zero out the three axes. How would I deal with workpieces that are slightly rotated around the z-axis? For instance, I may want to start with an existing, precisely rectangular “blank” and add new cuts to it. I could “zero out” the rotation around the z-axis by measuring at least three points around the perimeter, but I don’t think this is what you guys are doing. Do I need to align it manually to the x- or y-axis to achieve that my design is exactly aligned?

Thanks for any input!

---

<div class="post-metadata">

**Author:** ![eaststreetcarry](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.onefinitycnc.com/eaststreetcarry/32/2504_2.png) [@eaststreetcarry](https://forum.onefinitycnc.com/u/eaststreetcarry)\
**Post date:** [April 29, 2021, 2:18am UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/2 "2021-04-29T02:18:48Z")

</div>

I set up some 1-2-3 blocks on a corner and then probe the inside.

---

<div class="post-metadata">

**Author:** ![Pleased2fly](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@Pleased2fly](https://forum.onefinitycnc.com/u/Pleased2fly)\
**Post date:** [April 29, 2021, 11:44am UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/3 "2021-04-29T11:44:36Z")

</div>

I’d recommend running a grid pattern (2 inch square) on your spoil board after it is flattened, and that gives you a pretty precise line to follow that is in line with the X and Y real axis.

---

<div class="post-metadata">

**Author:** ![robbe](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@robbe](https://forum.onefinitycnc.com/u/robbe)\
**Post date:** [April 29, 2021, 4:30pm UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/4 "2021-04-29T16:30:02Z")

</div>

Thanks for sharing the practices!

I think what I am not grasping yet is this: Let’s say I put a rectangular board on the table and I want to reference to it precisely. Ignoring z-height, I fundamentally have three degrees of freedom: x/y zero and rotation of the piece around the z-axis. The purpose of the XYZ probe is to address the x/y zero precisely, let’s say to 2-10 mil. How do I address the rotational degree of freedom with a similar precision?  
It appears that eyeballing wouldn’t give me the precision, and aligning it manually and mechanically kind of defeats the purpose of using a probe to get better precision automatically. Not a criticism of the probe, naturally, but I feel that I’m missing something.

---

<div class="post-metadata">

**Author:** ![ConvenientWoodwork](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.onefinitycnc.com/convenientwoodwork/32/22558_2.png) [@ConvenientWoodwork](https://forum.onefinitycnc.com/u/ConvenientWoodwork)\
**Post date:** [April 29, 2021, 4:51pm UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/5 "2021-04-29T16:51:29Z")

</div>

Disclaimer: Not a professional

My understanding is that the machine coordinates and the work piece coordinates must be orthogonal to each other

---

<div class="post-metadata">

**Author:** ![robbe](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@robbe](https://forum.onefinitycnc.com/u/robbe)\
**Post date:** [April 29, 2021, 5:32pm UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/6 "2021-04-29T17:32:18Z")

</div>

So there seems to be [G68/69 that can rotate the x/y plane](https://www.cnccookbook.com/g68-g69-rotate-coordinate-cnc-g-code/) (I’m not a g-code expert). If I were to measure the difference from orthogonal, e.g. by probing three x/y locations instead of two points on the probe, I could numerically align, just as everyone is doing already for zero-point.

Edit: Corrected link as per @ConvenientWoodwork note.

---

<div class="post-metadata">

**Author:** ![ConvenientWoodwork](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.onefinitycnc.com/convenientwoodwork/32/22558_2.png) [@ConvenientWoodwork](https://forum.onefinitycnc.com/u/ConvenientWoodwork)\
**Post date:** [April 29, 2021, 7:09pm UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/7 "2021-04-29T19:09:59Z")

</div>

Huh, I had no idea!

I guess if you had a way to measure precisely the angle your workpiece is at you could manually enter this gcode into your program. But for that to work you’d need to know precisely the machine coordinate plane in which case why not just put your workpiece there.

Edit: I just read your previous post again, probing could definitely accomplish this

Btw your link seems to be pointing to the wrong place. [This](https://www.cnccookbook.com/g68-g69-rotate-coordinate-cnc-g-code/) should get you to the G68/69 page.

---

<div class="post-metadata">

**Author:** ![robbe](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@robbe](https://forum.onefinitycnc.com/u/robbe)\
**Post date:** [April 29, 2021, 7:58pm UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/8 "2021-04-29T19:58:43Z")

</div>

You’re certainly right, the link was wrong, I corrected.

If the OF controller supports G68 then it is just a matter of probing at least three points (or more) along either or both x and y axis plus the math. I won’t get my machine until August, but I’d be curious how this can be programmed.

---

<div class="post-metadata">

**Author:** ![OldNewbie](https://avatars.discourse-cdn.com/v4/letter/o/6f9a4e/32.png) [@OldNewbie](https://forum.onefinitycnc.com/u/OldNewbie)\
**Post date:** [April 29, 2021, 8:15pm UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/9 "2021-04-29T20:15:45Z")

</div>

If I understand you correctly you would need a way to precisely align your board correctly and get your x, y and z. Then run your program carving only the new area.

There is a lot of factors that have to work just right to make this work. I don’t think I would use this method,

Dave

---

<div class="post-metadata">

**Author:** ![robbe](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@robbe](https://forum.onefinitycnc.com/u/robbe)\
**Post date:** [April 29, 2021, 8:33pm UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/10 "2021-04-29T20:33:32Z")

</div>

@OldNewbie Yeah, I understand. I’m not trying to come up with a complicated solution to a simple problem, but to see if there is an incremental extension of what the probe concept can do already.

One of my use cases: I want to see if I can use regular woodworking tools to prep my “blanks”, e.g. pieces of furniture, then registering them in the CNC for further processing (e.g. inlays). I have no OF and no hands on experience with the repeatability.

Adding the in-plane rotation does not seem fundamentally different than using the probe plate concept for zeroing the offset. If you go the “probe route”, you already assume that you have a square, flat edge to reference from. The rest is just probing one more point and the corresponding math. It does not seem terribly more difficult than regular zero offsetting (and I have the benefit that I don’t have to manually and mechanically align the rotation). Naturally this will work only under certain circumstances: Do I have an edge to reference from? How much numerical error do I get from the measurement over longer distances?

---

<div class="post-metadata">

**Author:** ![robbe](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@robbe](https://forum.onefinitycnc.com/u/robbe)\
**Post date:** [April 29, 2021, 8:44pm UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/11 "2021-04-29T20:44:25Z")

</div>

For reference: I do not know JS or Gcode well, but it appears that the [xyz-probing here](https://github.com/OneFinityCNC/onefinity-firmware/blob/47cec0dae38f3c7c3d00172144f23eec468ff694/src/js/control-view.js#L367) could be extended easily to gauge the angle as well. From my reading this function (ignoring Z) essentially quickly finds the edge of the probe quickly (high feed rate), then goes back a bit and tries again with lower feedrate (supposedly to increase precision). In order to achieve the angle correction I would imagine the following:

1. do the probe\_xyz as above, set zero (all in gcode)
2. run the X or Y probing, but offset in Y or X by less than the width of the probe (to get to a farther point) (all in gcode)
3. Retrieve the position of the probing in #2 (gcode-\>JS)
4. Calculate angle (in JS)
5. Issue appropriate G68 (in gcode) → done

Assuming that the probe is long enough w.r.t. workpieces size, this should give similar precision as the regular offset computation. Benefit: You don’t have to align anything, just slap the workpiece on in any orientation, calibrate, mill.

I’m sure that I may be overlooking something obvious, I’m not a machinist/CNC person.

---

<div class="post-metadata">

**Author:** ![MikeH](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@MikeH](https://forum.onefinitycnc.com/u/MikeH)\
**Post date:** [April 30, 2021, 4:48am UTC](https://forum.onefinitycnc.com/t/align-milling-to-rotated-workpiece-around-z-axis/5281/12 "2021-04-30T04:48:10Z")

</div>

Your zero point is just that - a point. You don’t have to use the probe at all to set your zero point, it can be wherever you want it to be. Lots of folks just move the router to the spot they want, and lower the bit to the surface they are using all manually. Your workpiece can be oriented in any direction.

From there, you only need your workpiece to be aligned with what your design is trying to do. I would think it would be simpler/easier to rotate the design than re-align the CNC to a different angle.
