I had several stations on a looped track, and controlled the train position by switching on the power to the motor for a certain time.
At first I used a photodiode taped to the CRT monitor (and controlling the motor by lighting up a square in the corner of the screen), later I upgraded to controlling a relay via the parallel port.