RC5-Tester mit ATtiny13            

von Gerd Sinning                        
Elektronik-Labor   Projekte   AVR 


 
Tester für IR Fernbedienungen sind nicht gerade neuartig aber nützlich. Das Frontend mit dem SFH506 und dem PNP-Transistor macht genau das: wenn die Led1 blinkt, dann funktioniert sie. Schwieriger wird es, wenn man eine Fernbedienung sucht die RC5-Code sendet. Die modernen Geräte verwenden einen anderen Code, aber es liegen noch ein paar alte in der Schublade. Man kann ihnen nicht ansehen was sie senden, also wird ein AT13 eingesetzt, um eine RC5 Fernbedienung zu finden. Das ist in Bascom recht einfach, mit Getrc5(address , Command) wird das Signal dekodiert. 



Wenn nun die grüne Led an PB0 ca. 2 Sekunden leuchtet, dann sendet die Fernbedienung RC5-Code, sonst nicht, dann blinkt nur Led1. Man kann das nun testen, die 0 schaltet die Led an PB2 ein, jede andere Taste wieder aus. Address und Command werden seriell übertragen, damit man sieht, was jede Taste sendet. Wenn man das Programm etwas ändert und anstelle der LEDs jeweils einen Transistor und Relais einbaut, dann hat man eine kleine Fernsteuerung, z. B. kann man den Fernseher ein und ausschalten, um standby Strom zu sparen.

Download: 13IRtest.zip

' attiny13 remote control test
'
' find RC5 remote control
'
' PB0 output if RC5
' PB1 output if TV
' PB2 output switched
' PB4 output Com1
' PB3 input RC5
'
' GS 2014/4
'
'***************************************************************************
' This program is free software; you can redistribute it and/or
' modify it under the terms of the GNU General Public License.
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY;
'***************************************************************************
'
' ATtiny45 dip
' (PCINT5/RESET/ADC0/dW) PB5 VCC
' (PCINT3/XTAL1/CLKI/OC1B/ADC3) PB3 PB2 (SCK/USCK/SCL/ADC1/T0/INT0/PCINT2)
' (PCINT4/XTAL2/CLKO/OC1B/ADC2) PB4 PB1 (MISO/DO/AIN1/OC0B/OC1A/PCINT1)
' GND PB0 (MOSI/DI/SDA/AIN0/OC0A/OC1A/AREF/PCINT0)
'
'***************************************************************************
'use byte library for smaller code
'$lib "mcsbyte.lbx"

$regfile = "attiny13.dat"
$crystal = 1200000
'$crystal = 8000000
$hwstack = 8
$swstack = 8
$framesize = 4


Led0 Alias Portb.0 'output if RC5
Led1 Alias Portb.1 'output if TV
Led2 Alias Portb.2 'output switched

Dim Address As Byte , Command As Byte , Tog As Byte
Dim Cnt As Byte

Portb = &B00001000
Ddrb = &B00010111

'CLKPR = &B10000000 'Clock Prescaler Change Enable
'CLKPR = &B00000000 'Clock Division Factor=0, 8 MHz

Config Rc5 = Pinb.3

Acsr.acd = 0 ' switch off analog comparator

Open "comb.4:9600,8,n,1,INVERTED" For Output As #1

Print #1 , "Wait for RC5"
Enable Interrupts

Do
Getrc5(address , Command)
If Address < 255 Then
Tog = Command And &B10000000
Command = Command And &B01111111 'clear the toggle bit

Led0 = 1 'RC5
If Address = 0 Then 'TV '
Led1 = 1
End If
If Command = 0 Then 'switch on if 0 '
Led2 = 1
Else
Led2 = 0
End If
Disable Interrupts 'debug print
Print #1 , " Adr:" ; Address ; " Cmd:" ; Command
Enable Interrupts
End If 'If Address < 255
Incr Cnt
If Cnt = 20 Then
Led0 = 0
Led1 = 0
Cnt = 0
End If
Loop
End



 Elektronik-Labor   Projekte   AVR