Pin Connections
See to the right a list of all the pin connections. The port T (PT) pins are tied to the internal system timer. Therefore the Output Compare pins, which are set to do something when an internal timer runs out, must be on T pins. In our case, most of the Output Compare pins were not actually used to set an output on the physical pin itself, but were instead used internally to perform calculations are regular intervals. The exception is PT4, where an internal Output Compare timer was used to perform Pulse Accumulator calculations (see further details in the "Interesting Note" section below) while the physical pin was set as an output to be separately toggled to turn the Ball Collector motor on or off.
All of the Input Capture pins were used to capture rising or falling edges to detect events from IR light beams being tripped, such as balls passing into the bin or black tape being sensed on the field. The port U (PU) pins can be used to generate precise Pulse Width Modulation (PWM) signals, which are used to control the speeds of the DC drive motors and the positions of the servo motors. Finally, the analog/digital ports (PAD) took in the analog values from the IR distance sensors to provide precise information on proximity to the arena walls. Interesting Note: The neatest part of the pin connections was the combination of Pulse Accumulators (PT3 and PT7) with an output compare (PT4). The Pulse Accumulators were tied to the motor encoders, tallying up ("accumulating") the number of encoder pulses seen. The output compare on PT4 was then used to periodically read the number of accumulated pulses, divide this number by the time since the last measurement, and use this as an averaged value for encoder pulse frequency, i.e. motor speed! Adding a proportional-integral feedback control scheme to this motor speed measurement granted very precise control over robot movement, whether driving in straight lines or moving for pre-programmed distances. |
IR Beacon Detection Circuit
A two-stage op-amp circuit is used to capture the signal from square-wave infra-red light pulses that indicate which bin the robot is looking towards. As highlighted within the image to the right, the Trans-resistive Circuit converts an IR phototransistor current into a voltage, the two-stage op-amp Gain Stage with an AC Coupling circuit is used to reduce noise and amplify the signal, and a comparator at the end ensures a digital output.
Interesting Note 1: We chose to use two op-amps instead of just one because we wished to have a significant gain on the system, but it is also well known that op-amps rapidly gain error on their output as you increase the gain. To minimize error, we used two op-amps and limited each to no more than a gain of 10 due to accuracy dropping off with input frequency. Given the relatively low frequency of the IR beacons (order of 50Hz) this design may not necessarily have been needed, but it was a precaution to ensure accuracy. Interesting Note 2: We made the gains on the two-stage op-amp circuit so large that the signal into the comparator was already railing high and low. Therefore, we did not use the typical Schmitt-triggered hysteresis on our final output, but instead found a standard comparator sitting around a 2.5V reference worked well. For more in depth calculations, see:
|
Ball Collector DC Motor
A very simple motor driver circuit is used to drive the ball collector motor. A power N-MOSFET powers the system on or off, and it only runs in one direction.
For more in depth calculations, see:
|
Motor Driver Circuits
Each motor was driven with an LMD18200 chip. These chips allow for an extremely large current (several Amps) if needed by the motors. Further, the external bootstrap capacitor (labelled here as C4) is used with an internal charge pump to help the square-wave PWM signals rise up more crisply at very high frequencies. This bootstrap cap was especially useful for our robot because the specific motors we used had electrical time constants of about t = 34 microseconds. This means that we wanted to run the PWM at a frequency of at least 1/t, or 29.2 kHz, to
help avoid current ripple in the system. We ultimately ran the PWM at 30kHz on the dot, with the charge pump capabilities of the chip working well at this high speed. |
IR Wall Detection
Two Sharp-brand IR distance sensors were positioned near the front of the bot to sense nearby walls. Internal electronics on the sensors output a simple analog value corresponding to the distance sensed.
We noticed significant noise on the output from these sensors, leading to false events being detected when out saw spikes of falsely high signals. A low pass filter with a 15kHz corner frequency was added onto the system to eliminate much of the noise. Interesting Note: We would have preferred an even lower corner frequency on this low pass filter, but we found that the capacitor values needed to be extremely small or else the output signal would be very slow to respond, due to the IR sensors having a weak output that could be drowned out by larger capacitor values. |
Tape Sensors
Two tape sensors were poised near the front of the robot, one on the left and one on the right, looking down to read black tape lines on the arena floor. The tape sensors literally consist of just an IR LED and IR phototransistor package near each other in such a way that the phototransistor can pick up reflections from the LED on nearby surfaces. Especially when quickly moving from a white arena floor to a black line of tape, the sensor output flips between the ground and 5V high side value, but we still used a comparator to have crisp digital outputs to the microcontroller.
The current flowing through the IR LED is equal to (5V - 1.7V)/(100 Ohms) = 33mA. This is below the maximum continuous forward voltage of the emitter (50mA). According to the datasheet, the minimum current flowing through the IR phototransistor is 100nA and the absolute maximum is 20mA. The voltage at the inverting input of the LM339 is approximately 5V when there is no incident light on the phototransistor. The voltage at the inverting input decreases as the intensity of the incident light increases. The voltage on the inverting input of the LM339 is approximately (5V * 10k)/(10k + 10k) = 2.5V. The output of the LM339 is approximately 0V when there is no light incident on the phototransistor (when the sensor is over a non-reflective surface) and the distance from the sensor to the floor was chosen so that the output voltage goes high when the detector is over a reflective surface. Ball Counter IR
The ball counter circuit is schematically identical to the tape sensors described above. The main difference is that instead of using an IR LED and IR Phototransistor packaged together as a unit, they were two individual components posted facing towards one another so that a passing ball could block the signal between them to indicate another ball being collected!
|
|
Servo Motors
The robot uses two servo motors. The first actuates the gate to deposit balls from the top of the robot. The second has pins attached to the arm (or "horn") so that when it swings left or right it can pop one of the balloons to indicate team color!
Power
Three 7.2V NiCad batteries were wired together for a 21.6V power source. The raw 21.6V was used to drive the DC motors, but all the other electronics in the robot were powered through a 5V regulator drop from this higher voltage source.
Further, a 2.5V buffer was used in several places as a reference signal, and this was achieved via |