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 transmitter using PIC

Status
Not open for further replies.

raviram87

New Member
hello people...

recently i developed this circuit (attached below).... this is a RC5 transmitter circuit... when a high signal is given at any of the inputs (designated as L. R. D and U) an appropriate function in the TV is performed (such as increasing or decreasing volume, moving channels up or down etc...)

however when i rigged up the circuit on a breadboard... the IR led shown in the figure was continuously glowing... i.e., even if no input was given...

pls help on this... wats the mistake in the design?
 

Attachments

  • pic_circuit.GIF
    pic_circuit.GIF
    16.2 KB · Views: 994
The PIC is fast enough to toggle and modulate the LED without the nand gate. You could even use a PWM pin to reduce software overhead.
 
actually to generate the carrier frequency i am using the PWM feature of the PIC..... it is set to produce a 36KHz carrier signal....

the data pulse and the carrier frequency are then fed to the nand gate... when both the inputs are high, it outputs 0 driving the pnp transistor....
 
and...

i have used a 4MHz external oscillator along with 22pf capacitors....

is this rite?? because some people also say that a 20MHz external oscillator msut be used....
 
4MHz is fine, but it's easier (and more accurate) to simply generate the 38KHz in software, plus it means you don't require any external gates.

Check my PIC tutorials for 16F628 examples using the Sony SIRC's remote system, I've also used it for RC6 (enhanced RC5) for Sky Digiboxes, only slight mods needed.
 
actually i am generating that 38KHz carrier signal using software... i have used the PWM feature of the PIC...

i have just connected the circuit as it is on a beadboard.... but it doesn seem to work...

on the other hand i placed the pic on a pic kit (available in my college and used for loading programs on the pic... comes with lcd module, leds and 7 segment displays)....

then i took a wire and gave inputs from pins 17 and 21 of the PIC to my nnd gate.... (while the pic was still in the kit)... and then tested by giving high inputs to the designated input pins... it worked perfectly fine... but its not happening on the board....
 
sorry i didnt get it.... it is a software feature rite?

am configuring the ccp module to perform the pwm operation...
(1) i write a suitable value to the PR2 register to set the PWM period....
(2) then i chose the duty cycle by writing a value to the CCP1RL register..
(3) then CCP1 pin is made the output....
(4) then TMR2 is set....
 
hmmm.. i am able to understand...

wat can be the possible solution to the problem i am facing? should i modify my circuit design...
 
Your design has too many parts that aren't required, check my tutorial for how I easily and exactly generate the carrier in software, so no extra hardware required.

Here's a routine that I (crudely - some of the unused SIRC is still there) modified to do RC6, repeatedly sending the 'backup' code for a Sky digibox.

Code:
;Nigel Goodwin 2003
;SkyDigital 'Backup' IR transmitter
	LIST	p=16F628		;tell assembler what chip we are using
	include "P16F628.inc"		;include the defaults for the chip
	__config 0x3D1C			;sets the configuration settings (oscillator type etc.)

	cblock 	0x20 			;start of general purpose registers
		count1 			;used in delay routine
		counta 			;used in delay routine 
		countb
		count
		Delay_Count
		Bit_Cntr
		Data_Byte
		Dev_Byte
		WDT_Count
		Pulse
	endc
	

IR_PORT	Equ	PORTB
IR_TRIS	Equ	TRISB
IR_Out	Equ	0x01
IR_In	Equ	0x02
Ser_Out	Equ	0x01
Ser_In	Equ	0x02
SW1	Equ	7			;set constants for the switches
SW2	Equ	6
SW3	Equ	5
SW4	Equ	4

TV_ID		Equ	0x01			;TV device ID

But1		Equ	0x00			;numeric button ID's
But2		Equ	0x01
But3		Equ	0x02
But4		Equ	0x03
But5		Equ	0x04
But6		Equ	0x05
But7		Equ	0x06
But8		Equ	0x07
But9		Equ	0x08
ProgUp		Equ	d'16'
ProgDn		Equ	d'17'
VolUp		Equ	d'18'
VolDn		Equ	d'19'


	org	0x0000			;org sets the origin, 0x0000 for the 16F628,
	goto	Start			;this is where the program starts running

	org	0x005	

Start		BTFSC   STATUS    , NOT_PD
		clrf	WDT_Count
		movlw	0x07
		movwf	CMCON			;turn comparators off (make it like a 16F84)

		clrf	IR_PORT			;make PortB outputs low
 		clrf	TMR0
		clrwdt
		
   		bsf 	STATUS,		RP0	;select bank 1
   		movlw 	b'11111101'		;set PortB all inputs, except RB1
   		movwf 	IR_TRIS
		movlw	0xff
		movwf	PORTA
		movlw	b'00101111'
		movwf	OPTION_REG
		
		bcf	STATUS,		RP0	;select bank 0

		incf	WDT_Count,	f
		btfss	WDT_Count,	0x04
		sleep

