Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

edaboard IR Decoding Tutorial

Status
Not open for further replies.

d@nny

Full Member level 5
Full Member level 5
Joined
May 28, 2011
Messages
246
Helped
11
Reputation
22
Reaction score
11
Trophy points
1,298
Activity points
3,238
here is picture of my LG remote with keys press 0 , 1 , to , 9 .
0.jpg8.jpg7.jpg6.jpg5.jpg4.jpg3.jpg2.jpg1.jpg9.jpg

How should i scan this keys into the PIC16F76?????/
i am using the following time delays in interrupt routine and watching them on cd4094 shift register with the help of PORTC. But it is not correct at all and i cant find a way to scan them so no two keys present me the same code as currently this programme doing?



d1 equ 21h
d2 equ 22h
d3 equ 23h
r1 equ 24h

org 0x00
goto main
org 0x04
goto INTR

main:

banksel ANSEL
movlw B'00000000'
movwf ANSEL

banksel PORTA
clrf PORTA
banksel TRISA
movlw b'00000100'
movwf TRISA

banksel PORTC
clrf PORTC
banksel TRISC
clrf TRISC

banksel INTCON
bcf OPTION_REG , INTEDG
bsf INTCON , INTE
bcf INTCON , INTF
bsf INTCON , GIE

FIN:

goto FIN


INTR:
banksel PORTC
clrf PORTC
clrf r1
call De175ms ;1.75ms
call De28ms ; 2.8ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call De28ms
call scan
call de500ms
call serout
bsf PORTC , 5
bsf PORTC , 5


banksel INTCON

bcf INTCON , INTF
nop
nop
nop
nop
nop
retfie




scan:
btfsc PORTA , 2
goto one
goto zero
zero:
bcf STATUS , 0
rlf r1 , 1
one:
bsf STATUS , 0
rlf r1 , 1
return


de500ms:

movlw 0x03
movwf d1
movlw 0x18
movwf d2
movlw 0x02
movwf d3
De500_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto De500_0

;6 cycles
goto $+1
goto $+1
goto $+1
return

De28ms:

movlw 0xF3
movwf d1
movlw 0x02
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0

;2 cycles
goto $+1
return

De175ms:

movlw 0x5D
movwf d1
movlw 0x02
movwf d2
Delay_01
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_01

;2 cycles
goto $+1
return

serout:

movlw 0x08
movwf d3
testbit:
bcf PORTC , 4
btfsc r1 , 7
bsf PORTC , 4
bsf PORTC , 3
bcf PORTC , 3
rlf r1 , f
decfsz d1 , f
goto testbit
return


end
 

My remote output 0 to 9 keys
**broken link removed**

I have 35 keys on my remote control . I have decode them with following code. But only 15 keys out of 35 have output same code in pairs 2 * 6 = 12 keys and a pair of 3keys total 15 keys
Do i need some fine tune in the timing?

processor PIC16F676
#include <p16f676.inc>

d1 equ 21h
d2 equ 22h
d3 equ 23h
r1 equ 24h

org 0x00
goto main
org 0x04
goto INTR

main:

banksel ANSEL
movlw B'00000000'
movwf ANSEL

banksel PORTA
clrf PORTA
banksel TRISA
movlw b'00000100'
movwf TRISA

banksel PORTC
clrf PORTC
banksel TRISC
clrf TRISC

banksel INTCON
bcf OPTION_REG , INTEDG
bsf INTCON , INTE
bcf INTCON , INTF
bsf INTCON , GIE

FIN:

goto FIN


INTR:
banksel PORTC
clrf PORTC
clrf r1
call left
call scan
call count
call scan
call count
call scan
call count
call scan
call count
call scan
call count
call scan
call count
call scan
call count
call scan
call serout
bsf PORTC , 5
bcf PORTC , 5
call de500ms

banksel INTCON

bcf INTCON , INTF
nop
nop
nop
nop
nop
retfie




scan:
btfsc PORTA , 2
goto one
goto zero
zero:
bcf STATUS , 0
rrf r1 , 1
one:
bsf STATUS , 0
rrf r1 , 1
return


de500ms:

movlw 0x03
movwf d1
movlw 0x18
movwf d2
movlw 0x02
movwf d3
De500_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto De500_0

;6 cycles
goto $+1
goto $+1
goto $+1
return

count: ;0.001645 seconds

movlw 0x48
movwf d1
movlw 0x02
movwf d2
count_0
decfsz d1, f
goto $+2
decfsz d2, f
goto count_0

;2 cycles
goto $+1
return

left: ;0.00965 seconds

movlw 0x89
movwf d1
movlw 0x08
movwf d2
left_0
decfsz d1, f
goto $+2
decfsz d2, f
goto left_0

;2 cycles
goto $+1
return

serout:

movlw 0x08
movwf d3
testbit:
bcf PORTC , 4
btfsc r1 , 7
bsf PORTC , 4
bsf PORTC , 3
bcf PORTC , 3
rlf r1 , f
decfsz d1 , f
goto testbit
return


end
 

After all i have decode my remote successfully after making 3 changes in above code as the code is wrong in 2 places 1 is return missing and second in serout timimg . :razz:
no key matching with other.
every thing is ok
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top