![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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? | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| 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.... | |
| |
| | (permalink) |
| 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.... | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| 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.... | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| 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.... | |
| |
| | (permalink) |
| No, you using the hardware PWM module, it's a hardware function - this is why you've added the spurious extra gate. | |
| |
| | (permalink) |
| hmmm.. i am able to understand... wat can be the possible solution to the problem i am facing? should i modify my circuit design... | |
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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? | |
| |
| | (permalink) |
| Yes, although I would use an NPN transistor, as my tutorials do (and as remote controls generally do). | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| 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??? | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| RF module interface with PIC | dilton13 | General Electronics Chat | 11 | 18th January 2008 06:37 PM |
| Capturing and reproducing audio with a PIC | Fred.Amoson | Micro Controllers | 14 | 14th December 2007 09:22 PM |
| High ADC sampling rate PIC, 18F needed? | bananasiong | Micro Controllers | 24 | 28th October 2007 01:13 PM |
| Attempting to make a Keyfob transmitter... | adamthole | Electronic Projects Design/Ideas/Reviews | 7 | 25th November 2006 01:05 PM |
| Transmitter | zachtheterrible | General Electronics Chat | 3 | 5th August 2004 10:56 AM |