Ir Emitter Detector Writeup

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

IR Emitter/Detector Circuit Overview

An IR Emitter/Detector circuit leverages an IR LED and phototransistor pair to generate a signal based on
proximity or reflectance of an object within the emitter/detector field-of-view. This provides the unique
opportunity to create an autonomous system that can “follow a path” of high (or low) reflectance by
comparing logic-level outputs of several (two or more) IR emitter/detectors and performing path
correction procedures in software based on these outputs. For the purposes of the Super/PAC
competition, IR emitter/detector pairs are laid out in a configuration suitable for path correction
purposes as well as junction sensing. The layout is illustrated in the following picture.

Figure 1: Simple schematic of tape sensor configuration. The trio of tape sensors at the geometric center of the robot detects
the junction, and the tape sensor at the tail of the robot provides redundancy in path correction

Signal Conditioning Justification


A simple implementation of the tape sensor would provide constant voltage to the IR LED, and as a
result, the signal detected by the IR phototransistor would be a DC analog signal that could then be
amplified (probably via transimpedance amplifier) and passed through a comparator to convert it into a
logic-level high or low. Depending on the amount of physical isolation between the sensor and this
environment, this might be adequate. However, numerous sources of interference are present in the
competition that could generate noise within the signal:

1. DC offset due to the sun’s cycle (1.16E-5 Hz)


2. Ambient lighting (60 Hz)
3. State Beacon (1 kHz)
4. Primary Beacon (5 kHz)
5. Other electronic signals (up to several tens of kHz)

Given this, it was decided that the tape sensor LED’s would generate AC pulses at a relatively high
frequency (~40 kHz) such that all lower frequencies could be eliminated via filtering. The signal would
then be amplified, converted to DC, and sent through a comparator to provide a logic-level high or low

1
based on whether or not the IR emitter/detector is over tape or not. A functional block diagram of the IR
emitter/detector circuit implemented in our tape-following subsystem is given below.

Figure 2: Functional block diagram for IR Emitter/Detector Circuit

1. 555 Timer: Generates an astable square wave with a frequency of 40 kHz that will drive the IR
LED
2. IR Phototransistor: Connected in a sourcing configuration with a 1k resistor to ground
3. High-Pass Filter: with a cutoff frequency of 15 kHz, this filter will attenuate any DC offset and
60-Hz ambient interference, as well as the 1 kHz and 5 kHz infrared signals generated by the IR
beacons.
4. Non-inverting amplifier: boosts the output of the high-pass filter with a gain of 100.
5. Peak Detection: Converts the AC source to a DC signal dependent on the amount of reflectance.
6. Comparator with Hysteresis: Compares the output of the rectifier to a threshold voltage
tunable by a 20 kHz potentiometer.

The output of the comparator produces a logic-level high or low depending on reflectance. The
threshold voltage is set by a potentiometer, allowing the circuit to be “tuned” based on gameplay
conditions.

Component Calculations
555 Timer
The resistances ଵ and ଶ , as well as the capacitor ଵ , dictate the frequency of oscillation for the 555
timer according to the following equation:

1.44

ଵ 2ଶ ଵ

Thus, for ଵ  1 , ଶ  1 , and ଵ  0.01, the oscillation frequency is ~40 kHz, which is well above
the highest beacon frequency of 5 kHz. The rise/fall times of IR emitters are on the order of 10μs,
corresponding to a switching frequency of 100 kHz, so we can expect a sawtooth output at a switching

2
frequency of 40 kHz but the emitter should still have enough switching time to output its maximum
value. This will allow the opportunity to filter out these signals and remove their impact from the tape-
following signal.

The number of IR LED’s that the 555 timer can drive depends on the sink current cap of 200 mA for the
555 timer. Assuming a 1.6V drop across each IR LED, and a 0.35V drop across the 555 output in the low
state, we can calculate resistor ଷ assuming we use 2 IR LED’s in series:

஼஼ − 10% − 2ி − ௗ௥௢௣ 4.5 − 2 ∙ 1.6 − 0.35


ଷ = = = 47.5
ி 20

In the worst-case scenario we might presume no forward voltage drop across the IR LEDs and no drop
across the 555 output to calculate the maximum current possible.

஼஼ + 10%
௠௔௫ = = 117
ଷ

Thus we can see that a 555 timer can only support 1 string of 2 serial IR LED’s in the worst case. As a
result, it is necessary to use 2 555’s to drive the output of the 4 IR LEDs.

The output of the 555 timer into the IR LED, and the output of the phototransistor, are both shown in
the following figure. Note the sawtooth nature of the phototransistor output due to the rise-and-fall
times of the IR LED.

