measuring and controlling speed and position of Dc motor

it is a simple 24 V DC motor-generator set I m sorry to say that the model is obsolete so i cant share any link for the motor but it is running properly by motor controller and the code given above its a white strip on the shaft which has to be followed for the speed and position and sensor output is taken to LCD display