5
$\begingroup$

You have a disc. One half of the disc is painted white and the other half is black. The disc rotates in either a clockwise direction or an anti-clockwise direction.

There are two sensors which are not connected to the disc but are in a fixed position, pointed at the disc. They are at 90° from each other with respect to the center of the disc. The sensors output the value 1 when reading white and 0 when reading black.

Using only the output of the two sensors, find the direction in which the disc is rotating.

Diagram of Disc

$\endgroup$
6
  • $\begingroup$ This question was asked me in an interview, where I had to draw a circuit to find a direction. Here, I have modified this question. $\endgroup$
    – H.Modh
    Nov 19 '15 at 11:38
  • $\begingroup$ So what are we allowed to do? Can we touch the disk? Spin the disk? Paint the disk? $\endgroup$
    – DrunkWolf
    Nov 19 '15 at 11:46
  • $\begingroup$ No, you can't touch the disc. The disc is already rotating. and it is already painted with Black and White color. You just need to figure out the direction of the disc from the output of the sensors. $\endgroup$
    – H.Modh
    Nov 19 '15 at 11:51
  • $\begingroup$ In addition, when the sensor detects a black color, it gives a value "0" and when it detects a white color, it gives a value "1". $\endgroup$
    – H.Modh
    Nov 19 '15 at 11:57
  • 1
    $\begingroup$ At the 90° from the center of the disc; meaning they are 180° apart or only 90°? $\endgroup$
    – Jens
    Nov 19 '15 at 12:00
7
$\begingroup$

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.

enter image description here

$\endgroup$
2
  • $\begingroup$ Yes... perfect..!! 😀 $\endgroup$
    – H.Modh
    Nov 19 '15 at 12:25
  • $\begingroup$ I gave the similar answer with the same truth table in my interview... but I took almost 20-25 minutes to solve it...!! $\endgroup$
    – H.Modh
    Nov 19 '15 at 13:01
3
$\begingroup$

So if I'm getting this correct, we have a disc with radius R at the origin, and a sensor at (-R,0) and (0,R). The disc is half black, half white, with the dividing line between the colors being a straight line going through the center of the disc.

If both sensors show 1, we know the black part of the disc is up. Then if the left sensor goes to 0 before the other one, we know the disc is rotating clockwise. If the right sensor goes out first the disc is rotating counter-clockwise.

If the sensors are 180 degrees apart, (-R,0) and (R,0), I don't believe this is solvable without because you're unable to distinguish between clockwise with black side up and counterclockwise with black side down.

$\endgroup$
4
  • 1
    $\begingroup$ My guess as well, can't figure out a way to do it with the sensors being 180° apart. $\endgroup$
    – Jens
    Nov 19 '15 at 12:11
  • $\begingroup$ Good imagination without a diagram...!! $\endgroup$
    – H.Modh
    Nov 19 '15 at 12:58
  • $\begingroup$ @H.Modh Thanks, Would've given a table to if i knew that was the goal ;) $\endgroup$
    – DrunkWolf
    Nov 19 '15 at 13:05
  • $\begingroup$ @DrunkWolf... It is possible that the interviewer was looking for an answer without a table... like yours... $\endgroup$
    – H.Modh
    Nov 19 '15 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.