wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> medium >> Colored Disk - Spin Sensors
(Message started by: mike1102 on May 29th, 2003, 11:43am)

Title: Colored Disk - Spin Sensors
Post by mike1102 on May 29th, 2003, 11:43am
First - I couldn't find the original thread - Hard to believe I'm the first respondant.
I'll assume its the disk that's rotating. I'd place two photodiode sensors above the disk, looking down at it - they would remain stationary wrt the rotating disk. The sensors would be spaced about 170 deg apart - the two sensors and the center of the disk are not colinear. The phase of the relative outputs of the sensors will indicate the direction of disk rotation.

Title: Re: Colored Disk - Spin Sensors
Post by Icarus on May 29th, 2003, 8:05pm
There's a thread around here somewhere, but I can't find it now either. All I come up with using the search function is a mention in catch-all "Solutions to medium puzzles" thread that was started and then wisely abandoned.

Personally, I would put the two sensors close together - one sensor with register the change right before the other - making the direction of travel obvious.

Title: Re: Colored Disk - Spin Sensors
Post by wowbagger on May 30th, 2003, 3:52am

on 05/29/03 at 20:05:54, Icarus wrote:
Personally, I would put the two sensors close together - one sensor with register the change right before the other - making the direction of travel obvious.

That was my first thought, too.
One could argue, however, that there is a minimum separation the sensors must have. It depends on how fast the disk is spinning and to which precision you can resolve the delay between the sensors' signals.
Perhaps an academic point.

Title: Re: Colored Disk - Spin Sensors
Post by fyo on Jun 27th, 2003, 4:58pm
If "2 sensors" at basically any angle (which was my first thought as well) would suffice, this "riddle" should either be moved to the easy section or be removed completely.

On the other hand, if there is a more devious answer...

-fyo

Title: Re: Colored Disk - Spin Sensors
Post by Kozo Morimoto on Jul 2nd, 2003, 12:31am
I assume that colour sensor detects a change in colour - so it will trigger on both w->b transition and b->w transition.

If you place the sensors at like 12 o'clock and 5:30 o'clock (roughly 170 degrees) I can't see how you can tell the direction.

a) assume the disc is rotating counter clockwise.  Assume that the colour change is just after 12 o'clock (towards the 11 o'clock), so that 5:30 gets triggered soon after, then the 12 o'clock gets triggered

