=====5023 (Machine position Z) and 5043 (Work position Z)===== Conversion between work position and machine position and vice versa relies on the following components: 1) Work offset (5223) 2) Tool length (5403) 3) Tool offset (7517) 4) Tool correction (4700) 5) On-the-fly correction (8140) 6) Flatbed correction (8153) Combining these different offset and correction values allows to translate program coordinates from the host computer into machine coordinates. The following diagram shows the basic layout for such a conversion: {{:mycnc:global_variables:z-position-schematic-001.png}} The **work offset** is the base difference between the work and the program coordinates. The **tool length** and the **tool offset** work in conjunction (as the tool offset changes, the tool length also changes to accomodate). **Tool correction** allows for small variations to bring the tool up/down. **On-the-fly correction** is used for Torch Height Control. **Flatbed correction** is used to take into account the uneven portions of the working table, allowing to compensate for it by using a pre-recorded height map. **Tune Z** is currently reserved as an addition to the tool length (Total Tool Length = Tool Length + Tune Z), but the functionality is not yet finalized and is only available on lathe configurations at the moment (as of June 2022). NOTE: The on-the-fly (8140) and flatbed (8153) correction values are read-only and will be retrieved by the program itself the next time they are required as the control program is running. ====Tool offset #7517==== The myCNC software features the global variable #7517. Writing to register 7517 changes the tool length value based on the specified offset (correction value). In general, the value of the tool length in this case is calculated as follows: //**[Tool length] = [Current machine position] - [toolsetter position] - [offset]**// {{:mycnc:global_variables:global-variables-003-toolsetter.png}} For example, in a situation where the current probe position is "-195", the current machine position is "-100", and the offset is equal to 0, the tool length will be: (-100) - (-195) - (0) = 95 With an offset, the user can set the desired tool length value or length correction (if necessary). For example, the command G10 L80 P7517 Q0 specifies a tool length with zero offset, while G10 L81 P7517 Q100 sets the length, and takes the correction (offset) from register #100. //NOTE: The global variable #7515 performs the same function for the X coordinate tool length offset on a lathe.//