RF Detector Using An Arduino PDF
RF Detector Using An Arduino PDF
+VCC
+5V Pull-up
1M
20p Ge
Pin C2
A/D A/D
A/D
1k
1n Si
LED
Figure 1. The classic detector receiver. Figure 2. Si diode with bias voltage. Figure 3. An LED RF detector.
An Integrating Detector
Listing 1. Measuring the LED voltage [1]. Maybe we could do with a bit more gain?
--------------------------------------------------- This could be achieved in principle by
UNO_RX1.BAS B1 RF out, C2 RF in using a higher value of pull up resistor.
--------------------------------------------------- Even better would be to just switch on
$regfile = m328pdef.dat ATmega328p the pull up resistor briefly and then go
$crystal = 16000000 16 MHz
into a high impedance state before the
$baud = 9600
measurement is made. The charge across
$hwstack = 16
the LED will dissipate during the mea-
$swstack = 16
$framesize = 16 surement period. The presence of an RF
signal will increase the discharge rate.
Dim D As Word You can think of the LED junction as hav-
ing a small value of capacitance. Every
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , peak of the received RF signal brings the
Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2 LED briefly into conduction which has the
Config Lcd = 16 * 2 effect of reducing the charge on its capac-
Cls itor slightly. The value of this capacitor
Cursor Off
is only a few picofarads. That means you
only need a very low level of RF current
Config Adc = Single , Prescaler = 64 , Reference = Avcc 5V
to produce a measurable effect. To give
Config Timer1 = Pwm , Prescale = 1 , Pwm = 10 , Compare A Pwm = Clear better sensitivity you can increase the
Up delay between turning off the pull up and
Tccr1a = &B10000010 Phase-correct PWM, Top=ICR1 making a measurement. This will how-
Tccr1b = &B00010001 Prescaler=1 ever make the circuit sensitive to low fre-
quency signals which can cause interfer-
D = 8 1 MHz ence. For this reason its better to make
Icr1 = D the measurement quickly after the pull
Ocr1a = D / 2 up has been turned off using a relatively
Portc.2 = 1
short sample time (Prescaler = 8).
The program in Listing 2 performs aver-
aging on the measurement samples to
Do
D = Getadc(2) determine the zero level D0. By comparing
Print D the zero level with the input we can find
Locate 1 , 1 out if an RF signal has been received. A
Lcd D drop of three A/D steps of the LED voltage
Lcd is recognized as the threshold to indicate
Waitms 500 a signal has been received. Tests indicate
Loop that a received RF signal of around 50 mV
is necessary. To flag this event, LED2
on the Elektor Shield is lit and a tone is
also function as a photo diode, a voltage the value 410 which corresponds to a produced at B2. You can hook up a sim-
stabilizer, limiter and a varicap, surely we voltage at the LED of around 2 V. Con- ple piezo loudspeaker here to make the
can get one to work as an RF detector as nect a 10 cm length of insulated wire to tone audible. The signal strength is also
well. LED1 on the shield is already con- C2 to act as an antenna. Attach a bare transferred serially but not available on
nected to the analog input ADC2. There wire at B1 and hold the other end of it. the LCD due to timing constraints. When
is also a 1 k resistor in series with the Your body is now connected to the signal an RF signal is received at the input an
LED but that should not give a problem. and becomes an antenna for the signal (almost) constant tone will be audible at
The internal 30-k pullup resistor can which can be picked up by a normal AM the output.
be configured to provide a bias voltage, radio receiver. Now take the insulated With this set up you can send and receive
perfect; we really dont need anything wire on C2 and couple it to the RF signal. Morse characters. For this the output
else to build the circuit (see Figure 3). You will see the measured value drop to frequency was raised to 2 MHz to give
below 400. Its interesting to note that increased range. For tests you can dab
And so to the software! Now we have the measured value remains at a con- your finger on the output pin B1 to send
already built our little RF test lab (List- stant level. The RF oscillations are not Morse signals. The other hand should
ing 1) and can begin programming it to registered because the sample rate of the close enough to the receiving antenna
generate an RF signal. A 1 MHz square A/D converter is relatively low and this to ensure reception of the signals. You
wave signal is output from pin B1. produces an averaging effect on the mea- can of course set up two Arduinos so that
The program enables the pull up resistor sured signal. The measurement shown is signals can be sent and received.
on port pin C2 and continually measures the average voltage across the LED which For test purposes a sine wave genera-
the voltage on ADC2. Here you can read drops as the RF signal gets stronger. tor was used as a RF generator with a
By the way, dont overlook the other use- Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 ,
ful components on the extension shield Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
(Figure 4). There are two push buttons Config Lcd = 16 * 2
and a pot to play with. With a little inge- Cls
nuity you could make use of these to Cursor Off
provide sensitivity adjustment, a Morse
key, call button, mute and standby Config Adc = Single , Prescaler = 8 , Reference = Avcc 5V
(150307)
Web Link Config Timer1 = Pwm , Prescale = 1 , Pwm = 10 , Compare A Pwm = Clear
Up
[1] www.elektor.com/150307
Tccr1a = &B10000010 Phase-correct PWM, Top=ICR1
Tccr1b = &B00010001 Prescaler=1
D = 4 2 MHz
Icr1 = D
RF in RFout Ocr1a = D / 2
LED1 LED2
D = 0
S2 S1
Piezo
For N = 1 To 50
1k
1k
10k Portc.2 = 1
Waitus 100
Portc.2 = 0
+5V
D = D + Getadc(2)
Next N
28 27 26 25 24 23 22 21 20 19 18 17 16 15
D0 = D / 50
GND
AVCC
C5
C4
C3
C2
C1
C0
B5
B4
B3
B2
B1
AREF
ATmega328p
Do
GND
VCC
RES
D0
D1
D2
D3
D4
D5
D6
D7
B0
X1
X2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 Portc.2 = 1
Waitus 100
Portc.2 = 0
100n
16MHz D = Getadc(2)
If D < D0 Then
22p 22p D = D0 - D
10k
If D > 2 Then
Contrast
Print D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 Locate 1 , 1
GND
VCC
VEE
RS
R/W
E
D0
D1
D2
D3
D4
D5
D6
D7
Lcd D
LCD Lcd
150307 - 14
Sound Portb.2 , 20 , 4000 LED2 and Piezo
End If
End If
Figure 4. Except for the two antennae and the
Loop
piezo beeper everything else is already on board
the Extension shield.