Figure 3: 555 timer output, frequency of 40 kHz

Phototransistor in Sourcing Configuration


The phototransistor acts just like a BJT, except current flow from the collector to the emitter is
controlled by the amount of IR the transistor is exposed to. We select the value of the pull-down resistor
by optimizing a tradeoff between two conditions. First, we want to limit the maximum current flowing
through the phototransistor to less than 20 mA of continuous current, which favors using a large resistor
value. However, the resistor also introduces an offset corresponding to the following equation:

௢௙௙௦௘௧ = ஼(ைே) ௉஽

3
Where ஼(ைே) is on the order of 0.2 mA. Even with no reflectance, a collector dark current of 100 nA
leaks through the phototransistor, which when multiplied by the value of the pull-down, results in a
steady DC offset that is subsequently multiplied by whatever gains exist in the circuit. As such, we want
to hold the resistor to a pretty small value. 1 kΩ is a good compromise between the two
aforementioned conditions.

The following scope trace is the output of the phototransistor. Note the offset of ~200 mV which, when
multiplied by 1 kΩ, corresponds to an ஼(ைே) of 0.2 mA which is an expected value.

Figure 4: Phototransistor Output

High-Pass Filter
As we have a 40 kHz signal that we are trying to condition, we would like to filter out all lower-frequency
noise introduced by environmental factors and the beacons. With a cutoff frequency of 15 kHz, the RC
constant is calculated as follows:

1 1
௖ = →  =
2
 2
∙ 15 

Selecting ଷ = 0.01 and ହ = 1 , we can calculate the gain of certain driven frequencies given the
following equation:

( )
 =
(1 +  ଶ )

The response of this filter is plotted on the next page. For the expected signals, we expect the following
gains:

Frequency Gain
60 Hz 0.004
1 kHz 0.063
5 kHz 0.300
40 kHz 0.930

4
Figure 5: Frequency response of high-pass filter

Thus we expect to keep 93% of the signal of interest, while attenuating the next-closest signal to 30% of
its unfiltered value. The location and orientation of the tape sensors (under the robot, perpendicular to
the path of beacon wave propagation) will offer physical isolation, and the high-pass filter will take care
of the rest.

As the high-pass filter acts as a differentiator and the input is a square wave, part of the signal will go
below 0 volts at the output of the filter. This will negatively saturate the op-amp in the next stage; we
could prevent this using half-wave rectification which will only hold on to the positive part of the signal.
This is done by simply adding a forward-biased diode and a resistor to ground.

A scope trace of the high-pass filter output with full reflectance is shown below. Observe how the signal
is still attenuated despite selecting a corner frequency far below the signal frequency. Also observe the
differentiating action of the high-pass filter as part of the signal drops below 0V.

Figure 6: Attenuated phototransistor signal due to high-pass filtering

5
Non-inverting amplifier
The gain of this amplifier was determined empirically based on typical unamplified signals from the
filter, such that we want a ~5V voltage swing between zero reflectance and full reflectance; we are not
too worried about op-amp saturation as we are not really concerned with linearity. The LM6144 op amp
was chosen for this application, due to its ability to swing within a few millivolts of positive and negative
rails. Additionally, the input bias current is only 526 nA worst-case, which amounts to fractions of a
millivolt when amplified by the gain we expect. When the phototransistor just beings to detect
reflectance, the signal peaks at about 50 mV, so it was decided that a gain of 100 was to be used.
Resistor values ଻ and ଼ were determined based on the gain equation for a non-inverting amplifier:

଼
 = 25 = 1 + 
଻

One thing we have to be wary of is the gain bandwidth product (GBP) of the op-amp, as gains become
less stable at higher frequencies. For the LM6144, the GBP is 10 MHz when given an input signal with a
50 kHz frequency. We can calculate the maximum gain achievable at a certain frequency given the
following formula:


  =
௦௜௚௡௔௟

Given a signal of 40 kHz, the maximum stable gain achievable is 250, which far exceeds our amplification
requirements.

The output of the op amp is shown in the following figure. Note the saturation of the op-amp, as the top
and bottom peaks are cut off at 0 and 5V. This is okay for our application, as we aren’t too concerned
with linearity. Rather, we only want a binary output: HIGH for reflectance, LOW for lack thereof. So
saturation is fine.

Figure 7: Output of the amplifier