b) assume the disc is rotating clockwise.  Assume that the colour change is just before 5:30 (towards 4 o'clock).  So in this case, the 5:30 gets triggered soon after, then the 12 o'clock gets triggered next.

So in (a) and (b) how do you make the distinction?  In both cases the 5:30 gets triggered first then the 12 o'clock.  I don't see how a 2 sensor system will work, unless each colour sensor can distinguish b->w and w->b transitions separately, but that would make the riddle trivial.

Title: Re: Colored Disk - Spin Sensors
Post by wowbagger on Jul 2nd, 2003, 2:39am

on 07/02/03 at 00:31:40, Kozo Morimoto wrote:
So in (a) and (b) how do you make the distinction?  In both cases the 5:30 gets triggered first then the 12 o'clock.

Assume (wlog) that sensor S1 is triggered a time interval of t before sensor S2. You know the angle phi between S1 and S2. Based on the time T/2 between two signals from the same sensor, you can calculate the angular frequency w=2pi/T of the spinning disk.
Now, if
 2 pi w t = phi
 w t = phi
then the disk is rotating in the direction you measured the angle phi (normally counter-clockwise for positive phi). It's rotating in the other direction if
 2 pi w t = pi - phi.
 w t = pi - phi.

edited to correct error regarding angular frequency

Title: Re: Colored Disk - Spin Sensors
Post by Kozo Morimoto on Jul 2nd, 2003, 6:45pm
Can you give me an example?  I can't follow, am I doing it right?

Assume s1 at 6 o'clock.  s2 at 3 o'clock.

So phi = pi/2 (counter clockwise)

Assume it takes 3 seconds between s1 and s2 trigger.

so w=12/(2*pi) (it will take 12 seconds to do a full rev) so w=6/pi

so 2*pi*w*t = 2*pi*6/pi*3 = 24 <> phi = pi/2
so 2*pi*w*t = 24 <> pi-phi = pi-pi/2 ?

so I have w inverted? pi/6 ?

Title: Re: Colored Disk - Spin Sensors
Post by Kozo Morimoto on Jul 2nd, 2003, 7:51pm
I've done more thinking...

Say the sensors are at 6 o'clock and at 3 o'clock.

Assume the disc is spinning at 1 rev every 12 seconds.

Assume that the disc is white on the right half and black on the left half.

If its going counter-clockwise, s1 will be triggered by the w->b transition, then 3 seconds later, s2 will be triggered by the w->b transition.

If its going clockwise, s1 will be triggered by the b->w transition, then 3 seconds later, s2 will be triggered by the w->b transition.

So t will be 3 seconds for both scenarios.

I can't see how you can tell the direction of rotation with this setup.

Even if the sensors are close to pi apart, you get a pattern like:
t=0s s1 trigger
t=.5s s2 trigger
t=6s s1 trigger
t=6.5s s2 trigger
t=12s s1 trigger

and if going the otherway,
t=0s s1 trigger
t=5.5s s2 trigger
t=6s s1 trigger
t=11.5s s2 trigger
t=12s s1 trigger

it will be a similar pattern .5 then 5.5, then .5 then 5.5 for both.  We assume that its the same speed on both scenarios, but they may not be the same speed.

Also, I always thought that disk was short for diskette, and that a flat circular object is called a disc....

Title: Re: Colored Disk - Spin Sensors
Post by towr on Jul 3rd, 2003, 1:59am
actually a diskette is a small disk. Most things '-ette' are small forms of the ones without '-ette'. It's from french I think..
(also cigar -> cigarette, rose -> rosette etc)

disk (http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=disk) and disc (http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=disc) are interchangeable..

Title: Re: Colored Disk - Spin Sensors
Post by wowbagger on Jul 3rd, 2003, 2:04am
First of all, my excuses for not remembering the angular frequency correctly (and not looking it up):
 w = 2 pi / T  (T: period of circular motion)
I'll correct this error in my previous post.


on 07/02/03 at 18:45:47, Kozo Morimoto wrote:
Can you give me an example?  I can't follow, am I doing it right?

Assume s1 at 6 o'clock.  s2 at 3 o'clock.

So phi = pi/2 (counter clockwise)

Assuming my formulae are correct, this setup is not a good idea. In both cases, w t = pi/2.
I'll think about your other scenario later on.

As far as I know, the writing "disk" is an accepted alternative of "disc" (used esp. in AmE).

Title: Re: Colored Disk - Spin Sensors
Post by wowbagger on Jul 3rd, 2003, 8:20am

on 07/02/03 at 19:51:51, Kozo Morimoto wrote:
Even if the sensors are close to pi apart, you get a pattern like:
t=0s s1 trigger
t=.5s s2 trigger
t=6s s1 trigger
t=6.5s s2 trigger
t=12s s1 trigger

and if going the otherway,
t=0s s1 trigger
t=5.5s s2 trigger
t=6s s1 trigger
t=11.5s s2 trigger
t=12s s1 trigger

it will be a similar pattern .5 then 5.5, then .5 then 5.5 for both.

Yes, a similar pattern, but not the same. Note that I defined my time t to be the time interval between sensors S1 and S2 being triggered. In your first time series, t = 0.5s, whereas in the second one, t = 5.5s. From this, you get
 1)  w t = pi/12
 2)  w t = 11pi/12
You know that your sensors are close to pi apart, so phi = 11pi/12 (S1 at 0600h and S2 at 1130h). Thus, in case 1 the disk is spinning counter-clockwise. Note that in this case one colour change triggers sensor S1 and the other colour change triggers S2. On the other hand, in case 2 both sensors are triggered by the same colour change, the disk is spinning clockwise.


Quote:
We assume that its the same speed on both scenarios, but they may not be the same speed.

You can always calculate the speed from w = 2pi/T, where T is twice the time between two signals from one of the sensors. This does not depend on the direction of rotation.

edited to add:
As should be clear by now (or even from the start), the "symmetric" configuration with phi = pi/2 is useless. This stems from the fact that phi = pi-phi, so w*t equals both and we can't use it to distinguish between the directions of rotation.

Title: Re: Colored Disk - Spin Sensors
Post by James Fingas on Jul 3rd, 2003, 8:40am
If you're using just two sensors, I'd put them 90 degrees apart. For two sensors, you get four states for the sensor outputs:

00, 01, 11, 10

When the states cycle forwards, you're going forwards, and when they cycle backwards, you're going backwards.

If you're polling the colour sensors to determine which direction they're going, then putting the sensors at 90 degrees will make the states all the same length, making it less likely you'll miss one (which would make you unsure of your direction). This is effectively aliasing of the disc's rotational speed.

If the electronics are interrupt-based (meaning a change in the sensor outputs drives the information exchange), I would still probably use 90 degrees apart, but it would matter less.

If you're using N sensors, you get 2N states. Placing the sensors 180/N degrees apart will make all the states the same length, which should make it easier to tell which direction you're going in. For N=3 you get 6 states:

000, 001, 011, 111, 110, 100

If you jump 1 or 2 steps forward, you assume you're going forwards. If you jump 1 or 2 steps back, you assume you're going back. If you jump 3 steps, you're out of luck...

Title: Re: Colored Disk - Spin Sensors
Post by wowbagger on Jul 3rd, 2003, 8:53am

on 07/03/03 at 08:40:26, James Fingas wrote:
If you're using just two sensors, I'd put them 90 degrees apart. For two sensors, you get four states for the sensor outputs:

00, 01, 11, 10

