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.

Record Signal (IR from pin)

Status
Not open for further replies.
Here is my RC-5 Code. It will send all info correctly except for that toggle bit aka control bit. It will always send one cuz i havent coded that in yet lol but this will send the data correctly since i tested it in the logic analyzer. i thought id put the beta online for all to see. The delays are modded to fit with the cycles used before the calling of them. meaning a 7uS delay is not actually 7uS its less since it takes time to get called.

Code:
;******************************************************************************
;                                                                             *
;    Filename: RC-5 Remote                                                    *
;    Date: Sunday, May 03, 2009                  	                          *
;    File Version: 001                                                        *
;                                                                             *
;    Author:   Jason Lopez                                                    *
;    Company:  AtomSoft                                                       *
;                                                                             * 
;******************************************************************************
;                                                                             *
;    Files Required: P18F2525.INC                                             *
;                                                                             *
;******************************************************************************

	LIST P=18F2525	;directive to define processor
	#include <P18F2525.INC>	;processor specific variable definitions


    CONFIG	OSC = INTIO67, WDT = OFF, LVP = OFF, XINST = OFF
	

#DEFINE irL LATB
#DEFINE irT TRISB
#DEFINE ir 0

		CBLOCK	0x000
		EXAMPLE		;example of a variable in access RAM
		d1
		d2
		d3
		tmp1
		dev
		cmd
		ENDC

		ORG	0x0000
Init:
	movlw	0x72
	movwf	OSCCON
	movlw	0x0F
	movwf	ADCON1
	bcf		irT,ir
RemoteData:
	movlw	0x03
	movwf	dev

	movlw	0x11
	movwf	cmd
Main:
	bsf 	irL,ir
	call 	SendData
Loop4Ever:
	NOP
	goto	Loop4Ever

;*****************************************
;* Send IR Data                          *
;* ------------------------------------- *
;* Dev = Address of device               *
;* Cmd = Command                         *
;*****************************************
SendData
	call	One
	call	One
	call	One

	movlw 	0x10
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x08
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x04
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x02
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x01
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x20
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x10
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x08
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x04
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x02
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x01
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	call 	Delay890uS 
	return
;***************************************
;Send a Logic 1
;***************************************
One:
	bcf		irL, ir
	call	Delay890uS
	movlw	d'32'
	movwf	tmp1
loop1:
	decfsz	tmp1, f
	goto	$+6
	return
	bsf		irL, ir
	call	Delay7uS
	bcf		irL, ir
	call	Delay21uS
	goto	loop1
;***************************************
;Send a Logic 0
;***************************************
Zero:
	movlw	d'32'
	movwf	tmp1
loop2:
	bsf		irL, ir
	decfsz	tmp1, f
	goto	$+6
	goto	Zero1
	call	Delay7uSZ
	bcf		irL, ir
	call	Delay21uS
	goto	$+4
	NOP
	goto	loop2
Zero1:
	bcf		irL, ir
	call	Delay890uS
	return

;***************************************
;6.95uS 14 Cycles (7 uS) @ 8 Mhz
;***************************************
Delay7uS
	goto	$+4
	goto	$+4
	goto	$+4
	goto	$+4
	NOP
	return
Delay7uSZ
	goto	$+4
	goto	$+4
	NOP
	return
;***************************************
;20.85uS 42 Cycles (21 uS) @ 8 Mhz
;***************************************
Delay21uS 
	movlw	0x09
	movwf	d1
Delay21uS_0
	decfsz	d1, f
	goto	Delay21uS_0
	goto	$+4
	return
;***************************************
;1780 Cycles (890 uS) @ 8 Mhz
;***************************************
Delay890uS 
	movlw	0x60 ;2
	movwf	d1
	movlw	0x02
	movwf	d2
Delay890uS_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	Delay890uS_0
	goto	$+4
	nop
	return

		END
 
Last edited:
The image is the IR DATA from my remote. Can anyone determine what kind is it.

The below code is my RC-5 Remote code. Not useful to me anymore since i know mines isnt RC-5 lol but it might be usefull to others.

Code:
;******************************************************************************
;                                                                             *
;    Filename: RC-5 Remote                                                    *
;    Date: Sunday, May 03, 2009                  	                          *
;    File Version: 001                                                        *
;                                                                             *
;    Author:   Jason Lopez                                                    *
;    Company:  AtomSoft                                                       *
;                                                                             * 
;******************************************************************************
;                                                                             *
;    Files Required: P18F2525.INC                                             *
;                                                                             *
;******************************************************************************

	LIST P=18F2525	;directive to define processor
	#include <P18F2525.INC>	;processor specific variable definitions


    CONFIG	OSC = INTIO67, WDT = OFF, LVP = OFF, XINST = OFF
	

