# Programming a diy cmm

I'm trying to modify the project outlined at http://blog.dzl.dk/2018/08/21/3d-digitizer/ with 4 rotary encoders instead of 3. the first encoder $$e_0$$ is mounted in the base and allows the rest of the arm to rotate along the z axis. the second encoder $$e_1$$ is a known distance from the base $$H_0$$ and allows the rest of the arm to swing. The rest of the arm consisting of $$e_2$$ and $$e_3$$ do the same as $$e_1$$. The variable r refers to the distance between the origin (at the bottom of the base) and the point at the end of $$a_3$$. the supplied equations on the site are

$$r = a_1 \cdot \cos(e_1) + a_2 \cdot \cos(e_1+e_2)$$ $$z = h_0 + a_1 \cdot \sin(e_1) + a_2 \cdot \sin(e_1 + e_2)$$, $$x = r \cdot \cos(e_0)$$ , $$y = r \cdot \sin(e_0)$$. My guess is this can be modified with a third term and say $$r = a_1 \cdot \cos(e_1) + a_2 \cdot \cos(e_1 +e_2) + a_3 \cdot \cos(e_1+e_2+e_3)$$ am I anywhere near correct? note on the image that ARM1 corresponds to $$a_1$$, ARM2 is $$a_2$$, etc.

diy cmm