THIS FILE: ftp://cherupakha.media.mit.edu/pub/miniboard/hobbytip/legosens.txt CREATED: Tue Mar 7 13:45:18 1995 LAST UPDATE: Mon Jul 14 13:09:04 1997 -------------------------------------------------------------------------------- From: "Fred G. Martin" To: Multiple recipients of list Subject: Re: Control Lab > Is there anybody,who uses the LEGO Dacta sensors on the MiniBoard? > I'm looking for info about how to use these sensors,beacuse i've got > problems with the reflex- and angle-sensor's jacking to the MiniBoard. > These sensors were in the LEGO Dacta Control Lab.I try to plug these > sensors into the analog port of the MiniBoard,and the value of the > analog port change,after it the value isn't changing,but i use these > sensors.When i use these ones with the standard control panel,these > work without problems.Please help me! > > Gyula Priskin > Hungary The 9v sensors are active devices that require multiplexing power and return signal on the pair of wires. The devices have a bridge rectifier inside them to deal with the unknown polarity that they will be plugged into, and capacitance to store operating charge when returning a signal. To use the sensor, you need a circuit that can switch a 9v level on and off, and a way to measure the voltage on the sensor (only interesting when your supply voltage is off). The technique is to provide the sensor with the 9v to charge its capacitor (about 1 msec, depending on the current drive capability of your voltage source), turn off the voltage supply, and then measure the voltage on the sensor. For about 1 msec after you turn the voltage supply off, the sensor will have a valid and stable voltage that reflects its sensed parameter. Here is a circuit that I am currently using in my Programmable Brick design: +9v | / \ 47 ohm / 1/2 W \ +5v | | / / 1k |< \ 10K +--/\/\--| pnp (2n3906) / | |\ | LEGO | \---------+--->|----+---------o sensor o----+ 10K |/ | 1N914 | | ctrl--/\/\--| npn (pn2222) | | | |> | +-/\/\-- 6811 analog gnd | | 1K input | | gnd | +--->|--- etc. The control signal runs into an NPN transistor. When ctrl is high, the NPN turns on, drawing current through the emitter-base junction of the PNP and thus turning on the PNP. This provides approx. 9v which charges the LEGO sensor through the 1N914 diode. Then the ctrl signal is turned off, the voltage on the LEGO sensor may be measured. The 10K resistor is used as a pullup when measuring the LEGO sensor voltage so that the two passive 9v LEGO sensors may be used (touch switch and thermistor). The 1K resistor in series from the sensor pole to the 6811 analog input serves to the protect the 6811 from excess current when the transistor pair is turned on (and providing +9v to the sensor). The 47 ohm, 1/2 watt resistor protects the PNP from a short circuit on the LEGO sensor connector. The diode serves to isolate individual sensor input circuits so that multiple sensors can be driven from one transistor driver pair. Anyhow you see that it is not a no-brainer to interface the LEGO sensors to the Mini Board/6.270 board/Handy Board, but this is how it can be done. -Fred Date: Tue, 7 Mar 1995 13:58:35 -0500 From: "Fred G. Martin" Subject: 4.5v LEGO IR sensor Duh, of course you must mean the 4.5v infrared reflective LEGO sensor. The 4.5v is much easier to use. Just bias it with a 2.2K resistor and a 5v supply and measure the voltage: +5v | / \ / 1 to 5K (experiment for best result) \ | +--------- Vout | o 4.5v LEGO optosensor o | | gnd The 4.5v IR LEGO opto has a bridge rectifier so you can't get the polarity wrong, an IR emitter, and an IR phototransistor. In this circuit, the Vout is proportional to the current through the phototransistor, which is related to how much light it sees. So you can easily get much higher bandwidth from this device than the new 9v visible reflectance sensor. One cool thing about the new 9v angle sensor is that it is quadrature, so it can tell when the shaft changes direction. You can't do that with the old sensor and counter wheel unless you use two of them per shaft. -Fred Article 22091 of comp.robotics: Newsgroups: comp.robotics Path: 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