Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RC5 Code Help (Anybody Have?)

Status
Not open for further replies.

Suraj143

Active Member
Hi I searched in piclist & in google but I couldn’t find any rc5 routine.

Sony of course ok it has same pulse gap after each bit (600mS). But when it comes to RC5 (bi phase) it’s hard for me to write a code because it doesn’t have the same pulse gap.

The below RC5 code written same as Sony (SIRC) thinking it has same pulse gap. But it doesn’t work for Philips remotes.

Does anybody have RC5 code to share for PIC 16F series using assembly?

Many thanks

Code:
;======================================
; READ RC5 Format
; OUTPUT : TOGGLE.7 = TOGGLE BIT
;	       ADDR = ADDRESS 5 BIT 
;	        CDM = COMMAND 6 BIT
;	          C = 0 READ OK
;		    = 1 READ ERROR
;======================================
GET_RC5:BTFSC	IR
	GOTO	GET_RC5		; WAIT IR LOW
	CLRF	TMR0		; clear timer 0
	NOP
	BCF	INTCON,T0IF	; CLR timer 0 flag
	NOP
	;
	BTFSC	INTCON,T0IF     
	GOTO	ERR1		
	;
	BTFSS	IR
	GOTO	$-3
	;	
	MOVF	TMR0,W		
	;MOVLW	0xC8		; FOR TEST
	MOVWF	TEMP
	MOVLW	0XFF		; 1020 mS = 255*4
	SUBWF	TEMP,W
	BTFSC	STATUS,C
	GOTO	ERR1		; ERROR IF Time > 1020 uS
	MOVLW	0XC8		; 800 mS
	SUBWF	TEMP,W
	BTFSS	STATUS,C
	GOTO	ERR1		; ERROR IF Time < 800 uS  (C8h * TM0 Prescaler = 800 uS )
	;
	BTFSC	IR  		; Time validate 800uS-1020uS
	GOTO	$-1		; WAIT TO LOW (Syn BIT)
	CALL	DELAY1252	; DELAY 3/4 BIT LENGHT=1252 uS
	;
	BTFSS	IR
	BCF	TOGGLE,7	
	BTFSC	IR
	BSF	TOGGLE,7	
	;		
	BTFSS	IR
	GOTO	$+4
	BTFSC	IR
	GOTO	$-1
	GOTO	READ	
	;
	BTFSS	IR
	GOTO	$-1

;====== READ ADDRESS 5 BIT ===========
; READ MSB FIRST
;	
READ:	[COLOR="Red"]MOVLW	5
	MOVWF	TEMP	; LOOP COUNTER
	CLRF	ADDR[/COLOR]
	;	
READ1:	CALL	DELAY1252
	BTFSS	IR
	BCF	STATUS,C
	BTFSC	IR
	BSF	STATUS,C
	RLF	ADDR,F	; SHIFT LEFT ADDRESS
	;
	BTFSS	IR
	GOTO	$+4
	BTFSC	IR	; WAIT LOW
	GOTO	$-1
	GOTO	$+3
	;
	BTFSS	IR
	GOTO	$-1
	;
	DECFSZ	TEMP,F
	GOTO	READ1
	;
;====== READ COMMAND 6 BIT ===========	
; READ MSB FIRST
;
	[COLOR="Red"]MOVLW	6
	MOVWF	TEMP	; LOOP COUNTER
	CLRF	CMD[/COLOR]
	;	
CMD1:	CALL	DELAY1252
	BTFSS	IR
	BCF	STATUS,C
	BTFSC	IR
	BSF	STATUS,C
	RLF	CMD,F	; SHIFT LEFT COMMAND
	;
	BTFSS	IR
	GOTO	$+4
	BTFSC	IR
	GOTO	$-1
	GOTO	$+3
	;
	BTFSS	IR
	GOTO	$-1
	;
	DECFSZ	TEMP,F
	GOTO	CMD1
	;	
	MOVLW	0X3F	; 0011 1111
	ANDWF	CMD,F
	MOVLW	0X1F	; 0001 1111
	ANDWF	ADDR,F
	BCF	STATUS,C	; C=0 NO ERROR
	RETURN
	;
ERR1:	BSF	STATUS,C	; C=1 HAVE ERROR	
	RETURN
 
Hi blueroomelectronics it doesn't have any assembler code.

Capturing from a General I/O pin will be handy.Other than taking CCP modules.

Thanks
 
Hi blueroomelectronics the first post in my was based on that sixca site it doesn't work with TV remotes.Its working with their transmitter.
 
Thanks blueroomelectronics for your links.I had some of them & got some ideas :)

I'm still struggling to find a RC5 assembler code.If any other members have please direct to me.

Thanks
 
Nigel,i really want the idea of manchester coding and decoding in C not in assembly cause i didnt understand the code from your tutorial ..
 
Hi everybody thanks for the support.I read all of the links & manage to write a code.Now I need to check with a TV remote.

The problem is in many websites they tells "RC5 is more popular among hobbyists".Does it means they all playing with Phillips remotes?

But in the market there aren't very much available Phillips remotes but sony has a lot.

In the market I cannot identify is it a Phillips or some other is there any RC5 supporting remote list?
 
Suraj143 said:
Hi everybody thanks for the support.I read all of the links & manage to write a code.Now I need to check with a TV remote.

The problem is in many websites they tells "RC5 is more popular among hobbyists".Does it means they all playing with Phillips remotes?

But in the market there aren't very much available Phillips remotes but sony has a lot.

Sony SIRC is far easier to receive than RC5, which is why it's popular with hobbiests.

The advantage of RC5 is that it's used in more remotes than any other type of coding, as Philips supply components to many other manufacturers.
 
The RC5 protocol is pretty easy to decode. Use the input capture function to measure either 1) the time from edge to edge or 2) the time from falling edge to falling edge. Either one of those will let you decode the protocol. That is exactly what the ps3toothfairy (shameless plug) device does. Then you take the measurements and convert them to 1 or 0 based on the pulse width. Your exact measurement from the ICP will depend on which of the above methods you use.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top