In PLC code, I normally have a constant real number representing "final drive factor" to convert units from raw to real, but you still want to verify and work with the absolute value for position control and before converting the absolute to a useful position of rate of the final moving piece.
Use delta D (distance travelled) with a subtract block and a limit check to detect rollover, and then you can accumulate real raw position with the same resolution as the encoder if you are trying to understand how to use an encoder that makes multiple revolutions during a single stroke of the final driven element.
Each sprocket ratio is calculated by hand and written in the rung comment, each gear ratio too, then multiply them all together and type it into the tag value, and save it. You can get fancy and try to make the ratios adjustable, but in theory, this value rarely changes. Use this calculation for a basis for motor rpm commands.
In practice, with things like conveyor belt thicknesses changing and other variables, I often have another scale factor which can be taught or tuned in a setup mode after the machine is commissioned.