Rem +--------------------------------------------------------+ Rem | | Rem | D E F I N E S for ALL source file | Rem | | Rem | | Rem +--------------------------------------------------------+ Rem VAR sw "Switch for alternating LCD displays" Rem VAR j "Current time Parameter Set Number" Rem VAR LastJ "Last time paramter set number" Rem VAR c "Input byte" Rem VAR c1 "Input byte" Rem VAR tsoll [5], skp [5] Rem VAR thi [5], hhhi [5], mmhi [5], dayhi [5] Rem VAR tlow [5], hhlow [5], mmlow [5], daylow [5] Rem VAR hhein [5], mmein [5], dayein [5], dtein [5] Rem VAR hhaus [5], mmaus [5], dayaus [5], dtaus [5] Rem VAR wt, hh, mm, day, mnat, t "Current Date/Time/Temp" Rem VAR tnt "Current Temp * 10 (for 24x7 history)" Rem VAR i "loop/count variable" Rem VAR XC[14], LL[14], UL[14] "arrays to be DIM'ed for INPUT module" Rem +--------------------------------------------------------+ Rem | V5 main program Initialisation | Rem | | Rem | sets mtop for HW-Clock firmware to 3FF0 to preserve | Rem | the batterie backed RAM 4000h - 5FFFH | Rem | Activate the alternate output routine (dbx(19h) = 40h | Rem | inits RTC at 6003H | Rem | inits PIA, relais & LCD, inits variables | Rem | | Rem | | Rem +--------------------------------------------------------+ 10 mtop = 16300 20 dby(19H) = 40H 30 call 6003H 40 string 340,40 45 DIM XC(14), LL(14), UL(14) 49 REM ** APPLICATION ROM Version 2/2/95 V5 ** Rem VARDEL XC, UL, LL Rem VAR PwFail, Heat_Ein 50 gosub 1800 55 xby(0C800H) = xby(0c800H).and.0FEH 60 sw = 0 70 lastj = -1 : pwfail = 0 : Heat_Ein = 0 Rem +--------------------------------------------------------+ Rem | Decide wether a coldstart was done or a power | Rem | failure recovery caused the restart | Rem | Init or reload variables | Rem +--------------------------------------------------------+ 80 c = xby(0C802H).AND.4 90 if c = 0 then gosub 6200 : pwfail = pwfail + 1 : goto 230 95 print @ "Coldstart", Rem VARDEL PwFail, Heat_Ein Rem +--------------------------------------------------------+ Rem | init the 6 sets of temperatur and time related | Rem | variables. set 0 and 1 is initialised to the | Rem | base values: 5C 00:00 - 24:00 Mo - So | Rem | 20C 06:00 - 10:00 Fr - So | Rem | save variables in non-volatile RAM | Rem | init of the LCD messages $(2)..$(5) | Rem +--------------------------------------------------------+ 100 for i = 0 to 5 110 Tsoll (i) = 0 : skp (i) = 0 120 THi (i) = 0 : HhHi (i) = 0 : MmHi (i) = 0 : DayHi (i) = 1 130 TLow (i) = 99 : HhLow (i) = 0 : MmLow (i) = 0 : DayLow (i) = 1 140 HHein (i) = 0 : MMein (i) = 0 : DAYEin (i) = 1 : dtein (i) = 10000 150 HHaus (i) = 0 : MMaus (i) = 0 : DAYAus (i) = 1 : dtaus (i) = 10000 160 next i 170 Tsoll (0) = 5 180 HHein (0) = 0 : DAYEin (0) = 1 : dtein (0) = 10000 190 HHaus (0) = 24 : DAYAus (0) = 7 : dtaus (0) = 72400 200 Tsoll (1) = 20 210 HHein (1) = 6 : DAYEin (1) = 5 : dtein (1) = 50600 220 HHaus (1) = 10 : DAYAus (1) = 7 : dtaus (1) = 71000 225 gosub 6000 230 $(2) = ". TEMP ..,.C TT DD/MM Ein: TT HH:MM" 240 $(3) = " SOLL ..,.C S. HH:MM Aus: TT HH:MM" 250 $(4) = ". TEMP ..,.C Pf .. Min ..,.C TT HH:MM" 260 $(5) = " SOLL ..,.C On HH:MM Max ..,.C TT HH:MM" Rem +--------------------------------------------------------+ Rem | move the centigrade symbol into the LCD messages | Rem | init the day of week name array | Rem +--------------------------------------------------------+ 270 asc($(2),12)=0DFH 280 asc($(3),12)=0DFH 290 asc($(4),12)=0DFH : asc($(4),31)=0DFH 300 asc($(5),12)=0DFH : asc($(5),31)=0DFH 310 $(6) = "MoDiMiDoFrSaSo" Rem +--------------------------------------------------------+ Rem | get actual temperature into T | Rem | get time to HH & MM and day of week into WT | Rem | datim is a combination of weekday 1 digit msd | Rem | hour 2 digits | Rem | minutes 2 digits lsd | Rem | HeatTm contains Timestamp, used for on/off time calc| Rem | get current time (hh/mm) from hardware clock | Rem | firmware routine (and mon/day) | Rem +--------------------------------------------------------+ Rem VAR DaTim 400 gosub 2000 402 call 6009H : HH = xby (mtop+22) : MM = xby (mtop+21) 404 mnat = xby (mtop+24) : day = xby (mtop+23) 406 gosub 2200 : gosub 2300 410 datim = wt * 10000 + hh * 100 + mm Rem +--------------------------------------------------------+ Rem | store temperatur ( value 0 .. 255 for 0 .. 25,5C) | Rem | in 4400H - 4500H to save the pattern | Rem +--------------------------------------------------------+ 412 if MM <> 0 goto 428 414 tnt = t * 10 416 if tnt > 255 then tnt = 255 418 if tnt < 0 then tnt = 0 420 xby (4400H + (wt-1) * 24 + hh) = tnt Rem +--------------------------------------------------------+ Rem | check for input switch set and call input routines | Rem | if activated | Rem +--------------------------------------------------------+ 428 c = xby(0C802H).AND.4 430 if c <> 0 then gosub 5000 Rem +--------------------------------------------------------+ Rem | check which "set" is currently active by comparing | Rem | DATIM to the start & end times of any set. The | Rem | first set found is used, default is set 0 | Rem | j is set to the set number | Rem +--------------------------------------------------------+ Rem VAR UpLim 440 j = 0 450 for i = 5 to 1 step -1 460 if tsoll(i) = 0 then goto 480 462 if dtaus(i) < dtein(i) then uplim=dtaus(i)+70000 else uplim=dtaus(i) 470 if ((dtein (i) < datim).AND.(datim < uplim)) then j = i 480 next i Rem VARDEL DaTim, UpLim Rem +--------------------------------------------------------+ Rem | check if the selected set (j) id the same as the | Rem | last set (jlast). If different, a new set was | Rem | selected and therefor the min/max values get | Rem | reset. | Rem +--------------------------------------------------------+ 490 if j = lastj goto 530 500 if lastj = -1 goto 530 510 dayhi (lastj)=1 : thi (lastj) =0 : hhhi (lastj)=0 :mmhi (lastj)=0 520 daylow (lastj)=1 : tlow (lastj) =99 : hhlow (lastj)=0 :mmlow (lastj)=0 530 lastj = j Rem VARDEL LastJ Rem +--------------------------------------------------------+ Rem | check to see if current temperature is larger than | Rem | recorded maximum or less than recorded minimum. If | Rem | so, update min & max values | Rem +--------------------------------------------------------+ 540 if t>THi (j) then THi (j)= t: HHHi (j)=HH: MMHi (j)=MM: DAYHi (j) = WT 550 if t than desired value. If | Rem | so, display a "-" and switch off heating, otherwise | Rem | display a "+" and switch on. | Rem +--------------------------------------------------------+ Rem VAR Heat_Ein Rem Switch off 560 if t < tsoll (j) goto 600 570 asc($(3),1) = 2DH 580 asc($(5),1) = 2DH 582 xby(0C800H) = xby(0c800H).and.0FEH 590 goto 620 Rem Switch On 600 asc($(3),1) = 2BH 610 asc($(5),1) = 2BH 612 xby(0C800H) = xby(0c800H).or.1 614 Heat_Ein = Heat_Ein + 10 Rem +--------------------------------------------------------+ Rem | display first or 2nd LCD message set based on SW | Rem | variable and keep on looping | Rem +--------------------------------------------------------+ 620 if sw = 0 then gosub 1000 else gosub 1200 630 goto 400 Rem +--------------------------------------------------------+ Rem | Display 1st set of LCD message ($2) and $(3) | Rem +--------------------------------------------------------+ Rem VAR IV, O, X, Y, PwFail 1000 sw = 1 : X = 0 : Y = 0 : gosub 1950 : $(1) = $(2) 1005 iv = j : o = 1 : gosub 1405 1010 iv = T : o = 8 : gosub 1410 1012 iv = WT : o = 14 : gosub 1415 1014 iv = day : o = 17 : gosub 1400 1016 iv = mnat : o = 20 : gosub 1400 1020 iv = Dayein(j) : o = 33 : gosub 1415 1030 iv = HHein (j) : o = 36 : gosub 1400 1040 iv = MMein (j) : o = 39 : gosub 1400 1050 $(7)=$(1) 1060 $(1) = $(3) 1062 iv = skp (j) : o = 15 : gosub 1405 1064 iv = HH : o = 17 : gosub 1400 1066 iv = MM : o = 20 : gosub 1400 1080 iv = tsoll (j) : o = 8 : gosub 1410 1090 iv = Dayaus(j) : o = 33 : gosub 1415 1100 iv = HHaus (j) : o = 36 : gosub 1400 1110 iv = MMaus (j) : o = 39 : gosub 1400 1120 Print @ $(7),$(1), 1130 Return Rem +--------------------------------------------------------+ Rem | Display 2nd set of LCD message ($4) and ($5) | Rem +--------------------------------------------------------+ 1200 sw = 0 : X = 0 : Y = 0 : gosub 1950 : $(1) = $(4) 1205 iv = j : o = 1 : gosub 1405 1210 iv = T : o = 8 : gosub 1410 1215 iv = PwFail : o = 17 : gosub 1400 1220 iv = tlow (j) : o = 27 : gosub 1410 1230 iv = Daylow(j) : o = 33 : gosub 1415 1240 iv = HHlow (j) : o = 36 : gosub 1400 1250 iv = MMlow (j) : o = 39 : gosub 1400 1260 $(7)=$(1) 1270 $(1) = $(5) 1275 iv = int (Heat_Ein / 60) 1277 iv = iv - (int(iv/60)*60) : o = 20 : gosub 1400 1280 iv = int (Heat_Ein / 3600) : o = 17 : gosub 1400 1290 iv = tsoll (j) : o = 8 : gosub 1410 1300 iv = thi (j) : o = 27 : gosub 1410 1310 iv = Dayhi (j) : o = 33 : gosub 1415 1320 iv = HHhi (j) : o = 36 : gosub 1400 1330 iv = MMhi (j) : o = 39 : gosub 1400 1340 Print @ $(7),$(1), 1350 Return Rem +--------------------------------------------------------+ Rem | 1400: display a 2 digit value at $(1) offset o | Rem | 1405: display a 1 digit value at $(1) offset o | Rem | 1410: display a temp value (2 digits + decimal) | Rem | 1415: display a weekday name at $(1) | Rem +--------------------------------------------------------+ Rem IMPORT IV, O Rem VAR G, G1 1400 g=int(iv/10) : asc($(1),o)=g+48 : asc($(1),o+1)=iv-(g*10)+48 : return 1405 asc($(1),o)=iv+48 : return 1410 g1=(iv-int(iv))*10 : iv=int(iv) : gosub 1400 1412 asc($(1),o+3)=g1+48 : return 1415 if ((iv<1).or.(iv>7)) then asc($(1),o)=120 : asc($(1),o+1)=120: return 1416 ASC($(1),o)=ASC($(6),(iv-1)*2+1) : ASC($(1),o+1)=ASC($(6),(iv-1)*2+2) 1420 Return Rem VARDEL G, G1 Rem EndImport Rem VARDEL IV, O, X, Y, Heat_Ein, PwFail rem +--------------------------------------------------------+ rem | LCD I/O Package | rem |Subroutines: | rem | set cursor adr in LCD 1950 | rem | conf PIA & initialize LCD 1800 | rem +--------------------------------------------------------+ rem +--------------------------------------------------------+ rem | configure PIA & init of LCD : stuff jump instr. | rem | into 403CH for "Print @" Command (I/O to user dev.)| rem +--------------------------------------------------------+ Rem VAR A 1800 xby (0C803H) = 89H 1820 xby(4094H) = 30H : call 7250H : A = 1/2 1830 xby(4094H) = 30H : call 7250H : A = 1/2 1840 xby(4094H) = 30H : call 7250H : A = 1/2 1850 xby(4094H) = 38H : call 7250H : A = 1/2 1860 xby(4094H) = 0FH : call 7250H : A = 1/2 1870 xby(4094H) = 01H : call 7250H : A = 1/2 1880 xby(4094H) = 06H : call 7250H : A = 1/2 1890 xby(403CH) = 02H 1900 xby(403DH) = 71H 1910 xby(403EH) = 0B0H 1920 dby(24h) = dby(24H).OR.80H 1930 return Rem VARDEL A rem +--------------------------------------------------------+ rem | set cursor adr on LCD | rem | input X = offset 0 .. 39, Y = 0/1 | rem +--------------------------------------------------------+ Rem VAR I9, X, Y 1950 i9 = (X + (Y * 64)).or.80H 1960 xby(4094H)=i9 : call 7250H 1970 return Rem VARDEL I9, X, Y Rem +--------------------------------------------------------+ Rem | GetTemp Vers. 26.10.92 | Rem | Input: none | Rem | Output: T contains temperature | Rem +--------------------------------------------------------+ Rem IMPORT T Rem VAR K9, I9, X9, J9 2000 FOR I9=4080H TO 408CH : XBY(I9)=0 : NEXT I9 2020 XBY(4090H)=10 2030 XBY(4091H)=40H 2040 XBY(4092H)=80H 2060 CALL 7040H 2070 T=0 2080 FOR K9=0 TO 2 2090 X9=0 2100 FOR J9=0 TO 3 2110 I9=XBY(4081H+J9+K9*4) 2120 IF (I9.AND.2) > 0 then X9=X9+2**(3-J9) 2140 NEXT J9 2150 T=T*10+X9 2160 NEXT K9 2170 T=T/10 2180 Return Rem VARDEL K9, I9, X9, J9 Rem EndImport