6
Peak Detection
At this point we have a filtered and amplified signal, but it is still AC which we can’t do a whole lot with.
To convert this signal to DC, we use a peak detector to “approximate” AC to DC conversion. A diode
prevents voltage from flowing backwards, thus maintaining only the positive part of the signal. The
decay time between peaks is set by a resistor and a capacitor in parallel. If the RC time constant is large
enough when compared to the period of the input signal, the capacitor won’t finish discharging by the
time the next positive pulse comes up in the signal, so the output voltage will dance around the peak
voltage of the AC signal. However this introduces a tradeoff; if the time-constant is too large, the
response of the peak detector to sudden change is slower. Choosing a cutoff frequency of 500 Hz, we
realize a time constant of ~0.3 ms which offers adequate response time for our application. Thus, ଺ and
ସ were chosen to be 33k and 0.010μF, respectively.

A scope trace of the peak detection at work is shown in the following figure. Note that the decay time
set by ଺ and ସ approximates a DC signal at the peak voltage of the input signal.

Figure 8: Output of the peak detector

The output of the peak detector is then passed through a buffer such that it retains a near-ideal transfer
function, as the inputs of the buffer draw negligible current.

Comparator with Hysteresis


The comparator’s purpose is to compare the conditioned signal from the phototransistor with a
reference voltage. If the signal exceeds the reference, the comparator will saturate (giving a logic-level
“high”). If the signal is less than the reference, the comparator will drop to 0V. Since the conditions of
the surface aren’t well-known at this point, the reference voltage is set by a potentiometer which allows
the output to be manually tuned based on surface conditions until the comparator operates as
expected. Hysteresis was implemented which will give the comparator a 0.2V threshold around the
reference voltage such that “false triggers” due to noise within the signal are ignored. When in a non-
inverting configuration, the hysteretic threshold is set by resistors ସ and ଵଵ according to the following
equation:

7
ଵଵ
∆ = ௖௖
ସ

As the LM339 is open-collector output, we require a pull-up resistor in order to interface with the TTL
logic input of the arduino. This resistor value is 2.2k.

The comparator output in the high-state is shown in the following figure.

Figure 9: Logic-level comparator output

The Circuit
A circuit diagram of the full tape sensor circuit, implementing four independent IR emitter/detector
pairs, is given in Figure 10. The circuit is essentially a single phototransistor circuit duplicated four times,
and a coupled IR LED circuit duplicated twice. Note that efforts were made to reduce capacitive coupling
(namely, caps across the rails and IC power supplies), and these capacitors aren’t represented on the
circuit diagram.

Testing Results
The circuit works best as long as the tape sensors are within ~0.5” of the surface they are reflecting
from, which is plenty for our purposes. This is pretty typical, as the collector current from the
phototransistor in most commercial reflectance sensors peaks out at around 1/8” or so and deteriorates
at an exponential rate past this peak. Ambient light and other signal sources seem to have negligible
effect on the signal (as designed). The scoped waveform of the filtered signal into the comparator is a
pretty clean DC which maxes out at 5 volts in a full reflectance situation.

8
V3 V2 V6
5V 5V 5V
R4 +V
+V U4A +V 100k
C3 U9B
LM6142A/NS D3 LM6142A/NS
V1 10nF R6
+ 1N4938 R11
5V + 47k 2.2k
+V

R3 R5 U2C
1k R8 LM339
47 100k C4
R9
10nF R16 10k 50%
D1 Q1 R7 33k
LED1 R10 1k
1.0k

U1
R1 555 V4
1k V5 V7
5V 5V 5V
Gnd Vcc R13 +V
Trg Dis +V U5A +V 100k
C6 U3A
Out Thr LM6142A/NS D4 LM6142A/NS
Rst Ctl 10nF R14
D2 + 1N4938 R12
+ 47k 2.2k
R2 LED1
1k
Q2
C1 R20 U2D
.01uF C2 R19 LM339
.01uF 1k 100k C5
R17
10nF R15 10k 50%
R18 33k
R21 1k
1.0k

V12 V13 V11


5V 5V 5V
R32 +V
+V U10B +V 100k
C10 U10A
LM6142A/NS D6 LM6142A/NS
V14 10nF R33
+ 1N4938 R31
5V + 47k 2.2k
+V

R40 R38 U8B


1k R37 LM339
47 100k C9
R35
10nF R34 10k 50%
D8 Q4 R36 33k
LED1 R39 1k
1.0k

U11
R42 555 V10
1k V9 V8
5V 5V 5V
Gnd Vcc R29 +V
Trg Dis +V U6A +V 100k
C7 U7A
Out Thr LM6142A/NS D5 LM6142A/NS
Rst Ctl 10nF R28
D7 + 1N4938 R30
+ 47k 2.2k
R41 LED1
1k
Q3
C12 R23 U8A
.01uF C11 R24 LM339
.01uF 1k 100k C8
R26
10nF R27 10k 50%
R25 33k
R22 1k
1.0k

Figure 10: Tape Sensor circuit diagram

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy