; ; Fan Control ; Copyright (c) 2019.5.25 by (JM7OLW)Kousuke Matsumoto LIST P=PIC16F84A INCLUDE "P16F84A.INC" __CONFIG _RC_OSC & _WDT_OFF ;file register----------------------------------- tim1 EQU 21 tim2 EQU 22 tim3 EQU 23 time EQU 24 ;------------------------------------------------ ORG 0 GOTO start ;------------------------------------------------ start BCF PORTB,4 ;Relay OFF BSF STATUS,RP0 ;bank1 MOVLW B'11111' ;set RA0-4 INPUT MOVWF TRISA ;85h=TRISA MOVLW B'11100111' ;set RB4 OUTPUT MOVWF TRISB ;86h=TRISB BCF STATUS,RP0 ;bank0 BCF PORTB,4 ;Relay OFF CLRF time main00 BTFSC PORTA,2 ;IC7851 send relay GOTO main20 ;now receiving GOTO main10 ;now sending main10 ;now sending BSF PORTB,4 ;Relay <- ON MOVLW D'240' ;240sec is 4minutes MOVWF time GOTO main90 main20 ;now receiving INCF time,F DECFSZ time,F ;if time = 0 GOTO main40 ;time > 0 GOTO main30 ;time=0 main30 ;time=0 FAN is Low BCF PORTB,4 ;Relay <- OFF GOTO main90 main40 BSF PORTB,4 ;Relay <- ON DECF time,F ;time = time - 1 GOTO main90 main90 CALL wait ;1 sec wait GOTO main00 ;------------------------------------------------ ; wait 1 sec ;------------------------------------------------ wait BSF PORTB,3 ;debug MOVLW D'2' MOVWF tim1 wa1 MOVLW D'10' MOVWF tim2 wa2 MOVLW D'100' MOVWF tim3 wa3 NOP NOP DECFSZ tim3,F GOTO wa3 DECFSZ tim2,F GOTO wa2 DECFSZ tim1,F GOTO wa1 BCF PORTB,3 ;debug RETURN END ;end program-------------------------------------