Robo-Rats Electronics: Interfacing Sensors to the Handy Board
The Handy Board Technical Reference describes how to interface many sensors to the Handy Board. However, with the DRL Daughterboard installed, the 0.1 inch male header cannot be used. The daughterboard has terminal blocks which allow you to easily connect wires to the digital and analog inputs (and other signals including the motor outputs). This makes for easy sensor testing, since there is also one +5V and two GND connections on the J17 terminal block (see the daughterboard page for the location and pinout of the J17 connector). Unfortunately, there was not space to install terminal blocks for all the ground and +5V connections on the Handy Board. While a few wires can be inserted into each terminal block position, you may not be able to get all your +5V and GND wires into the J17 terminal block. There are two solutions to this problem: 1) using a pigtail, and 2) using a Molex connector.
A pigtail is a single wire which branches into many wires. The single wire is usually of a larger gauge than the branching wires. To use a pigtail, you would insert the large wire into the terminal block and solder many smaller wires to it as needed. One problem with using a pigtail is that it is difficult to disconnect wires from it--at the very least you have to unsolder them. Also, it is difficult to insulate the pigtail.
If you need more +5V and GND connections, we recommend using the Molex connector method. This is done by inserting 0.1 inch male right angle headers in the +5V and ground terminal strips on the Handy Board so they extend beyond the daughterboard. Then you crimp Molex pins to your wires and insert the Molex pin into the Molex housing. The Molex housing is then plugged into the header. Below is a photo of the right angle headers and the Molex housings included in your Robo-Rats kit:
The 8-pin 0.1 inch right angle header is shown in the upper left. The 8-position Molex header is shown in the lower left. The 6-pin 0.1 inch right angle header is shown in the upper right--note that the distance between the black plastic strip and the 90° bend of the pins is greater on the 6-pin header than on the 8-pin header. The 6-position Molex header is shown in the lower right. The 8-pin right angle header is inserted into the GND terminal strip on the Handy Board, and the 6-pin right angle header is inserted into the +5V terminal strip as shown below:
Note that the daughterboard must be removed to allow you to insert the headers. Please be careful when removing the daughterboard! You have to gently pull up on the daughterboard on one side at a time, going around on all four sides. You should only move the daughterboard by a small amount each time. If you pull too hard on one side and that side comes out all at once you may bend the pins on the other side of the board.
Molex pins are small metal contacts that are crimped to wires and inserted into the Molex housing. There is a special tool for crimping the contacts and a special orientation for inserting the pins into the housing. The pins can also be removed from the housing if you need to make a change to the design. Please get instructions from Keith Kotay before using the Molex connectors.
In general, you should use the terminal block connectors to prototype your design. Only after you have finalized the design should you look for a more permanent wiring method (this will prevent you from having to redo connections).
The Handy Board Technical Reference has a good description of how to wire a photocell to the Handy Board (page 42). The resistance of the photocells on your kit are 50 Ohms - 200K Ohms depending on the amount of light. The voltage you will sense at the analog input also depends on the value of the pullup resistor, since the photocell and the pullup resistor for a voltage divider. The value of the pullup resistor on the Handy Board is 47K Ohms. The output voltage of the circuit is:
Voutput = 5V (Rphotocell / (Rphotocell + Rpullup))
The following table shows observed values of the photocells in your kits:
Voltage (Digital Value)
|Black foam on face of photocell||200K Ohms||4.049V (~206)|
|Ambient light in lab, pointing horizontally||3.6K Ohms||0.356V (~18)|
|2 feet from illuminated food object||3.2K Ohms||0.319V (~16)|
|1 foot from illuminated food object||2.1K Ohms||0.214V (~11)|
|1 foot from 75W lamp||200 Ohms||0.021V (~1)|
Note that the values you are likely to observe in the competition are clustered in a narrow range: 11-18. This is a result of the large pullup resistor value relative to the photocell resistance in the test conditions. With the range so close it is likely that noise will cause false readings and make it very hard to detect the illuminated food object, at least at any distance over 1 foot. This can be fixed by placing another resistor in parallel with the default pullup resistor. Since the default pullup resistor is connected to the analog input and +5V, placing another resistor from the analog input terminal block position to +5V will cause the two resistors to be in parallel. The formula for the total resistance of two resistors in parallel is:
Rtotal = 1 / ((1 / R1) + (1 / R2))
For example, placing a 10K Ohm resistor in parallel with the default 47K Ohm resistor would give this result:
Rtotal = 1 / ((1 / 10K Ohm) + (1 / 47K Ohm)) = 8.2K Ohm
The Handy Board Technical Reference has a good description of how to wire a switch to a digital input of the Handy Board (page 42). Note that a pullup resistor is required to present a HIGH logic level when the switch is not closed. It is possible to connect a switch to an analog input if you have no digital inputs available.
The Handy Board Technical Reference section on interfacing an infrared reflectance sensor (which contains both an emitter and a detector) describes how to connect an infrared emitter to the Handy Board (page 43). The choice of current limiting resistor affects the intensity of the LED. The Handy Board Technical Reference suggests a 330 Ohm resistor. The equation for current flow is:
ILED = (V - VLED) / R
Substituting +5V for V, 1.8 for VLED (the normal voltage drop across an LED is 1.8V), and 330 Ohms for R gives:
ILED = (5V - 1.8V) / 330 = .00970 Amps (9.70mA)
This is a safe amount of current for an average device, however some devices can take over 25mA of current (check the device datasheet for the maximum allowable current). More current means more light--this may increase the distance/sensitivity of your sensor (it will also drain your battery quicker, so be cautious about current comsumption).
The Handy Board Technical Reference section on interfacing an infrared reflectance sensor (which contains both an emitter and a detector) describes how to connect a typical infrared detector to the Handy Board (page 43). The IR detector is often just a special, light sensitive bipolar transistor, although sometimes there may be additional circuitry added to provide a digital output instead of an analog output (in this mode it could not be used for distance sensing). There are two types of bipolar transistors: NPN and PNP. The difference between the two is not significant for our purposes, so I will limit the discussion to NPN types. A transistor (NPN or PNP) is a three terminal device: emitter, base, and collector. In an NPN device the emitter is commonly connected directly to ground and the collector is connected to the positive voltage with a resistor. The base is the input terminal for the transistor and the collector is the output terminal (in some configurations the emitter can be the output terminal, but we won't deal with that case here). The principle of operation is simple: a small amount of current traveling from the emitter to the base will induce a much larger current from the emitter to the collector. Thus the transistor amplifies the current present on the base and the resulting voltage change on the collector as a result of the collector current traveling through the collector resistor is the output.
In the case of the IR detector, there is no base terminal. When photons from the emitter fall on the light sensitive area of the detector, they induce a small current which appears at the base of the transistor. This small current is amplified by the transistor and can be used to sense the amount of light from the emitter. Wiring an IR detector is easy: just connect the emitter to GND, attach one end of a resistor to the collector and connect the other end of the resistor to the positive voltage. In the case of the Handy Board, things are even easier--since the analog inputs have pullup resistors to +5 volts, just connect the collector to an analog input.
Note that the value of the collector resistor will affect the sensitivity of the infrared detector. The voltage at the collector, Vc, is a function of the collector current, Ic, and the collector resistor, Rc. Assuming a +5 volt power supply we have the following equation:
Vc = 5V - Min((Ic * Rc), 5V)
(Note that (Ic * Rc) can never be larger than 5V, thus the use of the Min function). So, if Ic = 1 mA and Rc = 1000 Ohms, Vc would be:
5V - Min((0.001 * 1000), 5V) = 4V
However, if Rc = 47 K Ohms (the value of the pullup resistor in your Handy Board), the result would be:
5V - Min((0.001 * 47000), 5V) = 0V
(In practice it is impossible to get a 0V reading at the collector, but voltages on the order of a few tenths of a volt can be achieved).
For IR detectors, the only way the increase their sensitivity is to increase the value of the collector resistor. However, as the collector resistor value is increased, the linearity of the transistor will be reduced. Transistors have a fairly narrow range in which they are linear (collector current responds linearly to base current). Increasing the collector resistor value beyond a certain point will cause the transistor to act more and more like a digital device (a switch) than an analog device. This is okay if you only want to detect the on/off state of the emitter, but if you want to linearly sense distance over a large range you need to operate the transistor in its linear mode. The best thing to do is experiment with different resistance values and see what works best.
Infrared Emitter/Detector Pair
An infrared emitter/detector pair is a single device with both an emitter and detector in the same package. Refer to the infrared emitter and infrared detector sections above for information on how to interface these devices. In many cases, the emitter has the markings A & K -- A referring to the anode of the emitter and K referring to the cathode. The anode should be connected (possibly through a resistor) to the positive voltage source, and the cathode should be connected (possibly through a resistor) to ground (it is necessary to have a resistor on the anode or cathode terminal to limit current). The detector often has the markings E & C -- E refers to the emitter and C refers to the collector.
The beam breaker is essentially an infrared emitter/detector pair, however there is extra circuitry on the detector side to convert the analog output of the detector transistor to a digital signal. The emitter has the markings A & K -- A referring to the anode of the emitter and K referring to the cathode. The anode should be connected (possibly through a resistor) to the positive voltage source, and the cathode should be connected (possibly through a resistor) to ground (it is necessary to have a resistor on the anode or cathode terminal to limit current). The detector has three terminals: V, O & G. V should be connected to +5V, G should be connected to ground, and O is the output of the sensor. O should be connected to a digital input with a pullup resistor.
Hall Effect Sensor
The Hall Effect sensor is designed to detect the presence of a magnetic field. It works very well as a non-contact position sensor in conjunction with a small magnet. Sensing at a distance is somewhat more problematic, hence the large rare-earth electromagnet used on "poison" food items. There are several types of Hall Effect sensors--they differ in whether they are analog/digital and as to the magnetic field characteristics they can sense. The sensors in your kit are unidirectional--they only respond to a specific field direction. The magnets in the poison foods will be oriented such that your sensors will be effective when the brand (the numbers on the package) are pointing away from the magnet.
Connecting the Hall Effect sensor is easy: connect Vcc to +5V, GND to ground, and Output to a digital input with a pullup resistor (see the datasheet for information on pin numbers).
Note that a pullup resistor is required for the Hall Effect sensor. This is because it has an open-collector output. It is called open-collector because the collector of the output transistor is directly connected to the output pin. This may not seem like a good idea since it would be much easier to incorporate the collector resistor inside the unit to same space, but there are two good reasons to use open-collector parts:
A good example for #2 is using multiple Hall Effect sensors to detect the poison food items. The Hall Effect sensors in your kits can sense the magnets from approximately one inch above the magnet. However, sensitivity falls off extremely quickly as the sensor is moved outside the body of the magnet. Therefore you may need several Hall Effect sensors on your robot to monitor a large area. By connecting the outputs of the sensors together you only need to run one wire back to the Handy Board, which saves wiring time and digital inputs.
Back to the Robo-Rats Electronics page
Back to the main Robo-Rats page
Last modified: 05/09/01 19:53