;William Grill Honeywell Aerospace- Olathe 7/05/06 ;Controller delay translator provide wide delay values with small external components ;flash based, SOT23 ;processor=PIC10F202, WDT diabled GPIO equ 6 TMR0 equ 1 Status equ 3 TRISB equ 6 ; #define trigtype 0 ; 1=re-triggerable, 0=! #define trigsense 1 ; 1=hi to low 0 =low to high #define mult 2 ; n=multiplier 1-255 #define captype 1 ; 1 -255-f(RC)result, 0 -use f(RC)resultdirect RCresult equ 10 multiplier equ 11 bits equ 12 index1 equ 13 iRCresult equ 14 temp equ 15 CMCON0 equ 7 ; #define output GPIO,1 #define capin GPIO,0 #define enable GPIO,3 ; #define CNREF CMCON0,2 #define firstloop bits,0 #define setflag bits,1 #define capsense bits,2 #define retrigtype bits,3 #define poweron Status,3 #define ZERO Status,2 #define CARRY Status,0 ; ******************** start btfss poweron goto main powerup clrf GPIO movlw 0xFC ; ** 1111 1100 discharges the cap TRIS GPIO bcf CNREF if trigsense ; lohi or hilo movlw 0xEF ; 1 is hi to low 1 1 1 h/l 1 1 1 1 OPTION endif clrf bits ; firstloop, setflag if trigtype ; re-triggerable or ! bsf retrigtype endif if captype ; normal/255-result bsf capsense endif power1 movlw 0xFC andwf Status clrf TMR0 movlw mult movwf multiplier goto waitonenb ; ******************** main ; determine high to low low to high loop3 nop nop nop nop nop loopp4 nop nop waitonenb btfss enable goto loopq clrf GPIO goto power1 loopq nop nop loopw nop nop nop nop ; *********** ************** *********** ************** loop ; ---0--- test at 2min/11max sync to 7uS loop ; *********** ************** *********** ************** movf TMR0 btfsc ZERO goto loop1 ;scheduled transition bsf output ; transistion found clrf TMR0 ; clear trigger register btfsc enable ; test enable goto powerup btfss setflag ; test if output was set goto cont1 ; 1 x add 1 ; determime if single or re-trigger mode is active btfss retrigtype goto loop1aa movfw iRCresult ; re-load all registers fop re-trigger movwf RCresult ; reload movlw mult movwf multiplier bsf firstloop goto loopp ; cont1 ; trigger set and output was not set, new trigger nop cont2 bsf firstloop nop nop nop nop goto loopp ; ********************************************** ; no transititon in register loop1 btfss output goto loop ; keep looking for a trigger btfsc enable goto powerup nop loop1a nop nop nop loop1aa nop nop nop nop nop nop ; output is active loopp call maindelay ; fixed at 1ms process nop decfsz RCresult ; defned by evaluated RC goto loop3 movfw iRCresult movwf RCresult ; reload decfsz multiplier goto waitonenb ; at end bcf output bcf setflag movlw mult movwf multiplier goto loopw ; ********************* maindelay nop bsf setflag ; this is a 975-5uS loop ==970 total this sequence is 30+n*5 btfss firstloop goto main3 ; straight delay bcf firstloop movlw 0xFE ; 111 1110 TRIS GPIO movlw .127 ; movwf RCresult ; set up test of RC zd@~@~#@^$^%(*)&fglsdjfljfg toptest btfsc CMCON0,7 goto donecopy decfsz RCresult goto toptest incf RCresult ; donecopy movlw .128 subwf RCresult movlw 3 ; test if at boundary subwf RCresult,w btfsc CARRY goto done4 movlw 1 movwf RCresult goto done3 ; done4 nop movlw 3 subwf RCresult done3 btfss capsense ; qualify how to handle it goto done2 movlw 0xFF movwf temp movfw RCresult subwf temp ; reads 128 +6 incf temp,w movwf RCresult movwf iRCresult movlw .187 movwf index1 ; 12 main2 ; nop nop decfsz index1 goto main2 movlw 0xFC TRIS GPIO retlw 0 done2 ; use as is movfw RCresult movwf iRCresult movlw .186 movwf index1 nop nop nop goto main2 ; **Straight thru** main3 nop nop nop nop btfsc enable goto powerup movlw .188 movwf index1 main3a nop nop decfsz index1 goto main3a retlw 0 end