Wednesday, 24 July 2019
     
 
Main Menu
Home Home
Shop Shop
News News
BASCOM-AVR BASCOM-AVR
BASCOM-8051 BASCOM-8051
Products Products
Application Notes Application Notes
Publications Publications
Links Links
Support Center Support Center
Downloads Downloads
Forum Forum
Resellers Resellers
Contact Us Contact Us
Updates Updates
MCS Wiki MCS Wiki
Online Help
BASCOM-AVR Help BASCOM-AVR Help
BASCOM-8051 Help BASCOM-8051 Help
Contents in Cart
Show Cart
Your Cart is currently empty.
Search the Shop

Products Search

User Login
Username

Password

If you have problem after log in with disappeared login data, please press F5 in your browser

RSS News
 
     
 

 
   
     
 
AN #20 - How to decode SONY IR remote control signals Print
How to decode SONY IR remote control signals

The sample source code of this application note shows that you don't have to use ASM.

Kantor Zoltan who wrote this program shows you how to do the job with just BASCOM-BASIC.

Just connect a SFH506-36 to the INT0 of the 8051 compatible chip.

Download source code in .BAS file

Here is the code:

 

' (c)1999, By Kantor Zoltan
'foprogi
'*******************************************************************************************
'compiler opciok
'*******************************************************************************************

$baud = 19200 'baudrate
$crystal = 11059200 'frequency
$romstart = &H8200 'rom starting address
$ramsize = &H0200 'size of RAM
$ramstart = &H3000
$large
$iramstart = &H30
$map

'Hardware
'int0 IR sensor
'if there is an infra signal then the pin is 1

'number of received bit: 12+1 start
'device code:5 bit
'button code:7 bit

'if you have question please let me know:
'mailto:kantor@mail.matav.hu
'mailto:kantor@freemail.c3.hu
'mailto:kantor@tar.hu

'*******************************************************************************************
'konfig
'*******************************************************************************************

Config Timer0 = Timer , Gate = Internal , Mode = 2
'Timer0 = timer : timer0 operates as a timer
'Gate = Internal : no external gate control
'Mode = 2 : 8-bit reload

Th0
= 0
Set Tcon.0 'edge trig
Set Tcon.2

On Timer0 Timer_0_int
On Int0 Int0_int

Enable Interrupts 'enable the use of interrupts
Enable Timer0
Enable Int0

Start Timer0 'start the timer

'*******************************************************************************************
'valtozo definiciok
'*******************************************************************************************
Triac
Alias P1.0
Led
Alias P3.3

Dim New_ir_command As Bit
Dim Infra_count As Byte
Dim Infra_count_old As Byte
Dim Infra_command As Word
Dim Segb1 As Byte

Dim Segbit1 As Bit
Dim N As Byte
Dim Segw1 As Word
Dim Segb2 As Byte

New_ir_command
= 0

Ide
:
If New_ir_command = 0 Then Goto Ide
Infra_count_old
= 0

Segw1
= Infra_command
Print N ; " Number of received bit "
Print "Received command ";
Printhex Segw1

Shift Segw1 , Right , 2
Segb2
= High(segw1)
Print "Device " ; Segb2
Segb2
= Low(segw1) / 2
Print "Button " ; Segb2
Print

Goto Ide

'*******************************************************************************************
'* int rutinok
'*******************************************************************************************

'****************************************
'* timer0 rutin
'****************************************
Rem The Interrupt Handler For The Timer0 Interrupt
Rem .27.. ms each irq
Timer_0_int
:
If Infra_count < 150 Then
 
Incr Infra_count
 New_ir_command
= 0
 
Else
 New_ir_command
= 0
 
If Infra_count_old <> 0 Then
 New_ir_command
= 1
 
End If
 
End If

Timer_0_int_end
:
Return

'****************************************
'* int0 rutin
'****************************************
Rem The Interrupt Handler For The INT0 Interrupt
Rem infra falling edge trigger the irq
Int0_int
:
If Infra_count = 150 Then
 Infra_count
= 0 'start receive (Infra_count=0)
 New_ir_command
= 0
 Infra_count_old
= 0
 Infra_command
= 0
 N
= 0
 
End If

Segb1
= Infra_count - Infra_count_old
If Segb1 > 5 Then Set Infra_command.15 Else Reset Infra_command.15
Infra_count_old
= Infra_count

Shift Infra_command , Right

Incr N

Int0_int_end
:
Return