#DEFINE irL LATB
#DEFINE irT TRISB
#DEFINE ir 0

#define btnT TRISC
#define btn  PORTC
#define btnUp 0
#define btnDwn 1


		CBLOCK	0x000
		EXAMPLE		;example of a variable in access RAM
		d1
		d2
		d3
		tmp1
		dev
		cmd
		ENDC

		ORG	0x0000
Init:
	movlw	0x72
	movwf	OSCCON
	movlw	0x0F
	movwf	ADCON1
	bcf		irT,ir
	bsf		btnT,btnUp
	bsf		btnT,btnDwn
Main:
	bsf 	irL,ir
	btfss	btn,btnUp
	goto	UpBtn
	btfss	btn,btnDwn
	goto	DwnBtn
	goto 	Main
UpBtn:
	movlw	0x03
	movwf	dev
	movlw	0x11
	movwf	cmd
	goto 	SendIt
DwnBtn:
	movlw	0x00
	movwf	dev
	movlw	0x11
	movwf	cmd
	goto 	SendIt
SendIt:
	call 	SendData
	goto	Main

;*****************************************
;* Send IR Data                          *
;* ------------------------------------- *
;* Dev = Address of device               *
;* Cmd = Command                         *
;*****************************************
SendData
	call	One
	call	One
	call	One

	movlw 	0x10
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x08
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x04
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x02
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x01
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x20
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x10
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x08
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x04
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x02
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x01
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	call 	Delay890uS 
	call 	Delay120mS
	return
;***************************************
;Send a Logic 1
;***************************************
One:
	bcf		irL, ir
	call	Delay890uS
	movlw	d'32'
	movwf	tmp1
loop1:
	decfsz	tmp1, f
	goto	$+6
	return
	bsf		irL, ir
	call	Delay7uS
	bcf		irL, ir
	call	Delay21uS
	goto	loop1
;***************************************
;Send a Logic 0
;***************************************
Zero:
	movlw	d'32'
	movwf	tmp1
loop2:
	bsf		irL, ir
	decfsz	tmp1, f
	goto	$+6
	goto	Zero1
	call	Delay7uSZ
	bcf		irL, ir
	call	Delay21uS
	goto	$+4
	NOP
	goto	loop2
Zero1:
	bcf		irL, ir
	call	Delay890uS
	return

;***************************************
;6.95uS 14 Cycles (7 uS) @ 8 Mhz
;***************************************
Delay7uS
	goto	$+4
	goto	$+4
	goto	$+4
	goto	$+4
	NOP
	return
Delay7uSZ
	goto	$+4
	goto	$+4
	NOP
	return
;***************************************
;20.85uS 42 Cycles (21 uS) @ 8 Mhz
;***************************************
Delay21uS 
	movlw	0x09
	movwf	d1
Delay21uS_0
	decfsz	d1, f
	goto	Delay21uS_0
	goto	$+4
	return
;***************************************
;1780 Cycles (890 uS) @ 8 Mhz
;***************************************
Delay890uS 
	movlw	0x60 ;2
	movwf	d1
	movlw	0x02
	movwf	d2
Delay890uS_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	Delay890uS_0
	goto	$+4
	nop
	return
;***************************************
;120mS () @ 8 Mhz
;***************************************
Delay120mS
	movlw	0x7E
	movwf	d1
	movlw	0xBC
	movwf	d2
Delay120mS_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	Delay120mS_0
	goto	$+4
	nop
	return



		END
 

Attachments

  • ircode.jpg
    ircode.jpg
    47.8 KB · Views: 111
Last edited:
NEC IR Code Format Looks like what you have I guess your not worried about
What sends your Modulated Carrier
your just catching the code look here **broken link removed**
 
Last edited:
i dont know if its NEC. I tried to check it against it and if i do it by hand:

vol up sends: 8, 1, 1, 18
vol down sends: 8, 1, 1, 9

No inversion there. Its funny lol
 
not enough info there. I always go there :D I need to know the length of the individual pulses.

For RC-5 its 27.8uS for 1 pulse. Where 6.95uS the pulse is high and 20.85uS the pulse is low.
 
Not sure if its me but some how that doesnt seem correct.

SB-Projects has never been wrong for me and they state:
The protocol uses bi-phase modulation (or so-called Manchester coding) of a 36kHz IR carrier frequency.

on the other page it says 38.4khz
 
I have seen it from 36 to 40 and higher i don't think the carrier frequency is that important. The carrier frequency only matters to your Ir module they look at any thing out of there frequency as noise. That why Ir modules are no good if you don't send them modulated Ir
 