I see. Maybe I was complicating this one unnecessarily by assuming that the sensors work differently. My sensors just send a signal every time the colour changes, but do not actually give you the colour. (If you happen to know that such sensors don't exist, feel free to tell me so.)

In case you're not able to determine which way the disk is spinning (like in receiving states 00, 11, 00, 11,...), couldn't you just alter the time between successive readouts of the sensor states?

Title: Re: Colored Disk - Spin Sensors
Post by James Fingas on Jul 3rd, 2003, 10:04am
wowbagger,

That seems like a valid way of interpreting the problem. It might be a good idea in an interview situation to try and find out exactly what the specifics of the sensors are. Certainly if your sensors just give a pulse when they detect a colour edge, then two sensors at 90 degrees is no good. In fact, if they just give pulses, you either need to assume it rotates smoothly, or you need more than two sensors (I think three would do).

From my own experience, the simplest colour sensor would be a photodiode connected to a transistor and a resistor, which would behave as I've described. You can probably get a pulsed-output sensor, but it would require a different sort of circuit.

Title: Re: Colored Disk - Spin Sensors
Post by Kozo Morimoto on Jul 3rd, 2003, 2:49pm
My solution involved having 3 sensors @ 0300h,0600h,0830h.

The measurement starts when the 0600h gets trigeered.

If its going clockwise, 0830h will get triggered next.
If its going counter clockwise, 0300h will get triggered next.

This solution doesn't depend on measuring time between triggers (the riddle doesn't say that you have a timer) or that you have a sensor that can distinguish BW or WB transition and it also doesn't assume that the rotation is of constant speed.

Title: Re: Colored Disk - Spin Sensors
Post by wowbagger on Jul 4th, 2003, 2:25am

on 07/03/03 at 14:49:11, Kozo Morimoto wrote:
This solution doesn't depend on measuring time between triggers (the riddle doesn't say that you have a timer)

Still, you have to know which one is triggered first. This is exactly the information you use when you have two sensors close to each other (less than pi/2). The formula-fuss was just to show off my bad memory regarding basic concepts of physics.  ;)


Quote:
or that you have a sensor that can distinguish BW or WB transition and it also doesn't assume that the rotation is of constant speed.

Well, the riddle says that you have a "color sensor" which can mean that it tells you the colour, not only whether a change occured.
Oh, and about the constant speed issue: "Imagine a disk spinning like a record player turn table."
I don't know about your record player (if you have one), but the music will surely sound funny if it doesn't spin with constant w.  :P  ;)
Wait! How about your chances of determining the direction of rotation in case of a hip hop turntable? ;D

Title: Re: Colored Disk - Spin Sensors
Post by James Fingas on Jul 4th, 2003, 7:45am
wowbagger,

Having three edge-detector sensors is not the same as having two edge-detector sensors. When you have three edge-detector sensors, you get a string of pulses like this:

FWD: ..2..3..1..2..3..1..2..3..  (23123123123)
REV: ..1..3..2..1..3..2..1..3..  (13213213213)

You can tell these apart no matter what, even if you strip out the pauses. With two edge-detector sensors close together, you get pulses like this:

FWD: ..1.2....1.2....1.2....1.2..  (12121212)
REV: ..2.1....2.1....2.1....2.1..  (21212121)

If you strip out the pauses between them, they look exactly the same. This is what Kozo is saying. It means that your solution can't be implemented on a state machine unless you have a clock or timer of some sort.

Title: Re: Colored Disk - Spin Sensors
Post by wowbagger on Jul 4th, 2003, 8:06am
You're right. If we don't have any information about the pauses, we won't be able to determine the direction of rotation with two sensors alone.

Title: Re: Colored Disk - Spin Sensors
Post by marzapane on Dec 27th, 2004, 10:49am
IMHO a color sensor is different from a photodiode, thus I thougt:
Take a white sensor (ie it turn on while seeing white e turn off while seeing black) and a black sensor (on/black and off/white) put them side by side, now you'll have two different string corresponding to the different directions:
10 11 01 00 10 11 ....
or
10 00 01 11 10 00 ...
:)
My first post, hope i'm not wrong  ::)

Title: Re: Colored Disk - Spin Sensors
Post by Xeeblor on Sep 2nd, 2006, 2:19pm
This can be done with one colour sensor.

Let me start by saying that I was a colourist for 4 years in the plastics industry, and by 'colour sensor' I assume the riddle means 'photospectrometer'.

These sample a selected area and give results of the average colour of that area.

Imagine this area as a triangle with one 'thin' end pointing in the direction of rotation (or not as the experiment would prove).

For the purposes of explanation I'll say white is the first colour read. Set the spectro to take fast enough readings so that multiple readings while the colour is changing can be seen (or slow the revoloution of the disk down, which ever is easiest).

If the darkness of the 'grey' increases faster during the first half of the change then the disk is spinning from the 'fat' end of the triangle.

If the darkness of the 'grey' increases slower during the first half of the change then the disk is spinning from the 'thin' end of the triangle.



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright 2000-2004 Yet another Bulletin Board