’
RF Detector using an Arduino Programmed Programm ed in Bascom By Burkhard Kainka (Germany)
Add an RF receiver to a microcontroller and you open up many possibilities. It doesn’t need to be complicated, for most applications you can get away with just using a simple diode detector; in fact we can even use a plain old LED for the job! Just take an Arduino Uno with an extension shield and you’v you’ve e already got all the hardware you’ll need. Now add the code, programmed in Bascom.
If you delve back into the history of RF receiver designs you are sure to find reference to the simple detector receiver using a germanium (Ge) diode. Microcontrollers have inputs able to measure analog signals so there is no reason why we can’t just hook up the output of the detector to one of the A/D inputs on the microcontroller and see if we can pick up some signals. Once you’ve got it connected you have already built a signal strength meter. The readings you make can be useful, for example, in the world of amateur radio to tune an aerial. The resonant frequency of the detector circuit needs to be adjusted to be in the range of the measured frequency. You You can also tune to a nearby medium wave station and check the received signal strength in your area. You might be surprised to detect things
you weren’t expecting. In my study at home I can tell when a streetcar passes by because it noticeably affects the received signal strength of an AM station around 720 kHz. There are two main reasons for using a germanium diode in the detector circuit shown in (Figure (Figure 1). 1). First off it has a low forward-conduction voltage. voltage. This means that signals as low as 100 mV will produce an output signal. Secondly its reverse-voltage resistance is not especially high, that’s useful to dissipate any charge accumulating on the output capacitor. If you replace it with a silicon diode such as a 1N4148, for example, you will need to receive a much stronger signal before you start to see an output signal from the circuit. You will also need to add some form of output load such as a 1 MΩ resistor.
That doesn’t mean that silicon diodes are all bad for this sort of application. You can make use of a bias voltage to offset the diode’s conduction threshold. Figure 2 shows 2 shows such a circuit without any form of tuned circuit for frequency selection so it’s got a very wide bandwidth. With no received signal you can measure a voltage of around 0.6 V at the diode. When a signal is received this voltage level drops noticeably. This circuit works well with RF signals of around 100 mV. It can be used as an RF signal monitor and works across the entire short wave band without the need for any selector.
An LED as a detector diode? Would it be possible to use the LED that’s already fitted to the Elektor Ext ension-Shield? We already know that LEDs
+VCC +5V
20p
Pull-up
M 1
Ge
Pin C2
A/D
A/D
A/D k 1
1n
Si LED
Figure 1. The classic detector receiver.
Figure 2. Si diode with bias voltage.
Figure 3. An LED RF detector.
www.elektormagazine.com January & February 2016
93
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Listing 1. Measuring the LED voltage [1].
‘--------------------------------------------------‘-------------------------------------------------‘UNO_RX1.BAS B1 RF out, C2 RF in ‘----------------------------------‘----------------------------------------------------------------$regfile = “m328pdef.dat” ‘ ATmega328p $crystal = 16000000 ‘ 16 MHz $baud = 9600 $hwstack = 16 $swstack = 16 $framesize = 16 Dim D As Word Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2 Config Lcd = 16 * 2 Cls Cursor Off Config Adc = Single , Prescaler = 64 , Reference = Avcc
‘ 5V
Config Timer1 = Pwm , Prescale = 1 , Pwm = 10 , Compare A Pwm = Clear Up Tccr1a = &B10000010 ‘ Phase-correct PWM, Top=ICR1 Tccr1b = &B00010001 ‘ Prescaler=1 D = 8 Icr1 = D Ocr1a = D / 2 Portc.2 = 1
‘ 1 MHz
Do D = Getadc(2) Print D Locate 1 , 1 Lcd D Lcd “ “ Waitms 500 Loop
also function as a photo diode, a voltage stabilizer,, limiter and a varicap, surely we stabilizer can get one to work as an RF detector as well. LED1 on the shield is already connected to the analog input ADC2. There is also a 1 kΩ resistor in series with the LED but that should not give a problem. The internal 30-kΩ pullup resistor can be configured to provide a bias voltage, perfect; we really don’t need anything else to build the circuit (see Figure 3). 3).
the value 410 which corresponds to a voltage at the LED of around 2 V. Connect a 10 cm length of insulated wire to C2 to act as an antenna. Attach a bare wire at B1 and hold the other end of it. Your body is now connected to the signal and becomes an antenna for the signal which can be picked up by a normal AM radio receiver. Now take the insulated wire on C2 and couple it to the RF signa l. You will see the measured value drop to below 400. It’s interesting to note that
An Integrating Detector Maybe we could do with a bit more gain? This could be achieved in principle by using a higher value of pull up resistor. Even better would be to just switch on the pull up resistor briefly and then go into a high impedance state before the measurement is made. The charge across the LED will dissipate during the measurement period. The presence of an RF signal will increase the discharge rate. You can think of the LED junction as having a small value of capacitance. Every peak of the received RF signal brings the LED briefly into conduction which has the effect of reducing the charge on its capacitor slightly. The value of this capacitor is only a few picofarads. That means you only need a very low level of RF cur rent to produce a measurable effect. To give better sensitivity you can increase the delay between turning off the pull up and making a measurement. This will however make the circuit sensitive to low frequency signals which can cause interference. For this reason it ’s better to make the measurement quickly after the pull up has been turned off using a relatively 8). short sample time (Prescaler (Prescaler = 8). The program in Listing 2 performs 2 performs averaging on the measurement samples to determine the zero level D0. By comparing the zero level with the input we can find out if an RF signal has been received. A drop of three A/D steps of the LED voltage is recognized as the threshold to indicate a signal has been received. Tests indicate 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 produced at B2. You can hook up a simple piezo loudspeaker here to make the tone audible. The signal strength is also transferred serially but not available on the LCD due to timing constraints. When an RF signal is received at the input an (almost) constant tone will be audible at the output. With this set up you can send and receive Morse characters. For this the output frequency was raised to 2 MHz to give increased range. For tests you can dab
Trusted by over 1 million members
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
finger touching the output signal so the body works as an antenna, it was possible to achieve a range of around 39 inches using an output signal of 16 V pp and a frequency of 1 MHz. So what can the circuit be used for? Without any additional circuitry you can use it to track down sources of RF interference. Many switch mode power supplies are guilty of high levels of RF noise. Energy saving lamps and conventional fluorescent lamps are also culprits when it comes to unwanted RF noise especially in the medium wave band. All of these sources can be easily detected with the integrating LED detector you have built from an Arduino. By the way, don’t overlook the other useful components on the extension shield (Figure 4). 4). There are two push buttons and a pot to play with. With a little ingenuity you could make use of these to provide sensitivity adjustment, a Morse key, call button, mute and standby… stand by…
’
Listing 2. RF receiver with sound output [1].
‘----------------------------------------------------‘------------------------------------------------------‘UNO_RX2.BAS B1 RF out, C2 RF in ‘----------------------------------‘-----------------------------------------------------------------------$regfile = “m328pdef.dat” ‘ ATmega328p $crystal = 16000000 ‘ 16 MHz $baud = 9600 $hwstack = 16 $swstack = 16 $framesize = 16 Dim D As Word Dim D0 As Word Dim N As Byte Ddrb.2 = 1 Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2 Config Lcd = 16 * 2 Cls Cursor Off Config Adc = Single , Prescaler = 8 , Reference = Avcc
‘ 5V
(150307)
Config Timer1 = Pwm , Prescale = 1 , Pwm = 10 , Compare A Pwm = Clear Up Tccr1a = &B10000010 ‘ Phase-correct PWM, Top=ICR1 Tccr1b = &B00010001 ‘ Prescaler=1
Web Link
[1] www.elektor www.elektor.com/150307 .com/150307
RF in
RFout LED1
D = 4 Icr1 = D Ocr1a = D / 2
LED2
S2
S1
k 1
k 1
10k
+5V
28 27 26 25 24 23 22 21 20 19 18 17 16 15 5 4 3 2 1 0 D F C 5 4 3 2 1 C C C C C C N E C B B B B B G R V A A
Piezo
D = 0 For N = 1 To 50 Portc.2 = 1 Waitus 100 Portc.2 = 0 D = D + Getadc(2) Next N D0 = D / 50
ATmega328p S C D E 0 1 2 3 4 C N 1 2 5 6 7 0 R D D D D D V G X X D D D B
1
2
3
4
5
6
7
8
9
10 11 12 13 14
100n 16MHz
22p 10k
Contrast
22p
Do Portc.2 = 1 Waitus 100 Portc.2 = 0 D = Getadc(2) If D < D0 Then D = D0 - D If D > 2 Then Print D
‘ 2 MHz