This is the only real thing different
Data is modulated using Manchester coding. This means that each bit (or symbol) will have both a mark and space in the output signal. If the symbol is a "1" the first half of the bit time is a mark and the second half is a space. If the symbol is a "0" the first half of the bit time is a space and the second half is a mark.
Please note that this is the opposite of the RC-5 protocol!
Where you get the program you used the volup
 
its freeware audio application called:

Audacity

i connected the IR part to gnd and 5+ and the signal to the right channel of headset and Gnd
 
since RC-5 and RC-6 are so similar. Can i use the same: 27.8uS pulse?

RC6 is just an extended version of RC5, both use exactly the same Manchester coding - essentially RC6 gives more scope for expansion, more device codes, and more command codes.

As suggested, the actual modulation frequency makes little difference, as does the precise pulse width - the whole point of Manchester coding is that the pulse width isn't important, it's the change from high to low, and low to high, that carries the data, and not the pulse width.
 
heh here is the code i have so far. Untested not sure if it works at all lol but it makes a nice form on the Logic Analyzer in MPLAB:
Code:
;******************************************************************************
;                                                                             *
;    Filename: RC-6 Remote                                                    *
;    Date: Sunday, May 03, 2009                  	                          *
;    File Version: 001                                                        *
;                                                                             *
;    Author:   Jason Lopez                                                    *
;    Company:  AtomSoft                                                       *
;                                                                             * 
;******************************************************************************
;                                                                             *
;    Files Required: P18F2525.INC                                             *
;                                                                             *
;******************************************************************************

	LIST P=18F2525	;directive to define processor
	#include <P18F2525.INC>	;processor specific variable definitions


    CONFIG	OSC = INTIO67, WDT = OFF, LVP = OFF, XINST = OFF
	

#DEFINE irL LATB
#DEFINE irT TRISB
#DEFINE ir 0

#define btnT TRISC
#define btn  PORTC
#define btnUp 0
#define btnDwn 1


		CBLOCK	0x000
		EXAMPLE		;example of a variable in access RAM
		d1
		d2
		d3
		tmp1
		dev
		cmd
		ENDC

		ORG	0x0000
Init:
	movlw	0x72
	movwf	OSCCON
	movlw	0x0F
	movwf	ADCON1
	bcf		irT,ir
	bsf		btnT,btnUp
	bsf		btnT,btnDwn
Main:
	bsf 	irL,ir
	btfss	btn,btnUp
	goto	UpBtn
	btfss	btn,btnDwn
	goto	DwnBtn
	goto 	Main
UpBtn:
	movlw	0x01
	movwf	dev
	movlw	0x08
	movwf	cmd
	goto 	SendIt
DwnBtn:
	movlw	0x01
	movwf	dev
	movlw	0x12
	movwf	cmd
	goto 	SendIt
SendIt:
	call 	SendData
	goto	Main

;*****************************************
;* Send IR Data                          *
;* ------------------------------------- *
;* Dev = Address of device               *
;* Cmd = Command                         *
;*****************************************
SendData
	call	Header

;*********** DEV *******************
	movlw 	0x80
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x40
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x20
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x10
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x08
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x04
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x02
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x01
	ANDWF	dev, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero
;*********** CMD *******************
	movlw 	0x80
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x40
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x20
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x10
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x08
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x04
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x02
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero

	movlw 	0x01
	ANDWF	cmd, 0
	btfss	STATUS, Z
	call	One
	btfsc	STATUS, Z
	call	Zero
;*********** Signal Free *******************
	call 	Delay2_66mS

	return
;***************************************
;Send a Header
;***************************************
Header:
	call	Leader
	call	One
	call	Zero
	call	Zero
	call	Zero
	call	trOne
	return
;***************************************
;Send a Leader
;***************************************
Leader:
	movlw	d'95'
	movwf	tmp1
loopl:
	bsf		irL, ir
	decfsz	tmp1, f
	goto	$+6
	goto	Leader1
	call	Delay7uSZ
	bcf		irL, ir
	call	Delay21uS
	goto	$+4
	NOP
	goto	loopl
Leader1:
	bcf		irL, ir
	call	Delay890uS
	return
;***************************************
;Send a Logic 0
;***************************************
Zero:
	bcf		irL, ir
	call	Delay444uS
	movlw	d'32'
	movwf	tmp1
loop0:
	decfsz	tmp1, f
	goto	$+6
	return
	bsf		irL, ir
	call	Delay7uS
	bcf		irL, ir
	call	Delay21uS
	goto	loop0
;***************************************
;Send a Logic 1
;***************************************
One:
	movlw	d'32'
	movwf	tmp1
loop1:
	bsf		irL, ir
	decfsz	tmp1, f
	goto	$+6
	goto	One1
	call	Delay7uSZ
	bcf		irL, ir
	call	Delay21uS
	goto	$+4
	NOP
	goto	loop1
