Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2567
  • Last Modified:

Finding direction of rotation

There is a disk on a turn table. Half of it is black, and the other half is white. It is rotating in constant speed, but it's rotating fast so that you can't see whether it's going clockwise or counterclockwise. You also have a set of stationary sensors you can install anywhere which can tell whether the color of a spot has changed from black to white, or vice versa. What is the minimum number of sensors needed to find out which way the disk is rotating? What is the best, average, worst time to figure out the direction? If you use more sensors, can you improve the best, average, worst time? How can you accomplish that? If you are given only one sensor, how can you find out the direction, assuming you can change one constraint of the problem?
0
surajguptha
Asked:
surajguptha
3 Solutions
 
☠ MASQ ☠Commented:
Popular interview question this year
Try this
0
 
surajgupthaAuthor Commented:
If the sensor could just find if something has changed from white to black or black to white and there are two of them, how can you determine the direction of flow? I still don't get it. The sensor would just say white-black or black white. I can't seem to write a computer program that takes these values and makes a decision even if I know the speed of the turn table. I am feeling dumb, Can you kindly break it down for me?
0
 
phoffricCommented:
    OK to assume that the black covers 1/2 semi-circle and white the other half?
     OK to assume that no matter how fast the RPM is, the sensor is able to send a signal when there is a change in color?
     If so...

>> You also have a set of stationary sensors you can install anywhere which can tell whether the color of a spot has changed from black to white, or vice versa.

    The sensors don't even have to be able to tell whether black turned to white, or vice versa. It just needs to send a signal indicating that a color transition occurred.

    Two sensors very close to each other near the rim of the turn table should suffice. Facing the turntable at level position, you can call them L and R for left and right. When a color state change is detected, then a signal is sent to the computer which has two channels, one for L and one for R. So the computer reads 0 or 1; 0 means no state change detected; 1 means a state change has occurred.

Consider the sequence.
L R
0 0  // no state change for either sensor
0 1  // the right one has seen a transition
1 0  // the left one a short distance away has seen a transition
0 0  // the transition has past both

This sequence means that the dividing line between the two colors went from right to left, which mean clock-wise.
0
NEW Internet Security Report Now Available!

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out this quarters report on the threats that shook the industry in Q4 2017.

 
☠ MASQ ☠Commented:
If the disk is half black and half white you have a single line running along the diameter which represents the change in state (if you like on or off) when viewed by the sensor.

Grab two sensors and place them at equal distances from the center of the disk so they measure the same point on that line.  Place them a short distance apart, maybe 15 degrees.  Then record the time between them being triggered by a change of state.

Does this allow you to determine the direction of spin?
0
 
HooKooDooKuCommented:
With some assuptions, the two sensors can be used to determine the direction of by tracking the timing of when the sensors detect the white to black and black to white transition.

Now a few of the assuptions:
1. The two sensors can not be directly opposite each other, and you know their relative locations.
2. You get to either query the sensors and they tell you the current color under them, or the sensors are linked to your computer in an interupt pattern such that each time a sensor changes, an event is triggered in your program.
3. The speed of the sensors and your computer are MUCH faster than the disk (i.e. if you are having to pole the sensors, you can pole the sensors MANY times in one disk revolution.

Now all you need to do is build a time history of the change to determine the pattern of the black-to-white and white-to-black transitions and determine at any given moment where each sensor is in the pattern and what their current value is.

For example, lets say that we can sample the disk 12 times per revolution and the disk is painted with the left side black and the right side white (i.e. in one revolution there is only one transition from black to white and one from white to black).  Lets also say the sensors are 90 degrees appart.

With this setup, we can reprsent the history of what the sensors sees like this: "BBBBBBWWWWWWBBBBBBWWWWWW".  Basically, the first 6 samples saw black, the next 6 samples saw white, etc.

Now just look at the side by side history of the two sensors.

If Sensor 1 is at the 12 o'clock position and sensor 2 is at the 3 o'clock position, and the history pattern of the two sensors looks like this:
Sensor 1 "BBBBBBWWWWWWBBBBBBWWWWWW"
Sensor2 "BBBWWWWWWBBBBBBWWWWWWBBB"
You can see that the transition from black to white happens in sensor 2 before it happens in sensor 1, so the disk must be spinning counter clock wise.
we don't have a star-burst pattern of alternating black and
2. The sensors are either is is a dynamic system (i.e. the disk is spinning, the sensors
If the black/white pattern is different that the spacing of the sensors (i.e. if the left side is black and the right side isthe two sensors are NOT directly opposite each other, and the spacing of the black/white pattern is differe , and you are somehow getting data in something of real time (i.e. either as the sensors are constantly sending data
0
 
mlmccCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now