Find the Direction of the Disc with 2 Sensors


There is a disk half painted white and the other half black. There are two sensors and the outputs of these sensors are the only signals available. How will you determine if the disk is rotating clockwise or anti-clockwise?

Solution: Paint One half of the disc in white and the other half in black. Assume sensors output the value 1 when reading white and 0 when reading black.
There are four possible initial states for the sensor. There are two possible changes, one for clockwise, one for counter clockwise.

  • The disc is rotating clockwise if Sensor 1 changes to the value of Sensor 2 and Sensor 2 becomes Sensor 1 XOR 1
  • The disc is rotating counter clockwise if Sensor 1 changes to the value of Sensor 2 XOR 1 and Sensor 2 becomes Sensor 1.


source: stackexchange

Comments