Transmit
		MOVLW	0x0F			;send preamble
		call	Xmit_RS232
		MOVLW	0xCA
		call	Xmit_RS232
		MOVLW	0x93
		call	Xmit_RS232
		MOVLW	0x55
		call	Xmit_RS232
		MOVLW	0x55
		call	Xmit_RS232
		MOVLW	0x55
		call	Xmit_RS232
						;end of preamble
		MOVLW	0x95			;send backup codes
		call	Xmit_RS232
		MOVLW	0x5A
		call	Xmit_RS232

		sleep
		
		movlw	d'40'			;delay approx 10 secs (40x255mS)
		call	Delay255
		goto	Transmit





TX_One		movlw	d'16'
		call	IR_pulse
		retlw	0x00

TX_Zero		movlw	d'16'
		call	NO_pulse
		retlw	0x00

IR_pulse			 	
		MOVWF	count		;  Pulses the IR led at 40KHz
irloop		BSF	IR_PORT,	IR_Out 
		NOP			;
		NOP			;
		NOP			;
		NOP			; 
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		BCF	IR_PORT,	IR_Out
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;	
		NOP			;
		NOP			;	
		NOP			;
		NOP			;
		NOP
		NOP
		NOP			;
		NOP			;
		NOP			;
		DECFSZ	count,F
		GOTO 	irloop	
		RETLW	0

NO_pulse			 	
		MOVWF	count		;  Doesn't pulse the IR led
irloop2		BCF	IR_PORT,	IR_Out 
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		NOP			; 
		NOP			;
		NOP			;
		NOP			;
		NOP			;
		BCF	IR_PORT,	IR_Out
		NOP			;
		NOP			;	
		NOP			;
		NOP			;	
		NOP			;
		NOP			;
		NOP
		NOP
		NOP			;
		NOP			;
		NOP			;
		DECFSZ	count,F
		GOTO 	irloop2	
		RETLW	0

Xmit_RS232      MOVWF   Data_Byte            	;move W to Data_Byte
                MOVLW   0x08                 	;set 7 DATA bits out
                MOVWF   Bit_Cntr
Ser_Loop        RLF     Data_Byte , f        	;send one bit
                BTFSC   STATUS    , C
                call	TX_One
                BTFSS   STATUS    , C
                call	TX_Zero
                DECFSZ  Bit_Cntr  , f        	;test if all done
                GOTO    Ser_Loop

                retlw	0x00



;Delay routines

LDelay		MOVWF	count	
ldloop		call	Delay255
		DECFSZ	count,F
		GOTO 	ldloop	
		retlw	0x00

Delay255	movlw	0xff		;delay 255 mS
		goto	d0
Delay100	movlw	d'100'		;delay 100mS
		goto	d0
Delay50		movlw	d'50'		;delay 50mS
		goto	d0
Delay27		movlw	d'27'		;delay 27mS
		goto	d0
Delay20		movlw	d'20'		;delay 20mS
		goto	d0
Delay5		movlw	0x05		;delay 5.000 ms (4 MHz clock)
d0		movwf	count1
d1		movlw	0xC7
		movwf	counta
		movlw	0x01
		movwf	countb
Delay_0		decfsz	counta, f
		goto	$+2
		decfsz	countb, f
		goto	Delay_0

		decfsz	count1	,f
		goto	d1
		retlw	0x00

;end of Delay routines

	end
 
i have a query....

instead of using the nand gate to mix the carrier signal and the data pulses, wat u r trying to say is modulate the data pulses within the program.... remove off the nand gate.... and then supply these modulated pulses to the pnp transistor....

am i rite?
 
And if you do stick with PWM just turn its duty from 0% (off) to 50% (the PWM will modulate the LED)

Both Nigels and the PWM method are very easy to simulate with MPLABs built in simulator and logic analyzer.
 
thanks so much for all the help....

currently am using a 25% duty cycle PWM.... by changing it to 50%, what will be the difference???
 
thanks ...:)

but i wonder what was the mistake using the NAND gate in the circuit....

so generate the carrier using the PWM feature.... modulate the pulses... and finally take the modulated output of the CCP1 pin and use that output to drive the remaining circuitry....
 
NAND gate should have worked fine, remember it inverts everything.

Depending on your project requirements Nigels version works equally well and can be put on even the smallest PICs sans PWM.
 
yup.... only when the carrier and the data pulse is high, we get a 0 output to drive the PNP transistor....

my only doubt is that the circuit works perfectly fine when
(1) the pic ic is programmed and placed in the PIC kit...
(2) the remaining part of the circuit is placed on a breadboard...

so when i take the +5V supply and give it to the PIC, the circuit works perfectly fine... even i verified its working on a tv... its fine...

but when i remove the pic and place it along with the rest of d circuit on the breadboard, the ir led starts continuously glowin.... and when i give the +5V supply to the input pins, nothing happens... it doesn work....

why is this happening?

since am using the pwm feature, should i include somethin extra in the hardware connections?
 
Breadboards are notoriously unreliable when crystals are involved. How big are the crystal caps? Do you have 0.1uf caps on the PIC and NAND gates power pins? Also hook up ALL the VDD & VSS pins.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top