;********************************************************************** ; ; Filename: photo_trigger_4.asm ; Date: 12/25/07 ; ; Camera trigger for crossed IR beams. ; Logic outputs of two IS471FE optical ICs are connected to GP0. ; LED (cathode) that indicates relay operating mode is connected at GP1. ; Relay that operates camera shutter is connected to GP2. ; Button that toggles relay operating mode between normal and ; pulsed connects at GP3. ; ; Powers up in "continuous" mode. LED and relay are activated as long ; as the IR beams are interrupted. ; Pushing the button switches from continuous mode to pulsed ; mode. In pulsed mode, relay is closed and LED turned on for 25 ms ; then turned off for 975 ms, 875 ms, ... 75 ms depending upon the number ; of times the button is pushed. 11th push returns to continuous mode. ; Watch-dog timer resets uC to continuous mode if you hold the button ; down for 2.3 seconds. ; ; version 3: pulse modes set to 1, 2, 3...8,9, 10 pps ; also removed debounce delay on IR beams input ; version 4: when selecting pulse mode, LED flashes the frequency- select ; 4 pps and the LED flashes 4 times, etc. ; ; Tested, working 12/25/07 ; delays generated using Picloops ;******************************************************************** list p=10F206 ; list directive to define processor #include ; processor specific variable definitions __CONFIG _CP_OFF & _MCLRE_OFF & _WDT_ON & _IntRC_OSC UDATA RELAY_MODE res 1 CounterA res 1 CounterB res 1 CounterC res 1 CounterD res 1 BUTTON EQU GP3 RELAY EQU GP2 LED EQU GP1 IR_BEAMS EQU GP0 ;********************************************************************** RESET_VECTOR CODE 0x000 ; processor reset vector goto start ; go to beginning of program ;************************* Main Program Code ******************************** MAIN CODE start movlw b'10001111' ; b7:wake on change-off, b6:weak pull-ups -on, OPTION ; TMR0 on fosc/4, prescaler on WDT, ; prescaler = 1/128 bcf CMCON0,CMPON ; turn off comparator movlw 0x09 TRIS GPIO ; set GP0,3 as inputs, GP1,2 as outputs movlw 0x06 movwf GPIO ; set RELAY and LED off LEDnorm clrf RELAY_MODE ; set relay mode to "normal" (not pulsed) bcf GPIO,LED ; turn on LED for 1 second call delay500 call delay500 bsf GPIO,LED ; turn off LED button bsf GPIO,RELAY ; turn relay off bsf GPIO,LED ; turn LED off clrwdt btfsc GPIO,BUTTON ; check BUTTON. If pushed, debounce and goto beams ; check again. If still pushed, wait for call delay11 ; release. btfsc GPIO,BUTTON goto beams loopa btfss GPIO,BUTTON ; wait for button release goto loopa incf RELAY_MODE,f ; increment RELAY_MODE movlw .11 subwf RELAY_MODE,w btfss STATUS,Z ; if RELAY_MODE=11, goto LEDpulse goto LEDnorm LEDpulse movf RELAY_MODE,w movwf CounterD loopz bcf GPIO,LED ; turn on LED for 25 ms call delay25 bsf GPIO,LED ; turn off LED clrwdt call delay167 call delay167 decfsz CounterD,f goto loopz goto button beams clrwdt btfss GPIO,IR_BEAMS ; check for input from IR beams. goto button movf RELAY_MODE,f btfsc STATUS,Z ; check relay mode goto rlycont rlypuls bcf GPIO,LED ; turn on LED for 25 ms bcf GPIO,RELAY call delay25 bsf GPIO,LED bsf GPIO,RELAY movf RELAY_MODE,w addwf PCL,f ; jump to appropriate "off" delay nop call delay500 call delay167 call delay83 call delay50 call delay33 call delay24 call delay18 call delay14 call delay11 call delay75 goto beams rlycont bcf GPIO,RELAY ; normal mode: turn relay on bcf GPIO,LED ; turn LED on call delay25 ; for 25 ms goto beams ;PIC Time Delay = 0.5000020 s with Osc = 4.000000 MHz delay500 movlw D'3' movwf CounterC movlw D'140' movwf CounterB movlw D'83' movwf CounterA loopw decfsz CounterA,1 goto loopw decfsz CounterB,1 goto loopw decfsz CounterC,1 goto loopw retlw 0x00 ;PIC Time Delay = 0.1666680 s with Osc = 4.000000 MHz delay167 movlw D'217' movwf CounterB movlw D'113' movwf CounterA loopv decfsz CounterA,1 goto loopv decfsz CounterB,1 goto loopv retlw 0x00 ;PIC Time Delay = 0.0833340 s with Osc = 4.000000 MHz delay83 movlw D'109' movwf CounterB movlw D'55' movwf CounterA loopu decfsz CounterA,1 goto loopu decfsz CounterB,1 goto loopu retlw 0x00 ;PIC Time Delay = 0.0500030 s with Osc = 4.000000 MHz delay50 movlw D'65' movwf CounterB movlw D'238' movwf CounterA loopt decfsz CounterA,1 goto loopt decfsz CounterB,1 goto loopt retlw 0x00 ;PIC Time Delay = 0.0333350 s with Osc = 4.000000 MHz delay33 movlw D'44' movwf CounterB movlw D'72' movwf CounterA loops decfsz CounterA,1 goto loops decfsz CounterB,1 goto loops retlw 0x00 ;PIC Time Delay = 0.0238110 s with Osc = 4.000000 MHz delay24 movlw D'31' movwf CounterB movlw D'234' movwf CounterA loopr decfsz CounterA,1 goto loopr decfsz CounterB,1 goto loopr retlw 0x00 ;PIC Time Delay = 0.0178600 s with Osc = 4.000000 MHz delay18 movlw D'24' movwf CounterB movlw D'47' movwf CounterA loopn decfsz CounterA,1 goto loopn decfsz CounterB,1 goto loopn retlw 0x00 ;PIC Time Delay = 0.0138900 s with Osc = 4.000000 MHz delay14 movlw D'19' movwf CounterB movlw D'7' movwf CounterA loopq decfsz CounterA,1 goto loopq decfsz CounterB,1 goto loopq retlw 0x00 ;PIC Time Delay = 0.0111130 s with Osc = 4.000000 MHz delay11 movlw D'15' movwf CounterB movlw D'108' movwf CounterA loopp decfsz CounterA,1 goto loopp decfsz CounterB,1 goto loopp retlw 0x00 ;PIC Time Delay = 0.0750020 s with Osc = 4.000000 MHz delay75 movlw D'98' movwf CounterB movlw D'101' movwf CounterA loopo decfsz CounterA,1 goto loopo decfsz CounterB,1 goto loopo retlw 0x00 ;PIC Time Delay = 0.0250030 s with Osc = 4.000000 MHz delay25 movlw D'33' movwf CounterB movlw D'118' movwf CounterA loopx decfsz CounterA,1 goto loopx decfsz CounterB,1 goto loopx retlw 0x00 END ; directive 'end of program'