Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 9th May 2008, 03:01 AM   #1 (permalink)
Experienced Member
 
Join Date: Jan 2007
Location: South Mald Isld
Posts: 533
Suraj143 is on a distinguished road
Question RC5 Code Help (Anybody Have?)

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:	MOVLW	5
	MOVWF	TEMP	; LOOP COUNTER
	CLRF	ADDR
	;	
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
;
	MOVLW	6
	MOVWF	TEMP	; LOOP COUNTER
	CLRF	CMD
	;	
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
Suraj143 is offline   Reply With Quote
Old 9th May 2008, 03:33 AM   #2 (permalink)
Experienced Member
 
 
Join Date: Jan 2007
Location: Toronto, Canada
Posts: 4,123
Blog Entries: 1
blueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to behold
Send a message via Skype™ to blueroomelectronics
Default

http://home.tu-clausthal.de/~dpor/rc5dekoder_eng.html
http://home1.stofanet.dk/hvaba/fprc5rx/index.html
http://www.sixca.com/eng/articles/remote/index.html

One suggestion is to use the CCP Capture mode. Should simplify the software.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com

Last edited by blueroomelectronics; 9th May 2008 at 03:48 AM.
blueroomelectronics is online now   Reply With Quote
Old 9th May 2008, 03:47 AM   #3 (permalink)
Experienced Member
 
Join Date: Jan 2007
Location: South Mald Isld
Posts: 533
Suraj143 is on a distinguished road
Default

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
Suraj143 is offline   Reply With Quote
Old 9th May 2008, 03:49 AM   #4 (permalink)
Experienced Member
 
 
Join Date: Jan 2007
Location: Toronto, Canada
Posts: 4,123
Blog Entries: 1
blueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to behold
Send a message via Skype™ to blueroomelectronics
Default

I just added sixca
http://www.sixca.com/eng/articles/remote/index.html
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now   Reply With Quote
Old 9th May 2008, 03:56 AM   #5 (permalink)
Experienced Member
 
Join Date: Jan 2007
Location: South Mald Isld
Posts: 533
Suraj143 is on a distinguished road
Default

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.
Suraj143 is offline   Reply With Quote
Old 9th May 2008, 03:59 AM   #6 (permalink)
Experienced Member
 
 
Join Date: Jan 2007
Location: Toronto, Canada
Posts: 4,123
Blog Entries: 1
blueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to behold
Send a message via Skype™ to blueroomelectronics
Default

No code but very good information on IR protocols.
http://www.sbprojects.com/knowledge/ir/ir.htm
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now   Reply With Quote
Old 9th May 2008, 04:38 AM   #7 (permalink)
Experienced Member
 
Join Date: Jan 2007
Location: South Mald Isld
Posts: 533
Suraj143 is on a distinguished road
Default

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
Suraj143 is offline   Reply With Quote
Old 9th May 2008, 07:39 AM   #8 (permalink)
Experienced Member
 
 
Join Date: Jan 2005
Location: UK
Posts: 1,966
eblc1388 is just really niceeblc1388 is just really niceeblc1388 is just really nice
Default

Check this out:

RC-5 Decoder
__________________
L.Chung
eblc1388 is offline   Reply With Quote
Old 9th May 2008, 10:00 AM   #9 (permalink)
Super Moderator
 
 
Join Date: Nov 2003
Location: Derbyshire, UK
Posts: 22,786
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

If you check my Manchester radio routines, RC5 is Manchester coding, and there's a link to the site I modified it from where they do IR as well.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 10th May 2008, 01:33 AM   #10 (permalink)
Experienced Member
 
Join Date: Apr 2006
Posts: 203
ahmedragia21 is an unknown quantity at this point
Default

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 ..
ahmedragia21 is offline   Reply With Quote
Old 11th May 2008, 10:30 PM   #11 (permalink)
New Member
 
 
Join Date: Jan 2008
Location: Toronto Canada
Posts: 29
ex-navy is on a distinguished road
Default Microchip AN1064 - RC5 example application

Take a look here:

http://www.ustr.net/infrared/infrared1.shtml

This may help you also:

http://focus.ti.com/lit/an/slaa134/slaa134.pdf
__________________
We learn by example and by direct experience because there are real limits to the adequacy of verbal instruction. Malcolm Gladwell

www.olson-engineering.com

Last edited by ex-navy; 11th May 2008 at 10:40 PM.
ex-navy is offline   Reply With Quote
Old 12th May 2008, 03:27 AM   #12 (permalink)
Experienced Member
 
Join Date: Jan 2007
Location: South Mald Isld
Posts: 533
Suraj143 is on a distinguished road
Default

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 is offline   Reply With Quote
Old 12th May 2008, 04:30 AM   #13 (permalink)
Experienced Member
 
 
Join Date: Jan 2007
Location: Toronto, Canada
Posts: 4,123
Blog Entries: 1
blueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to behold
Send a message via Skype™ to blueroomelectronics
Default

Universial remotes are very cheap. All appear to support SIRC & RC5 as they are common.

More RC5 stuff
http://www.picbasic.nl/frameload_uk....sceiver_uk.htm
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now   Reply With Quote
Old 12th May 2008, 08:18 AM   #14 (permalink)
Super Moderator
 
 
Join Date: Nov 2003
Location: Derbyshire, UK
Posts: 22,786
Nigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to beholdNigel Goodwin is a splendid one to behold
Default

Quote:
Originally Posted by Suraj143
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 14th May 2008, 03:05 PM   #15 (permalink)
Experienced Member
 
 
Join Date: Jan 2007
Location: Toronto, Canada
Posts: 4,123
Blog Entries: 1
blueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to beholdblueroomelectronics is a splendid one to behold
Send a message via Skype™ to blueroomelectronics
Default

This Microchip app note has RC5 code.
Attached Files
File Type: pdf 01064A.pdf (228.1 KB, 5 views)
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Latest
MP Lab Program Help bamafan54 Micro Controllers 3 19th October 2007 02:53 AM
Accessing EEPROM Clayton Micro Controllers 15 23rd March 2007 03:00 AM
Need some help with a code provided by ATMEL ikalogic Micro Controllers 1 23rd January 2007 02:46 PM
Tough assembly program for the PIC16F84 asmpic Micro Controllers 34 3rd December 2004 06:50 PM
An error in pic16f84a, why? Zener_Diode Micro Controllers 6 11th April 2004 02:55 AM


All times are GMT. The time now is 05:09 PM.


Electronic Circuits  |  Radio Controlled
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0 (Unregistered)