AN_EricHatch

advertisement
A Method for Encoding and Decoding Simple Command Over the Voiceband
Application Note
ECE 480, Team 3
April 2, 2010
Author: Eric Hatch
Hatch
Abstract
Designing RF equipment for a specific frequency is an evolved and expensive process.
Therefore, it is desirable to use equipment that is already available or in place to transmit data or
commands. This method creates a set of audio frequency tones for each command. The tones are
then transmitted using available voiceband equipment. For example, these signals can be sent
over radio, television, telephone or any medium made for the voiceband. This application note
explains how to encode/decode, and implement and encoder/decoder for tone signaling.
Outline
I. Choosing tones .......................................................2
harmonics
separation
multiplexing
II. Creating Tones ......................................................4
Phase Shift Oscillator
Multiplexing
III. Decoding Tones ...................................................7
Buffer
Filters
Peak Detector
Crossing Detector
Logic
IV. References............................................................13
1
Hatch
I: Choosing tones
The frequency of each tone can theoretically be anywhere in the voiceband: 20 Hz to 20 KHz if
they are perfect sinusoids. However, there are a few things to watch out for when selecting the
tones.
Harmonics
Most methods of creating sinewaves also create unwanted harmonics. Care must be taken so that
the harmonics do not register as a different tone. Therefore, no tone's frequency should be a
multiple of another tone's frequency. For example, If tone 'a' has frequency f a , its Fourier series
may look something like this:
v a t   Va ,max 1.27 cos2  f a t   0.424 cos2 3 f a t   0.255 cos2 5 f a t   0.182 cos2 7 f a t   ...
(This is a worst case scenario, as this is the decomposition of a square wave.) If the second
frequency is chosen to be f b  3 f a , this could pose a problem because the decoder could detect
f b when only f a is sent. However, multiples of frequencies still want to be avoided. If f b is
much higher than f a , then f a 's harmonics may be attenuated enough so they are not detected
by f b 's filters. For example, if f b  15 f a , the decoder should work as intended because the 15th
harmonic of a signal is very small.
Separation
The tones must be separated by some amount due to the dependability of the oscillators and the
bandwidth of the filters in the decoders. In some oscillators, the frequency varies slightly, so the
filter cannot be too sharp. Also, very sharp filters are difficult to design for the correct frequency
using standard components.
2
Hatch
Multiplexing
In order to prevent false positives from interference or other signals on that channel,
multiplexing can be enabled. Since tone signals are often used on voiceband equipment,
someone's voice could pass a certain frequency and trigger the decoder. To prevent this, a few
tones could be added together, so all tones need to be present for the input to be detected by the
decoder.
Example
These tone signals are intended to being transmitted over an FM radio over 5 miles in Tanzania
to indicate a request for an internet link to be powered up. There are two different stations that
this internet request could come from, and differentiating between the two is important. Also, the
radio is to operate at 433 MHz, which is unlicensed band in Tanzania. For this specific
application, two sets of two multiplexed signals are being implemented. The sets are:
set 1: f a1  123 Hz, f a 2  1.31 kHz
set 2: f b1  234 Hz, f b 2  1.24 kHz
3
Hatch
II: Creating Tones
Phase Shift Oscillator
A simple way to create relatively low distortion sine wave is with a Phase Shift Oscillator [1].
This schematic is shown in figure 1.
Rf
5
-
¼
LM324
Vout
+
R
2.5
C
C
C
R
R
2.5
2.5
Figure 1: Phase Shift Oscillator
This circuit is implemented using 5V single supply op amp. The 2.5V reference is implemented
using a simple voltage divider shown in figure 2. The capacitor is used to stabilize the reference.
4
Hatch
5
1k
2.5
1k
1µ
Figure 2: Voltage Divider to Create 2.5V Reference
The frequency of oscillation is determined by the following equation:
f osc 
1
2RC 6
In order for the circuit to oscillate, R f must be chosen such that:
R f  29 R
The method for implementation of this circuit is below.
1. Choose frequency of oscillation
2. Choose a standard component for C .
3. Choose R such that R 
1
2f oscC 6
.
4. Choose R f such that R f  29 R . An R f closer to 29R will create a less distorted
sinewave.
This circuit will create a sinewave with peak to peak amplitude of about 1.5V to 2.5V. Therefore,
a gain stage may be added to make use of the maximum voltage swing of the op amp. The op
5
Hatch
amp used in this circuit is an LM324 which is a very cheap quad op amp specifically build to
work well with single supply circuits. Any single supply op amp can be used for this circuit and
other circuits in this application note.
Multiplexing
Two or more oscillator outputs can be added together using a summing amplifier. Because of
this, it may be better not to add an amplification stage until the summing amplifier. A typical two
input summing amplifier is shown below in figure 3.
Rf
Ra
Va
5
Rb
Vb
-
¼
LM324
+
Vout
2.5
Figure 3: Summing Amplifier
The output of this circuit is given by:
Vout  Va
Rf
Ra
 Vb
