Integrating RF LED Detector with ATtiny13           

Elektronik-Labor  Projekte  AVR  Sparrow          



Video: https://youtu.be/i6FLdRkIDl0

German/Deutsch

Using a given microcontroller system my question was: How can I make the simplest possible RF receiver. I am using the ATtiny13 on the Sparrow board. LED2 is connected to port B.3 which is ADC(3) as well. So why not connect an Antenna here. The LED should work as a detector diode.  A bias voltage is needed. So I should switch on the internal pullup.


 
Now it works fine! Don’t believe it? Watch the video. To get it sensitive enough I had to use one more trick. I switch on the pullup for a very short time. This will charge the LED which is also a little capacitor of only a few picofarads. Voltage may rise up to 2 V. Then I switch back to high Z. The LED is discharged down to about 1.5 V after some microseconds. But in the presence of an RF signal is will discharge a little lower. Several RF pulses may result in an integrated loss of LED voltage. That’s why I call it an integrating RF detector. In the end I need something like 50 mV at 100 kHz the get a clear result.

I used an integration time of 10 Ás. At the beginning I collect a reference value Ref to know the LED voltage without signal. This is used later to detect the voltage loss caused by an RF signal.

Download: Sparrow_RX.zip
Direct download: http://tiny.systems/categorie/cheepit/RFDetector.html
'ATtiny13 RF receiver
$regfile = "attiny13.dat"
$crystal = 1200000
$hwstack = 8
$swstack = 4
$framesize = 4

Config Portb = &B000000010
Dim T As Byte
Dim N As Byte
Dim D As Word
Dim Ref As Word
Dim Diff As Word

Config Adc = Single , Prescaler = Auto
Config Timer0 = Pwm , Prescale = 8 , Compare B Pwm = Clear Up

D = 0
For N = 1 To 20
Portb.3 = 1
Portb.3 = 0
Waitus 10 'integration time
D = D + Getadc(3) 'LED2 voltage
Next N
Ref = D / 20
Do
Portb.3 = 1
Portb.3 = 0
Waitus 10 'integration time
D = Getadc(3) 'LED2 voltage
If D >= Ref Then
Pwm0b = 0
Else
Diff = Ref - D
If Diff > 2 Then
Pwm0b = 128 'sound and LED1
Waitms 50
End If
End If
Loop
End



Elektronik-Labor  Projekte  AVR  Sparrow