jeremygaughan
New Member
Hi again, I am still building this infrared airplane system. I have a code here to test to see if my equipment is working properly, but it's not. The transmitter sends the 38khz and the receiver picks it up. My problem is that the receiver is supposed to keep the led on whenever it receives a 38khz pulse. It flashes every time I hit the switch but won't stay on when I leave the switch pressed. here are my codes. Can anyone see a logic flaw in my programs that would cause this to be happening.
(it has adc in the real code this is just a on off deal to test the equipment)
(it has adc in the real code this is just a on off deal to test the equipment)
Code:
;1 channel transmitter using IR and ADC on a 12f675
list P=12f675
#include <p12f675.inc>
__config _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CPD_OFF & _CP_OFF
ERRORLEVEL -302
cblock 20h
counterslow, counterslow2, counterfast, counterfast2, counterslow3, counterslow4, counterfast3, counterfast4
endc
bsf STATUS,RP0 ;bank 1
movlw 0x00
movwf ANSEL
movlw 0x30
movwf TRISIO ;set I/O
bcf STATUS,RP0
movlw 0x07 ;turn off comparitors
movwf CMCON
start
btfsc GPIO,5
goto $-1
call IRpulse
goto start
IRpulse
BSF GPIO,0 ;27 commands makes 38khz
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
BCF GPIO,0
goto $+1
goto $+1
goto $+1
goto $+1
return
end
Code:
;1 channel receiver using IR and ADC on a 12f675
list P=12f675
#include <p12f675.inc>
__config _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CPD_OFF & _CP_OFF
ERRORLEVEL -302
cblock 20h
pulseontime, pulsegap, pwmhighcounter, pwmlowcounter, pwmtimer
endc
bsf STATUS,RP0 ;bank 1
movlw 0x00
movwf ANSEL
movlw 0x08
movwf TRISIO ;set I/O
bcf STATUS,RP0
movlw 0x07 ;turn off comparitors
movwf CMCON
start
bcf GPIO,0
btfsc GPIO,3
goto $-1
bsf GPIO,0
bsf GPIO,4
bsf GPIO,5
goto $+1
goto $+1
goto $+1
goto $+1
goto $+1
goto start
end