Printer carriage control

They work in a couple of ways mostly.

One type uses a stepper motor and as you can imagine, by counting the steps it knows what area of the page it is printing at.

Another way is to use a regular motor and a pulse wheel. By counting the pulses generated by the pulse wheel and an optical sensor it knows its position on the page.

Most times there is a home position sensor at the capping assembly and it counts the steps from that position. It checks home position once in a while depending on the model. More expesive units may have an optical sensor and a patch on the platen for it to find home position and time the ink drops. The more expensive the device, the more precise the carriage position and ink drop sensors. Really expensive printers even track the curvature of the platen roller and the curl to the paper and adjust the head height to compensate.