Procedure of encoder shaft manufacturing has a built-in system for thermal expansion compensation which was optimised and implemented in this undergraduate thesis. Thermal expansion is a result of heat added to the shaft by laser information inscription and causes lower manufacturing precision. Expansion compensation uses a method of creating pre-marks and detecting them by measuring the intensity of reflected laser light. Main experimental task in this thesis was system setup. The goal was to create narrow pre-marks which could be reproducibly detected. We created them with both continuous and modulated laser beams at different power levels. The latter proved to be more suitable at 240 W peak power. For pre-mark detetection we have chosen minimum laser power of 16 W. To increase repeatability we also set up the position of the photodiode. We then conducted experiments of creating pre-marks and detecting them, followed by their evaluation. By calibrating the system and choosing the appropriate algorithm for data analysis we have achieved target precision under 10 μm and detection repeatability evaluated with standard deviation of 3,59 μm. Using this system the precision of encoder shaft production will drastically increase.