Rf
Rb
Usually Ra  Rb  R f works, but if clipping occurs, lower R f to the next standard value. The
output of this circuit is fed to the transmission medium i.e. the radio transmitter input.
6
Hatch
III: Decoding Tones
The decoder circuit is made up of several stages. The output of the transmission medium such as
a radio is fed to a buffer. The next stage is composed of a band pass filter for each frequency.
Each frequency is detected with a peak detector and 'zero' crossing detector. The output of a
crossing detector is logical high or low. This is fed to an AND gate if multiplexing is used. The
output of the AND gate is a usable input for a microcontroller.
Buffer
Since the transmission medium's output impedance and power output may be different for each
application, a buffer is added as the first stage of the decoder circuit. This is simple non-inverting
voltage follower, which has very high (theoretically infinite) input impedance, allowing for
maximum signal transfer. This circuit is shown below in figure 4.
5
Vin
+
¼
LM324
Vout
-
Figure 4: Voltage Follower
Gain Stage
Depending on the output voltage of the receiving device, it may be necessary to amplify the
voltage of the signal. Ideally, this gain should be implemented such that the entire range of the
op amp's voltage swing capabilities is utilized. The voltage gain for this stage is:
7
Hatch
Vout R f

Vin
Ra
R f is a variable resistor in the circuit shown in figure 5. This is not necessary, but is helpful
when finding the maximum voltage signal without clipping.
Rf
5
Vin
Ra
-
¼
LM324
Vout
+
2.5
Figure 5: Inverting Amplifier with Variable Gain
Band Pass Filters
The band pass filters are the heart of the decoder. They are the first stage in actually detecting the
tones. In this application, the sharpness, or Q did not need to be extremely high, but it was
important that the filters had some degree of sharpness. To implement the band pass filters while
only using one op amp per filter, the circuit shown in figure 6 was used.
8
Hatch
C4
C3
R1
R5
Vin
5
R2
-
¼
LM324
Vout
+
2.5
2.5
Figure 6: Universal Second Order Filter, as a Band Pass Filter
This circuit, with different combinations of resistors and capacitors can be implemented as either
a high pass, low pass, band pass, or notch filter. What makes this ideal for this application is that
the voltage gain has complex poles. Therefore, a specific sharpness of the filter can be designed
for. The voltage gain is given by:
Vout

Vin
s
s2 
1
R1C 4
C3  C 4
R1  R2
s
R5 C 3 C 4
R1 R2 R5 C 3 C 4
Equating this to the general form of a second order band pass filter:
s
s2 
1
R1C4
H
C3  C 4
R1  R2
s
R5C3C4
R1 R2 R5C3C4
9

s2 
0
Q0
0
Q0
s  02
Hatch
This yields the following set of equations which can be solved in terms of H , Q0 ,  0 (or f 0 ) and
two of the component values. For convenience let these component values be C 3 and C4 , and
let C3  C4  C . Solving these equations:
R1 
Q0
H 0 C
R2 
Q0
 0 C 2Q02  H
R5 
2Q0
0C


Therefore, the design procedure for designing these band pass filters is:
1. Choose the gain, H . This should be around 1 or 1.2.
2. Choose the sharpness, Q0 , This should be around 10.
3. Choose the center frequency,  0  2f 0 .
4. Choose a standard value for the capacitors, C3  C4  C
5. Calculate R1 , R2 and R5 using the equations above.
Peak Detectors
To convert the detection of an AC signal into a usable DC voltage, a peak detector is used. This
circuit is shown in figure 7. The output of this circuit (when the signal is biased at 2.5V) is given
by:
Vdc  2.5  Vin,max  Vd ,on
Therefore, if the filter is only passing a very small signal, the output voltage is about 2.1V due to
the diode drop of about 0.6V. When the filter detects a signal, the output voltage is about 3.1V.
The resistor in parallel with the capacitor is there so that the input goes low soon after the tone is
10
Hatch
no longer present. Otherwise, the capacitor would stay charged longer. The specific diode is not
important.
1N4148
Vin
Vdc
0.1µ
1M
Figure 7: Peak Detector with Slow Leak
Crossing Detector
The DC output of the peak detector is sent to a simple crossing detector with a 2.5V reference.
When V dc is above 2.5V, the crossing detector's output goes high to about 4.8V. When V dc is
below 2.5V, the crossing detector's output goes low to about 0.8V. A crossing detector with no
hysteresis works well in this case because the diode drop in the peak detector circuit essentially
biases the signal to about 2.0V as far as the crossing detector is concerned. The crossing detector
is shown in figure 8.
5
Vin
+¼
1k
LM324
-
2.5
Figure 8: 2.5V Crossing Detector
11
Vout
Hatch
Logic
The AND gate used in this example was a 74LS08N. This is an IC with 6 two input AND gates.
The input to the AND gates are the outputs of the crossing detectors. The output of the AND gate
is an input to the Microcontroller in the entire remote control system.
12
Hatch
IV: References
[1] G. M. Wierzba, ECE 302 e-Notes. August 2008
[2] G. M. Wierzba, ECE 303 e-Notes. August 2008
[3] G. M. Wierzba, ECE 402 e-Notes. August 2009
13
Download