;--TERMOSTAT-------------------)S(09.2003 ; slovak@post.cz ; ; Xtal=20MHz ; Displej spolecna Anoda(+) ; 09.2006 uprava: levy displej nezobrazuje nulu ; ; Leve tlacitko - Minus ; Prostredni tl. - Plus ; Prave tlacitko - Dalsi (postupne prepinani zobrazeni na displeji) ; ; displej: teplota -19.9 az 99.9 [stupne Celsia] ; : L = mez Low -19 az 99 ; : H = mez High -19 az 99 ;_ ___ : P = cislo Programu regulace 0 az 5 ; |___| |_: A = cas pro ReLo ZAP 00-FFhex (00=nejdelsi cas, jako 100hex) ; : b = cas pro ReLo VYP 00-FFhex (00=necasuje, imp=0) ; |-A-|-b-| : C = cas pro ReHi ZAP 00-FFhex (00=nejdelsi cas, jako 100hex) ; |-C-|-d-| : d = cas pro ReHi VYP 00-FFhex (00=necasuje, imp=0) ; (01=nejkratsi cas, asi 0.15s) ; Program 0: vystupy RHi RLo 0=zap ; 1: pouze pro RHi s hysterezi podle H a L ; na vystupu RLo jsou impulzi (frekvence je umerna teplote) ; 2,3,4,5: mez H ovlada RHi podle tabulky ; mez L ovlada RLo podle tabulky ; ; | 0 1 2 3 4 5 Program regulace ; meze | ; | 1 v1 imp v1 imp 0 ; H -|--------------------------- }vystup ReHig ; | 1 ^1 imp ^1 ^1 ; | imp-teplota stoupa ; | ; | imp-teplota klesa ; | 1 imp v1 v1 v1 ; L -|--------------------------- }vystup ReLow ; | 1 ^0 ^1 imp imp 0 ; | ; ^ ; teplota ; ; ^v = vcetne (pri rovnosti teploty a meze plati jeste tento stav) ; 1 = vystup rele VYP ; 0 = vystup rele ZAP ; imp = casove prepinani rele podle nastavenych casu ; ;---------------------------------------- LIST P=16F628, R=DEC ; direktivy prekladace include ; definice nazvu registru __CONFIG 0x3F66 T0 EQU 0x20 ;vysledna teplota (desetiny) T1 EQU 0x21 ; (jednicky) T2 EQU 0x22 ; (desitky) Priznak EQU 0x23 ;priznakove bity ;pro matematicke a (jine) funkce A1 EQU 0x24 ;(Vzorky) A2 EQU 0x25 ;(pamet pro Segment) A3 EQU 0x26 ;(MemW) B1 EQU 0x27 ;(H1 delka urovenH 1) B2 EQU 0x28 ;(H2 delka urovenH 2) B3 EQU 0x29 ; C1 EQU 0x2A ;(Kolikrat) C2 EQU 0x2B ; C3 EQU 0x2C ; D1 EQU 0x2D ;(SH1 suma urovneH 1) D2 EQU 0x2E ;(SH2 suma urovneH 2) D3 EQU 0x2F ;(SH3 suma urovneH 3) D4 EQU 0x30 ;(SP1 suma perioda 1) D5 EQU 0x31 ;(SP2 suma perioda 2) D6 EQU 0x32 ;(SP3 suma perioda 3) P1 EQU 0x33 ;(P1 delka periody 1) P2 EQU 0x34 ;(P2 delka periody 2) P3 EQU 0x35 ; (1=nizsi, 2=vyzsi, 3=nejvyzsi bajt) CDisplej EQU 0x36 ;citac pro displej DPoradi EQU 0x37 ;poradi displeje Disp0 EQU 0x38 ;znak na displeji Disp1 EQU 0x39 ; Disp2 EQU 0x3A ; MOD EQU 0x3B ;cislo modu KlvPort EQU 0x3C ;klavesnice OC1 EQU 0x3D ;Old C OC2 EQU 0x3E ; pro Prumer O1 EQU 0x3F ;Out teplota O2 EQU 0x40 ; vystupni teplota pred -681 KC0 EQU 0x41 ;casovac Opakovani KC1 EQU 0x42 ; KLV Low1 EQU 0x43 ;dolni mez Low2 EQU 0x44 ; Hig1 EQU 0x45 ;horni mez Hig2 EQU 0x46 ; TA EQU 0x47 ;CYKLOVAC Low TB EQU 0x48 ; TC EQU 0x49 ;CYKLOVAC Hig TD EQU 0x4A ; Prog EQU 0x4B ;cislo programu PT1 EQU 0x4C ;Prevod teplota/impuls PT2 EQU 0x4D ; CImpuls EQU 0x4E ;Citac pro impuls Trend0 EQU 0x4F ;teplota stoupa nebo klesa Trend1 EQU 0x50 ; Trend2 EQU 0x51 ; EEADRp EQU 0x70 ;pomocna EE adresa (!!! 0x70 !!!) TlM EQU 3 ;PORTB tlacitko MINUS TlP EQU 5 ;PORTB tlacitko PLUS TlD EQU 4 ;PORTB tlacitko DALSI Vstup EQU 0 ;PORTB teplotni cidlo SMT 160-30 OD1 EQU 0 ;PORTA anoda Disp1 OD2 EQU 1 ;PORTA anoda Disp2 OD0 EQU 2 ;PORTA anoda Disp0 ReLo EQU 3 ;PORTA vystup rele RLo ReHi EQU 4 ;PORTA vystup rele Hig VST EQU 0 ;Priznak vstup Kl EQU 7 ;Priznak kladne Pres EQU 6 ;Priznak stisknute tl. Zapis EQU 5 ;Priznak pro zapis do EEPROM Znam EQU 4 ;Priznak znamenko ImpOut EQU 3 ;PORTA vystup impulsu ;---------------------------------------- ; kod programu ;---------------------------------------- ORG 0 GOTO Start ; skok na zacatek programu CALL 41 CALL 83 CALL 40 GOTO IntProc ; skok na obsluhu preruseni ;---------------------------------------- ;--prevod cislo znaku/sedmisegment------- Segment MOVWF A2 ; SUBLW 0x24 ;24-Seg MOVF A2,W ;puvodni znak BTFSS STATUS,C ;kladne? MOVLW 0x20 ;NE, nahradit znak ADDWF PCL,F ;ANO RETLW 0x05 ;00/0 RETLW 0xED ;01/1 RETLW 0x83 ;02/2 RETLW 0xC1 ;03/3 RETLW 0x69 ;04/4 RETLW 0x51 ;05/5 RETLW 0x11 ;06/6 RETLW 0xCD ;07/7 RETLW 0x01 ;08/8 RETLW 0x41 ;09/9 RETLW 0x09 ;0A/A RETLW 0x31 ;0B/b RETLW 0x17 ;0C/C RETLW 0xA1 ;0D/d RETLW 0x13 ;0E/E RETLW 0x1B ;0F/F RETLW 0x29 ;10/H RETLW 0x3F ;11/I RETLW 0xA5 ;12/J RETLW 0x3B ;13/k RETLW 0x37 ;14/L RETLW 0x0D ;15/M RETLW 0xB9 ;16/n RETLW 0xB1 ;17/o RETLW 0x0B ;18/P RETLW 0xBB ;19/r RETLW 0x33 ;1A/t RETLW 0x35 ;1B/u RETLW 0x45 ;1C/V RETLW 0x2B ;1D/Y RETLW 0xFB ;1E/- RETLW 0xE9 ;1F/-1(-10) RETLW 0xFF ;20/ (vypnuty displej) RETLW 0xF3 ;21/= (-20) RETLW 0xD3 ;22/. (-30) RETLW 0x79 ;23/. (-40) RETLW 0xC5 ;24/) ;--MINUS ZNAKY--------------------------- MZnaky BTFSC STATUS,Z ;nulov? MOVLW 0x20 ;ANO, kod VYP.znak MOVWF Disp2 BTFSS Disp2,7 ;MSB=1? RETURN ;NE ANDLW B'00000111' ;(1a1=1) ADDWF PCL,F ;PC+W RETLW 0x1E ;0 = kod - RETLW 0x1F ;1 = kod -1 RETLW 0x21 ;2 = kod -2 RETLW 0x22 ;3 = kod -3 RETLW 0x23 ;4 = kod -4 ;---------------------------------------- IntProc MOVF TMR0,W ;casovac do W BTFSC INTCON,T0IF ;preruseni od casovace? GOTO Timer ;ANO MOVWF B1 ;casovac do H1 BCF Priznak,VST ;VST=0 BCF INTCON,INTF ;priz.prer.od vstupu=0 RETFIE Timer INCF P2,F ;P2+1 BTFSC Priznak,VST ;VST=0? INCF B2,F ;NE, H2+1 BCF INTCON,T0IF ;priz.prer.od casovace=0 RETFIE ;---------------------------------------- ;--C1 * (D2,3 * 2) = B1,2,3-------------- Posuv MOVWF C1 ;kolikrat MOVF D2,W MOVWF A1 MOVF D3,W MOVWF A2 CLRF A3 Znova BCF STATUS,C ;C=0 RLF A1,F ;posuv vlevo RLF A2,F ; RLF A3,F ; DECFSZ C1,F ;kolikrat-1, =0? GOTO Znova ;NE MOVF A1,W ADDWF B1,F ;B1+A1 BTFSS STATUS,C ;preteklo? GOTO Plus2 ;NE INCFSZ B2,F ;+1, =0? GOTO Plus2 ;NE INCF B3,F ;+1 Plus2 MOVF A2,W ADDWF B2,F ;B2+A2 BTFSC STATUS,C ;nepreteklo? INCF B3,F ;+1 MOVF A3,W ADDWF B3,F ;B3+A3 RETURN ;======================================== ; Matematicke podprogramy ; ;---A1,2,3 / B1,2,3 = C1,2,3------------- ; s.Z=1=deleni nulou ; B se nemeni, v A je zbytek ; pouziva D1,2,3,4,5,6;P1 LOMENO MOVF B1,F ;Test B na nulu BTFSC STATUS,Z ;nenulove? MOVF B2,F ; BTFSC STATUS,Z ;nenulove? MOVF B3,F ; BTFSC STATUS,Z ;nenulove? RETURN ;B=0 MOVF A1,W ;AdoD MOVWF D1 ; MOVF A2,W ; MOVWF D2 ; MOVF A3,W ; MOVWF D3 ; CLRF D4 ;nulovat CLRF D5 ; CLRF D6 ; MOVLW 24 ;pocet bitu MOVWF P1 ; BCF STATUS,C ;C=0 LPrvni CALL Dx2 CALL PMinus BTFSC STATUS,C ;zaporne? GOTO LKlad DECFSZ P1,F ;-1=0? GOTO LPrvni GOTO ELom ;A1C MOVF C1,W SUBLW 10 ;10-C1 BTFSC STATUS,C ;zaporne? GOTO DTEnd ;NE Big MOVF D1,W ;okamzita MOVWF O1 ; zmena MOVF D2,W ; MOVWF O2 ; DTEnd BSF STATUS,C ;C=1 RETURN ;--CTENI EEPROM-------------------------- ERead BSF STATUS,RP0 ;reg.sada 1 MOVF EEADRp,W MOVWF EEADR ;adresa BSF EECON1,RD ;cteni MOVF EEDATA,W BCF STATUS,RP0 ;reg.sada 0 RETURN ;--ZAPIS DO EEPROM----------------------- EWrite BSF STATUS,RP0 ;reg.sada 1 MOVWF EEDATA ;data MOVF EEADRp,W MOVWF EEADR ;adresa BSF EECON1,WREN ;zapis povolen MOVLW 0x55 ;uvodni MOVWF EECON2 ; sekvence MOVLW 0xAA ; MOVWF EECON2 ; BSF EECON1,WR ;zapis EEIF0 BTFSC EECON1,WR ;konec zapisu? GOTO EEIF0 ;NE BCF EECON1,WREN ;zapis zakazan BCF STATUS,RP0 ;reg.sada 0 RETURN ;--TEPLOTA>X----------------------------- ; C=0=ANO, C=1=NE VETSI ANDLW 0x80 ;1000000 BTFSS STATUS,Z ;X=+? GOTO VetsiTM ;NE, X=- BTFSC T2,7 ;T=+? GOTO Ce1 ;NE, T=- VetsiMT MOVF T0,W ;TdoB MOVWF B1 ; MOVF T1,W ; MOVWF B2 ; MOVF T2,W ; MOVWF B3 ; CALL MINUS ;X-T RETURN VetsiTM BTFSC T2,7 ;T=+? GOTO MensiTM ;NE ;---------------------------------------- Ce0 BCF STATUS,C RETURN ;--TEPLOTA=vystup+5 tak vystup+1 CLRF A3 MOVF O2,W MOVWF B2 MOVF O1,W ADDLW 5 ;Dif.+4 MOVWF B1 ;B+5 BTFSC STATUS,C ;nepreteklo? INCF B2,F ;+1 CLRF B3 CALL DifTest BTFSS STATUS,C ;kladne? GOTO DifMinus INCFSZ O1,F ;+1, =0? GOTO DifEnd ;konec INCF O2,F ;+1 GOTO DifEnd ;konec ;jestli vstup<=vystup tak vystup-1 DifMinus MOVF D1,W MOVWF B1 MOVF D2,W MOVWF B2 MOVF O1,W MOVWF A1 MOVF O2,W MOVWF A2 CALL DifTest BTFSS STATUS,C ;kladne? GOTO DifEnd ;Program;v Toleranci MOVLW 1 SUBWF O1,F ;-1 BTFSS STATUS,C ;kladne? DECF O2,F ;-1 DifEnd MOVF O1,W MOVWF A1 MOVF O2,W MOVWF A2 ;--MINUS A1,2 - 681 = C1,2--------------- ; C1,2 do T1,2 CLRF A3 MOVLW 0xA9 ;(681=0x02A9) MOVWF B1 ; MOVLW 0x02 ; MOVWF B2 ; CLRF B3 CALL MINUS ;A-B=C MOVF C1,W ;CdoT MOVWF T1 ; MOVF C2,W ; MOVWF T2 ; ;--ZNAMENKO------------------------------ BTFSS STATUS,C ;C=1, kladne? GOTO Zaporne ;NE BCF Priznak,Znam ;znamenko=0, (nesviti) GOTO HexDec Zaporne BSF Priznak,Znam ;znamenko=1, (sviti) COMF C1,F ;negace COMF C2,F ; INCFSZ C1,F ;+1, =0? (korekce) GOTO HexDec INCF C2,F ; ;--HEX/DEC------------------------------- HexDec CLRF T1 CLRF T2 Rad100 MOVLW 100 SUBWF C1,W ;C1-100 MOVWF B1 BTFSC STATUS,C ;zaporne? GOTO Uloz ;NE MOVLW 1 SUBWF C2,W ;C2-1 BTFSS STATUS,C ;kladne? GOTO Rad10 ;NE MOVWF C2 MOVF B1,W Uloz MOVWF C1 INCF T2,F ;+1 GOTO Rad100 Rad10 MOVLW 10 SUBWF C1,W ;C1-10 BTFSS STATUS,C ;kladne? GOTO End10 ;NE MOVWF C1 INCF T1,F ;+1 GOTO Rad10 End10 MOVF C1,W MOVWF T0 ;T0,1,2=vysledna teplota ;--OZNACIT ZAPORNE (nastavit bit7 T2)---- BTFSC Priznak,Znam ;kladne? BSF T2,7 ;NE, MSB=1 ;--ZVOLENY PROGRAM----------------------- Program MOVF Prog,W MOVWF A3 ;test Prog BTFSC STATUS,Z ;Prog=0? GOTO PROG0 ;ANO DECF A3,F ;test-1 BTFSC STATUS,Z ;=0?, Prog=1? GOTO PROG1 ;ANO DECF A3,F ;test-1 BTFSC STATUS,Z ;=0?, Prog=2? GOTO PROG2 ;ANO DECF A3,F ;test-1 BTFSC STATUS,Z ;=0?, Prog=3? GOTO PROG3 ;ANO DECF A3,F ;test-1 BTFSC STATUS,Z ;=0?, Prog=4? GOTO PROG4 ;Prog=4 GOTO PROG5 ;Prog=5 ;--VYNULOVAT SH,SP a Vzorky-------------- NulD CLRF D1 ;SH CLRF D2 ; CLRF D3 ; CLRF D4 ;SP CLRF D5 ; CLRF D6 ; CLRF A1 ;Vzorky ;--DISPLEJ 3 mista----------------------- Disp DECFSZ CDisplej,F ;citac-1, =0? GOTO ImpP1 ;NE MOVLW 7 ;rychlost MOVWF CDisplej ; zobrazovani DECFSZ DPoradi,F ;-1; =0? GOTO DJedna ;NE ;--Desetiny------------------------------ MOVLW 3 ;pocet mist displeje MOVWF DPoradi MOVF Disp0,W CALL Segment BCF PORTA,OD1 ;OD1=0=VYP MOVWF PORTB BSF PORTA,OD0 ;OD0=1=ZAP GOTO ImpP1 ;---------------------------------------- DJedna DECFSZ DPoradi,W ;-1, =0? GOTO DDva ;NE ;--Jednicky------------------------------ MOVF Disp1,W CALL Segment BCF PORTA,OD2 ;OD2=0=VYP ;---Cteni klavesnice------------- MOVWF A3 ;schovat W MOVLW 255 ;11111111 MOVWF PORTB ;prepnout na 1 BSF STATUS,RP0 ;reg.sada1 MOVWF TRISB ;1=vstup BCF STATUS,RP0 ;reg.sada0 MOVF PORTB,W ;cte KLV MOVWF KlvPort ;ulozit BSF STATUS,RP0 ;reg.sada1 MOVLW 1 ;00000001 MOVWF TRISB ;0=vystup BCF STATUS,RP0 ;reg.sada0 MOVF A3,W ;obnovit W ;-------------------------------- MOVWF PORTB BSF PORTA,OD1 ;OD1=1=ZAP GOTO ImpP1 ;--Desitky------------------------------- DDva MOVF Disp2,W CALL Segment BCF PORTA,OD0 ;OD0=0=VYP MOVWF PORTB BSF PORTA,OD2 ;OD2=1=ZAP ;--Impulsni vystup PROG1----------------- ImpP1 DECFSZ Prog,W ;test Prog-1, =0? GOTO Mode ;NE DECFSZ CImpuls,F ;CitacImpulsu-1, =0? GOTO Prevod ;NE BSF PORTA,ImpOut ;vystup=1 Prevod INCFSZ PT1,F ;Prevod Teploty+1, =0? GOTO Mode ;NE INCFSZ PT2,F ;+1, =0? GOTO Mode ;NE BCF PORTA,ImpOut ;vystup=0 MOVLW 90 ;obnovit MOVWF CImpuls ; CitacImpulsu MOVF O1,W ;nova hodnota MOVWF PT1 ; prevodu MOVF O2,W ; na impuls MOVWF PT2 ; RLF PT1,F ;x2 RLF PT2,W ; ADDLW 0xED ;+11101101 237 MOVWF PT2 ; korekce ;--MOD zobrazovani teplota=0,L=1,H=2,P=3 Mode MOVF MOD,W MOVWF A3 ;test MOD BTFSC STATUS,Z ;=0? GOTO MTeplomer ;ANO, teplota DECF A3,F ;test-1 BTFSC STATUS,Z ;=0?, MOD=1? GOTO MLow ;ANO, L DECF A3,F ;test-1 BTFSC STATUS,Z ;=0?, MOD=2? GOTO MHigh ;ANO, H DECF A3,F ;test-1 BTFSC STATUS,Z ;=0?, MOD=3? GOTO MProg ;ANO, P ;--MOD A=4,b=5,C=6,d=7------------------- MOVWF EEADRp ;cislo casovace v EEPROM ADDLW 6 ;+6=znak(A,b,C,d) MOVWF Disp0 ;na displej0 CALL ERead MOVWF B2 ;casovac(TA,TB,TC,TD) ANDLW 0x0F ;00001111, dolni 4bity MOVWF Disp1 ;na displej1 SWAPF B2,W ANDLW 0x0F ;00001111, horni 4bity MOVWF Disp2 ;na displej2 CALL KLV BTFSC STATUS,Z ;neco stisknuto? GOTO Main ;NE BTFSS KlvPort,TlM ;je to Tl.Minus? DECF B2,F ;ANO, -1 BTFSS KlvPort,TlP ;je to Tl.Plus? INCF B2,F ;ANO, +1 BTFSS KlvPort,TlD ;je to Tl.Dalsi? GOTO ModPlus ;ANO MOVF B2,W ;casovac(TA,TB,TC,TD) CALL EWrite ;zapis MOVLW 1 MOVWF TB MOVWF TD GOTO Main ;======================================== MTeplomer MOVF T0,W ;teplota desetiny MOVWF Disp0 ;do displej0 MOVF T1,W ;teplota jednicky MOVWF Disp1 ;do displej1 MOVF T2,W ;teplota desitky CALL MZnaky MOVWF Disp2 ;do displej2 CALL KLV BTFSS STATUS,Z ;zadne tlacitko? BTFSC KlvPort,TlD ;NE ;stisknuto Tl.Dalsi? GOTO Main ;konec ;NE, konec ;---------------------------------------- ModPlus INCF MOD,F ;+1 MOVF MOD,W XORLW 8 BTFSC STATUS,Z ;>7? CLRF MOD ;ANO, MOD=0 GOTO Main ;======================================== MLow MOVLW 0x14 ;znak L MOVWF Disp0 ;do displej0 MOVF Low1,W ;mez jednicky MOVWF Disp1 ;do displej1 MOVF Low2,W ;mez desitky CALL MZnaky MOVWF Disp2 ;do displej2 CALL KLV BTFSC STATUS,Z ;neco stisknuto? GOTO Main ;NE, konec BTFSS KlvPort,TlM ;je stisknuto TlMinus? GOTO MLMinus ;ANO BTFSS KlvPort,TlP ;je stisknuto TlPlus? GOTO MLPlus ;ANO BTFSS Priznak,Zapis ;=1? GOTO ModPlus ;zapis do EEPROM CLRF EEADRp ;adresa=0 MOVF Low2,W CALL EWrite INCF EEADRp,F ;adresa+1=1 MOVF Low1,W CALL EWrite BCF Priznak,Zapis ;=0 GOTO ModPlus ;--Low -1 (MIN -40C)-------------------- MLMinus BSF Priznak,Zapis BTFSC Low2,7 ;MSB je VYP? GOTO MLMplus ;NE MOVLW 1 SUBWF Low1,F ;jednicky-1 BTFSC STATUS,C ;zaporne? GOTO Main ;NE SUBWF Low2,F ;desitky-1 BTFSS STATUS,C ;kladne? GOTO MLM1 ;NE MOVLW 9 MOVWF Low1 ;jednicki=9 GOTO Main MLM1 MOVLW 0x80 ;10000000 MOVWF Low2 ;desitky=-0 CLRF Low1 ;jednicky=0 MLMplus MOVF Low2,W SUBLW 0x83 ;0x83-L BTFSS STATUS,C ;kladne? GOTO Main INCF Low1,W ;jednicky+1 MOVWF Low1 SUBLW 9 ;9-L BTFSC STATUS,C ;L>9? GOTO Main ;NE CLRF Low1 ;jednicky=0 INCF Low2,F ;desitky+1 GOTO Main ;--Low +1 (MAX 130C)-------------------- MLPlus BSF Priznak,Zapis BTFSC Low2,7 ;MSB=0? GOTO MLPminus ;NE MOVF Low2,W SUBLW 12 ;12-L BTFSS STATUS,C ;L<=12? GOTO Main ;NE INCF Low1,W ;jednicky+1 MOVWF Low1 SUBLW 9 ;9-L BTFSC STATUS,C ;L>9? GOTO Main ;NE CLRF Low1 ;jednicky=0 INCF Low2,F ;desitky+1 GOTO Main MLPminus MOVLW 1 SUBWF Low1,F ;jednicky-1 BTFSC STATUS,C ;zaporne? GOTO MLP1 MOVLW 9 MOVWF Low1 ;jednicky=9 DECF Low2,F ;desitky-1 MLP1 MOVF Low2,W XORLW 0x80 ;10000000 BTFSS STATUS,Z ;desitky=-0? GOTO Main ;NE MOVF Low1,F BTFSC STATUS,Z ;jednicky neni 0? CLRF Low2 ;desitky=0 GOTO Main ;======================================== MHigh MOVLW 0x10 ;znak (H) MOVWF Disp0 ;do displej0 MOVF Hig1,W ;mez jednicky MOVWF Disp1 ;do displej1 MOVF Hig2,W ;mez desitky CALL MZnaky MOVWF Disp2 ;do displej2 CALL KLV BTFSC STATUS,Z ;neco stisknuto? GOTO Main ;NE konec BTFSS KlvPort,TlM ;je stisknuto TlMinus? GOTO MHMinus ;minus BTFSS KlvPort,TlP ;je stisknuto TlPlus? GOTO MHPlus ;plus BTFSS Priznak,Zapis ;=1? GOTO ModPlus ;zapis do EEPROM MOVLW 2 MOVWF EEADRp ;adresa=2 MOVF Hig2,W CALL EWrite INCF EEADRp,F ;adresa+1=3 MOVF Hig1,W CALL EWrite BCF Priznak,Zapis ;=0 GOTO ModPlus ;--Hig -1 (MIN -40C)-------------------- MHMinus BSF Priznak,Zapis BTFSC Hig2,7 ;MSB je VYP? GOTO MHMplus ;NE MOVLW 1 SUBWF Hig1,F ;jednicky-1 BTFSC STATUS,C ;zaporne? GOTO Main ;NE SUBWF Hig2,F ;desitky-1 BTFSS STATUS,C ;kladne? GOTO MHM1 ;NE MOVLW 9 MOVWF Hig1 ;jednicki=9 GOTO Main MHM1 MOVLW 0x80 ;10000000 MOVWF Hig2 ;desitky=-0 CLRF Hig1 ;jednicky=0 MHMplus MOVF Hig2,W SUBLW 0x83 ;83-L BTFSS STATUS,C ;kladne? GOTO Main INCF Hig1,W ;jednicky+1 MOVWF Hig1 SUBLW 9 ;9-L BTFSC STATUS,C ;L>9? GOTO Main ;NE CLRF Hig1 ;jednicky=0 INCF Hig2,F ;desitky+1 GOTO Main ;--Hig +1 (MAX 130C)-------------------- MHPlus BSF Priznak,Zapis BTFSC Hig2,7 ;MSB=0? GOTO MHPminus ;NE MOVF Hig2,W SUBLW 12 ;12-L BTFSS STATUS,C ;L<=12? GOTO Main ;NE INCF Hig1,W ;jednicky+1 MOVWF Hig1 SUBLW 9 ;9-L BTFSC STATUS,C ;L>9? GOTO Main ;NE CLRF Hig1 ;jednicky=0 INCF Hig2,F ;desitky+1 GOTO Main MHPminus MOVLW 1 SUBWF Hig1,F ;jednicky-1 BTFSC STATUS,C ;zaporne? GOTO MHP1 MOVLW 9 MOVWF Hig1 ;jednicky=9 DECF Hig2,F ;desitky-1 MHP1 MOVF Hig2,W XORLW 0x80 ;10000000 BTFSS STATUS,Z ;desitky=-0? GOTO Main ;NE MOVF Hig1,F BTFSC STATUS,Z ;jednicky neni 0? CLRF Hig2 ;desitky=0 GOTO Main ;======================================== MProg MOVLW 0x18 ;znak (P) MOVWF Disp0 ;do dislpej0 MOVF Prog,W ;cislo programu MOVWF Disp1 ;do displej1 MOVLW 0x20 ;zadny znak MOVWF Disp2 ;do displej2 CALL KLV BTFSC STATUS,Z ;neco stisknuto? GOTO Main ;NE konec BTFSS KlvPort,TlM ;je stisknuto TlMinus? GOTO MPMinus ;minus BTFSS KlvPort,TlP ;je stisknuto TlPlus? GOTO MPPlus ;plus BTFSS Priznak,Zapis ;=1? GOTO ModPlus ;zapis do EEPROM MOVLW 8 MOVWF EEADRp ;adresa=8 MOVF Prog,W CALL EWrite BCF Priznak,Zapis ;=0 GOTO ModPlus ;--Prog -1 (MIN 0)----------------------- MPMinus BSF Priznak,Zapis ;=1 MOVF Prog,F BTFSS STATUS,Z ;=0? DECF Prog,F ;NE, -1 GOTO Main ;--Prog +1 (MAX 5)----------------------- MPPlus BSF Priznak,Zapis ;=1 MOVF Prog,W XORLW 5 BTFSS STATUS,Z ;=5? INCF Prog,F ;NE, +1 GOTO Main ;======================================== PROG0 BSF PORTA,ReLo ;VYP RLo BSF PORTA,ReHi ;VYP RHi GOTO NulD ;---------------------------------------- PROG1 CALL HdoAB ; Ovladani ReleHig s hysterezi CALL MENSI ; BTFSC STATUS,C ;TeplotaL? BCF PORTA,ReHi ;NE, ReleHi=0 GOTO NulD ;---------------------------------------- PROG2 CALL HdoAB ;priprava pro porovnani Hig meze CALL VETSI ;Teplota>H C=0, jinak C=1 CALL ZVTHig ;C=0 CYKLOVAC ReleHi, C=1 VYP ReleHi CALL LdoAB ;priprava pro porovnani L meze CALL VETSI ;Teplota>H C=0, jinak C=1 CALL ZVTLow ;C=0 CYKLOVAC ReleLo, C=1 VYP ReleLo GOTO NulD ;konec PROG ;---------------------------------------- PROG3 CALL HdoAB CALL MENSI ;TeplotaH CALL ZVTHig ;C=0 CYKLOVAC ReleHi, C=1 VYP ReleHi CALL LdoAB CALL MENSI ;TeplotaH BTFSS STATUS,C ;NE GOTO ReZAV ;ANO CALL LdoAB CALL MENSI ;TTr CALL ZVTHig CALL TrendAB CALL MENSI ;T