One1:
	bcf		irL, ir
	call	Delay444uS
	return

;***************************************
;Send a Trailer Logic 0
;***************************************
trZero:
	bcf		irL, ir
	call	Delay890uS
	movlw	d'32'
	movwf	tmp1
loopt0:
	decfsz	tmp1, f
	goto	$+6
	return
	bsf		irL, ir
	call	Delay7uS
	bcf		irL, ir
	call	Delay21uS
	goto	loopt0
;***************************************
;Send a Trailer Logic 1
;***************************************
trOne:
	movlw	d'32'
	movwf	tmp1
loopt1:
	bsf		irL, ir
	decfsz	tmp1, f
	goto	$+6
	goto	OneTR1
	call	Delay7uSZ
	bcf		irL, ir
	call	Delay21uS
	goto	$+4
	NOP
	goto	loopt1
OneTR1:
	bcf		irL, ir
	call	Delay890uS
	return

;***************************************
;6.95uS 14 Cycles (7 uS) @ 8 Mhz
;***************************************
Delay7uS
	goto	$+4
	goto	$+4
	goto	$+4
	goto	$+4
	NOP
	return
Delay7uSZ
	goto	$+4
	goto	$+4
	NOP
	return
;***************************************
;20.85uS 42 Cycles (21 uS) @ 8 Mhz
;***************************************
Delay21uS 
	movlw	0x09
	movwf	d1
Delay21uS_0
	decfsz	d1, f
	goto	Delay21uS_0
	goto	$+4
	return
;***************************************
;1780 Cycles (890 uS) @ 8 Mhz
;***************************************
Delay890uS 
	movlw	0x60 ;2
	movwf	d1
	movlw	0x02
	movwf	d2
Delay890uS_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	Delay890uS_0
	goto	$+4
	nop
	return
;***************************************
;120mS () @ 8 Mhz
;***************************************
Delay120mS
	movlw	0x7E
	movwf	d1
	movlw	0xBC
	movwf	d2
Delay120mS_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	Delay120mS_0
	goto	$+4
	nop
	return

Delay444uS
	movlw	0xB0
	movwf	d1
	movlw	0x01
	movwf	d2
Delay444uS_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	Delay444uS_0
	nop
	return

Delay2_66mS
	movlw	0x26
	movwf	d1
	movlw	0x05
	movwf	d2
Delay2_66_0
	decfsz	d1, f
	goto	$+6
	decfsz	d2, f
	goto	Delay2_66_0
	goto	$+4
	nop
	return

		END

This is the HEADER:
header-jpg.28916


This is the actual data:
data-jpg.28915


Remember @ 8Mhz its 2 Cycles = 1uS
The below 14 in uS = 7uS .

pulsehigh-jpg.28918


The below 55 in uS = 27.5 uS
completepulse-jpg.28917
 

Attachments

  • data.jpg
    data.jpg
    42.4 KB · Views: 237
  • header.jpg
    header.jpg
    47.2 KB · Views: 230
  • completepulse.jpg
    completepulse.jpg
    44.5 KB · Views: 236
  • pulseHigh.jpg
    pulseHigh.jpg
    44.8 KB · Views: 243
Last edited:
ima have to put this on hold for a while. I got asked to actually create something useful for someone else lol

Using that RFID reader i had a while back. Heh ill make some money finally lol. Ill still work on this on the side but not as much. I guess ill buy a logic analyzer from saleae with the money i make but i wont be paid till im done and that may be weeks since i need to order the final board online :( but heh i guess itll be worth it.



That would help alot with finding out the control codes and stuff like header info.
 
Last edited:
PICKit2 logic analyser

Having a few spare minutes, I threw together an IR receiver to feed to my PICKit2 (IR receiver IC, 47Ω, 47µF), and here are some sample remote signals.

They are all ON/OFF signals, the first two are from satellite TV (Sky) boxes, a normal Sky box then a Sky+ (PVR), notice the slight difference because of the different device ID. These both use Philips RC6.

The third one is Sony SIRC's, and is a nice simple system to read, which was why I choose it for my tutorials.
 

Attachments

  • Sky_ONOFF.GIF
    Sky_ONOFF.GIF
    3.8 KB · Views: 110
  • SkyPlus_ONOFF.GIF
    SkyPlus_ONOFF.GIF
    3.8 KB · Views: 111
  • Sony_ONOFF.GIF
    Sony_ONOFF.GIF
    3.5 KB · Views: 106
Cool. I guess ima have to try to setup the IR Reciever again and Pickit 2 also.

How did you setup the PICKIT 2? In the Logic window i mean.

Trigger When:
Sample Rate:
Trigger Position:

Thanks.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top