;DETECTOR DE PROXIMIDAD emite con un led infrarrojo un ;haz de luz que al reflejarse con algun objeto, rebota ;al detector de luz infrarroja, la tarjeta detectora ;que contiene estos dispositivos se conecta a una tarjeta ;EDUPIC en el conector para LCD processor 16f628 include __config _XT_OSC & _WDT_OFF & _PWRTE_OFF & _MCLRE_ON & _BODEN_OFF & _LVP_OFF #DEFINE BANCO0 BCF STATUS,5 #DEFINE BANCO1 BSF STATUS,5 CONT EQU 20H L EQU 21H M EQU 22H P EQU 23H EVE EQU 24H PENDON EQU 25H CLAVE EQU 26H ORG 00H clrf PORTA clrf PORTB movlw H'07' movwf CMCON INICIO BANCO1 clrf VRCON movlw 0x04 movwf PORTA ;salida RA0,1 ; entrada RA2 movlw 0x0e ;entradas RB3,2,1 movwf PORTB bcf OPTION_REG,7 ;pulls up habilitados BANCO0 VUELTA BSF PORTA,1 ;led I.R. apagado call MOMENTO MOVLW 0X4 MOVWF EVE TRENES movlw D'5' movwf CONT CALL MOMENTO PULSOS bcf PORTA,1 ;enciende led call PICO ; bsf PORTA,1 ;apaga led call PICO decfsz CONT ;envia 5 pulsos goto PULSOS BTFSC PORTA,2 ;verifica entrada de R.I.R. GOTO DECI DECFSZ EVE GOTO TRENES SELEC movfw PORTB ;ve los puentes movwf CLAVE ;puenteado es cero bcf STATUS,C rrf CLAVE,f ;para que sean los menos significativos comf CLAVE ;los hace uno movfw CLAVE andlw 0X7 ;solo los pines con puentes movwf CLAVE VALIDA bcf STATUS,Z ;solo hay tres combinaciones sublw 0x1 ;que son validas btfsc STATUS,Z goto ESUNO movfw CLAVE sublw 0x2 btfsc STATUS,Z goto ESDOS movfw CLAVE sublw 0x4 btfsc STATUS,Z goto ESCUAT goto VUELTA ;otra combinacion no es válida ESUNO bsf PORTA,0 ;activa Rel. goto PAU1 ESDOS bsf PORTA,0 goto PAU2 DECI btfsc CLAVE,2 goto VUELTA DESACTI bcf PORTA,0 call MOMENTO goto INICIO PAU1 call PAUSA1 goto INICIO PAU2 call PAUSA2 goto INICIO ESCUAT BTFSC PENDON,3 GOTO APAGA bsf PENDON,3 BSF PORTA,0 MISMO call PAUSA1 goto VUELTA APAGA BCF PENDON,3 BCF PORTA,0 goto MISMO PICO movlw 0x06 ;20 us movwf P PE decfsz P,f goto PE return MOMENTO movlw 0x3 ;2.263 ms movwf M MOM movlw 0xFA movwf L MOL decfsz L goto MOL decfsz M,f goto MOM return PAUSA1 movlw 0x3 ;588.299 ms movwf L PAL1 movlw 0xFF movwf M PAM1 MOVLW 0XFF MOVWF P PAN1 DECFSZ P,F GOTO PAN1 decfsz M,F goto PAM1 decfsz L,f goto PAL1 return PAUSA2 movlw 0x37 ;10.785 ..s movwf L PAL2 movlw 0xFF movwf M PAM2 MOVLW 0XFF MOVWF P PAN2 DECFSZ P,F GOTO PAN2 decfsz M,F goto PAM2 decfsz L,f goto PAL2 return end