;***** Welding light with blue and white LED ***** ; list p=10f200 ;*********************************************************************** ;* Pins: ;* ---------------------------------- ;* GP: 0 > ;* 1 > white LED ;* 2 > blue LED ;* 3 > enable ;* ;*********************************************************************** ; Include file for 10F200 #include ; Configuration: ; no code protection ; no WD-Timer ; no reset pin __CONFIG _CP_OFF & _WDT_OFF& _MCLRE_OFF ;*********************************************************************** ; store variables from address 10h cblock 0x10 loops2 loops3 Count d1 d2 d3 endc ;******************************************************* ; Start of program code org 0x0000 movwf OSCCAL ; Calibrate oscillator movlw b'00001000' ; GP3 input tris GPIO movlw b'10000011' ; Pull-Upīs enable, prescaler 16 option ; bcf CMCON0,CMPON ;comparator off ; Start bcf GPIO,2 ;first LEDs off bcf GPIO,1 btfss GPIO,3 ;welding light enabled? goto $-1 ;nope movlw .100 ;100ms debounce call Wait btfss GPIO,3 ;test again goto Start ;not enabled ; ;***** welding starts with a flash ***** ; begin movlw .50 movwf Count ;Register movlw .200 ;LED on for 200ms call Wait ; btfss GPIO,3 ;light enabled? goto Start ;nope bcf GPIO,2 ;LED off bcf GPIO,1 movlw .255 ;for 255ms call Wait ; btfss GPIO,3 ;light enabled? goto Start ;nope bsf GPIO,1 ;white LED on movlw .20 call Wait bsf GPIO,2 ;blue LED on movlw .100 ;for 100ms call Wait ; btfss GPIO,3 ;light enabled? goto Start ;nope bcf GPIO,1 bcf GPIO,2 ;LED off movlw .220 ;for 220ms call Wait ; btfss GPIO,3 ;light enabled? goto Start ;nope bsf GPIO,1 ;white LED on movlw .40 call Wait bsf GPIO,2 ;LED on movlw .240 ;for 240ms call Wait ; btfss GPIO,3 ;light enabled? goto Start ;nope bcf GPIO,1 bcf GPIO,2 ;LED off movlw .220 ;for 220ms call Wait ; ;***** Now start welding ***** ; Weld bsf GPIO,1 bsf GPIO,2 ;welding LED on movlw .30 ;for 30 ms call Wait ; btfss GPIO,3 ;Welding enabled? goto Start ;nope bcf GPIO,1 bcf GPIO,2 ;LED off movlw .70 ;for 70ms call Wait ; btfss GPIO,3 ;Welding enabled? goto Start ;nope bsf GPIO,1 ;white LED on movlw .20 call Wait bsf GPIO,2 ;LED on movlw .10 ;for 10ms call Wait ; btfss GPIO,3 ;Welding enabled? goto Start ;nope bcf GPIO,1 bcf GPIO,2 ;LED off movlw .5 ;for 5ms call Wait ; btfss GPIO,3 ;Welding enabled? goto Start ;nope bsf GPIO,1 ;white LED on movlw .40 call Wait bsf GPIO,2 ;LED on movlw .30 ;for 30ms call Wait ; btfss GPIO,3 ;Welding enabled? goto Start ;nope bcf GPIO,1 bcf GPIO,2 ;LED off movlw .50 ;for 50ms call Wait ; decfsz Count,f ;if loop is executed 256 times, new welding cycle goto Weld ; ; 2999995 cycles = 3s (Delay Code Generator) pause between 2 welding cycles movlw 0x1A movwf d1 movlw 0x8B movwf d2 movlw 0x07 movwf d3 Delay_0 decfsz d1, f goto $+2 decfsz d2, f goto $+2 decfsz d3, f goto Delay_0 ;5 cycles goto $+1 goto $+1 nop ; goto begin ; ;********************************************************** ; delay loop Wait movwf loops3 ; X ms pause Wai movlw .110 ; value for 1ms movwf loops2 Wai2 nop nop nop nop nop nop decfsz loops2, F ; 1 ms passed? goto Wai2 ; nope, not yet ; decfsz loops3, F ; 100 ms passed? goto Wai ; nope, not yet retlw 0 ; stop wait ; ; end