raitl
New Member
Hi. I'm a bginner in robotics and been working on my first bot for a week now. I have it "up and running" with basic (bump switch based) navigation. Now I'm implementing IR object detection and I've run into a problem I can't seem to overcome...
I'm using mostly recycled parts for the bot, except for the PIC16F876A microcontroller. So my IR system consists of one TSOP1738 IR reciever and two IR leds from old TV remotes. I have everything wired to the PIC and the receiver works...somewhat when I point a remote at it and press buttons. Sometimes it gets a reading and sometimes not. It might be that the remotes aren't exactky 38kHz so that's not a big problem. The big problem is, that my IR leds don't want to communicate with the reciever. I'm using PWM to modulate the IR light at exactly 38kHz, but I suspect I have not set up the hardware PWM correctly.
could someone help me calculate the appropriate values to get the led blink at exactly 38kHz? And explain the values aswell.
Thanks in advance.
I'm using mostly recycled parts for the bot, except for the PIC16F876A microcontroller. So my IR system consists of one TSOP1738 IR reciever and two IR leds from old TV remotes. I have everything wired to the PIC and the receiver works...somewhat when I point a remote at it and press buttons. Sometimes it gets a reading and sometimes not. It might be that the remotes aren't exactky 38kHz so that's not a big problem. The big problem is, that my IR leds don't want to communicate with the reciever. I'm using PWM to modulate the IR light at exactly 38kHz, but I suspect I have not set up the hardware PWM correctly.
Code:
BANK1
movlw 0x34 ;PWM period
movwf PR2
BANK0 ; register bank 0
bsf CCP1CON, 4 ; Determine
bcf CCP1CON, 5 ; PWM duty cycle
movlw b'01000000' ; initial duty cycle
movwf CCPR1L
BANK1 ; register bank 1
bcf TRISC, 2 ; port c is an output
BANK0 ; register bank 0
movlw b'00000100' ;
movwf T2CON ; PWM on TIMER2
could someone help me calculate the appropriate values to get the led blink at exactly 38kHz? And explain the values aswell.
Thanks in advance.