Newsgroups: comp.robotics
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!news.kei.com!bloom-beacon.mit.edu!news!fredm
From: fredm@media.mit.edu (Fred G Martin)
Subject: Re: LEGO Encoders
Message-ID: <1995Aug11.115942.19094@media.mit.edu>
Sender: news@media.mit.edu (USENET News System)
Organization: MIT Media Laboratory
References: <40cjo6$k9d@wabbit.cc.uow.edu.au>
Date: Fri, 11 Aug 1995 11:59:42 GMT
Lines: 46

In article <40cjo6$k9d@wabbit.cc.uow.edu.au>
viso@elecsun9.elec.uow.edu.au (Viengsook Soukhavong) writes: 

>Has anyone been successful in using the LEGO encoders with the f1 board?
>They are digital...so... hmmm I dont really know how they work.
>
>This is what I think:
>They have 16 positions per revolution... so that must mean that every 
>time I get a low sent to the digital input, that's 1/16th of a revolution.
>
>Anyway.. I really need to get it to work.
>
>I tried the solution suggested by Fred Martin with the 8V regulator...
>I tried the LM2940 and it didnt work either....*sigh*

Well, I have used them, so my solution is indeed viable!

As with the new-fangled LEGO reflectance sensor, you have to realize
that the sensor contains a bridge rectifier (so you can't get the
polarity wrong) and a relatively large bypass capacitor (for storing
charge to run itself).

The way you use it is to charge up the sensor to 7.5v and then stop
charging it and look at the voltage on the sensor.  You do this at a
rate of about 300 Hz (maximum).  Allow a tiny delay after you turn off
your charge voltage for the sensor's value to settle, but not too long
because then its internal cap discharges and the reading is invalid.
You have between 1/2 and 1 millisec to read the value after you stop
charging.

With the LEGO rotation sensor, it returns four discrete voltages
depending on the rotation.  These voltages follow a specific pattern
depending on which way you turn it; i.e., A--B--C--D--A etc going one
way, and D--C--B--A--D etc the other.  So, for example, if you see a
transition from state "A" to state "B" you might count up, and if you
saw a transition from state "A" to state "D" you would count down.
You should never see a transition from state "A" to "C"---that would
mean you were not sampling frequently enough or that the shaft is
turning too fast.

I hope this helps.

	-Fred

Fred Martin | fredm@media.mit.edu | (617) 253-5108 | 20 Ames St. Rm. E15-320
Epistemology and Learning Group, MIT Media Lab     | Cambridge, MA 02139 USA
