Samogradnja: Akvarijski krmilnik Cubicus 2002  2. del

Programska oprema


V drugem delu opisa akvarijskega krmilnika Cubicus 2002 sledi opis programske opreme. Programska oprema vključuje:

Razvojno okolje za C-Control- Basic

Skupaj s C-Control osnovno enoto dobimo na eni disketi tudi programsko opremo za razvoj aplikacije. Omenjeno programsko opremo instaliramo na računalnik in že lahko pričnemo z delom. Na PC-ju napišemo program v Basicu, ki ga prevedemo in če ni nobenih napak ga  preko serijskega vmesnika prenesemo v enoto C-Control Unit. Program se naloži v EEPROM, kjer ostane zapisan za nedoločen čas.

Program Ccew32d, ki predstavlja razvojno okolje je narejen le  v nemškem jeziku, kar pa ne predstavlja veliki problem , saj ga uporabljamo le za:

Štiri besede nemškega jezika se lahko naučimo, tudi če nam je ta jezik popolnoma tuj.

Aplikacija v Basicu

Aplikacija je enostavno ena sama datoteka s končnico BAS, kjer je zapisan naš program. Razvojno okolje in priročniki vključujejo dovolj podrobna navodila za pisanje programa, da pa bi bralec hitreje pridobil vtis o enostavnosti in primernosti tega načina izdelave aplikacije za krmiljenje morskega akvarija, pa prilagam izvorno kodo za mojo aplikacijo, ki je precej podrobno razložena v nadaljevanju članka.

Programska oprema na PC ju za branje in prikaz  grafov.

Profesionalni akvarijski krmilniki imajo tudi programsko opremo, ki se instalira na PC računalnik in omogoča grafične prikaze za PH, redox, temperaturo in ostale merjene veličine. Za Cubicus 2002 takega programe nisem napisal, je pa možno z enostavnim terminalskim programom HyperTerminal , ki ga ima vsak PC računalnik iz Cubicusa prebrati tabelo meritev , ki jo kasneje uvozimo v Excel.

Na PC ju torej potrebujemo HyperTerminal za branje tabel meritev iz Cubicusa in Excel za prikaz grafov.

Moja aplikacija

Jedro pričujočega članka predstavlja razlaga programa v BAS datoteki, ki je trenutno moja aplikacija za krmiljenje morskega akvarija. Možno je naredi tudi mnogo več in povsem druge funkcije, zato je omenjena  aplikacija le ilustracija možnosti krmilnika. Besedo trenutno moja aplikacija sem omenil zato, ker se program stalno spreminja. Nekatere funkcije, ki sem jih že realiziral sem ukinil in dodal nove.

Priložen program bo lažje razumeti, če si najprej pogledate shemo krmiljenja mojega morskega akvarija, ki trenutno vključuje:

Vhod Funkcija Izhod
Ura (RTC), Vklop / Izklop 2 X T5 Actinic Relejski izhod 2
Ura (RTC), Postopno danenje in mračenje 2 X T5 Actinic Analogni izhod (1do10V)
Ura (RTC), Vklop / Izklop 4 X T5 Daylight Relejski izhod 1
Ura (RTC), Postopno danenje in mračenje 4 X T5 Daylight Analogni izhod (1do10V)
Ura (RTC),  Nivo vode Dodajanje izhlapele vode

Računanje in prikaz količine izhlapele vode

Relejski izhod 3

LCD

Ura (RTC), Simulacija plime in oseke z vrtenjem  črpalke Relejski izhod 5, Relejski izhod 7
Tipkovnica Izklop vseh črpalk Relejski izhod 8
Tipkovnica Ročno krmiljenje izhodov  z uporabo tipkovnice vsi relejski izhodi

oba analogna izhoda

Ph adapter Meritev Ph

 

LCD
Temp adapter Meritev temperature

 

LCD
Ph adapter, Temp adapter Grafi meritev, temperature , Ph Serijski port
Tipkovnica Nastavitev ure in datuma

 

Ura

 

Na osnovni shemi krmiljenja mojega akvarija ste verjetno opazili, da imam prosta še dva relejska izhoda. Razlog je v dejstvu, da sem pred kratkim ukinil Nilsen reaktor, za katerega sem potreboval en relejski izhod za mešanje apnene vode in generator valov s preprostim vključevanjem - izključevanjem  črpalk. Prosta izhoda bom lahko koristno uporabil, ker imam kar nekaj idej.

Imam še dosti prostih analognih vhodov, ki čakajo na priključitev merilnika slanosti, itd.

Analognih izhodov pa je bistveno premalo. V načrtu imam kar nekaj projektov , kjer potrebujem analogne izhode. Obstaja tudi rešitev v okviru Cubicus 2002. Z dodatnimi releji se lahko doseže, da en analogni izhod podpira več funkcij, če funkcij ne potrebujemo istočasno. Kot primer naj navedem skupino funkcij, ki si lahko delijo isti analogni izhod: danenje in mračenje zjutraj in zvečer, simulacija lune ponoči, valovanje pa samo podnevi.

3.2 Programska oprema

Izvorna koda je shranjeva v datoteki Cubicus.bas Struktura programa prav gotovo ni zgled sodobnemu načinu programiranja, saj je celoten program le v eni datoteki, kar ni najbolj ugodno iz stališča preglednosti. To je pač omejitev sistema C-Control. Po drugi strani pa boste ugotovili, da je možno zelo hitro razumeti delovanje programske opreme in prilagodti aplikacijo lastnim potrebam.


Definicije

Na začetku datoteke Cubicus.bas  so definicije, katere sem zaradi preglednosti premaknil na posebno stran.


'******************************** Program ******************************************

gosub LCD_INIT
gosub FILE_INIT
baud R9600

delay = OFF
regdis = OFF
page = 0
lasthour = hour
lastday = day
last_refill = 0
refill_count = 0
refill_sum = 0
aso1 = AO1_MAX : aso2 = AO2_MAX : ao1 = aso1 : ao2 = aso2
value2 = 0
r1 = 1 : r2 = 0 : r3 = 0 : r4 = 0 : r5 = 0 : r6 = 0 : r7 = 0 : r8 = 0

param = &H80 + page : gosub LCD_GOTOCHAR : gosub WR_TITLE
pause 50
gosub LCD_CLS
param = &HC0 + page : gosub LCD_GOTOCHAR : gosub WR_TITLE
pause 50
gosub LCD_CLS
param = &H94 + page : gosub LCD_GOTOCHAR : gosub WR_TITLE
pause 50
gosub LCD_CLS
param = &HD4 + page : gosub LCD_GOTOCHAR : gosub WR_TITLE
pause 50
gosub LCD_CLS
 


Na tem mestu se prične glavna zanka programa, ki je znotraj  #LOOP  ......   goto LOOP

Program znotraj tega dela se izvaja vsakih 100 milisekund. V osnovi ta del programske opreme izvede krmilne funkcije, izpiše nove vrednosti meritev na zaslon , preveri stanje tipkovnice in izvede morebitne zahteve podane preko tipk.


#LOOP
pause 5


'
-------------------------------- Regulation ----------------------

time = HOUR*100 + MINUTE

' light 0N and OFF 2 channels

if regdis1 then goto END_AUTO_LIGHT1
if (time >= 728 AND time < 2032) then LIGHT1 = OFF else LIGHT1 = ON
aso1 = AO1_MAX
if (time >= 728 AND time < 800) then aso1 = AO1_MIN + (MINUTE-28)*2 + SECOND/30
if (time >=2000 AND time < 2032) then aso1 = AO1_MAX - (MINUTE*2 + SECOND/30)
if aso1 > AO1_MAX then aso1 = AO1_MAX
if aso1 < AO1_MIN then aso1 = AO1_MIN
ao1 = aso1
goto END_LIGHT1
#END_AUTO_LIGHT1
if value2 = AO1_AUTO_INC then aso1 = aso1 + 1
if value2 = AO1_AUTO_DEC then aso1 = aso1 - 1
if (aso1 = AO1_MAX) AND (value2 = AO1_AUTO_INC) then value2 = 0
if (aso1 = AO1_MIN) AND (value2 = AO1_AUTO_DEC) then value2 = 0
ao1 = aso1
#END_LIGHT1

if regdis2 then goto END_AUTO_LIGHT2
if (time >= 700 AND time < 2100) then LIGHT2 = OFF else LIGHT2 = ON
aso2 = AO2_MAX
if (time >= 700 AND time < 730) then aso2 = AO2_MIN + MINUTE*3 + SECOND/20
if (time >=2030 AND time < 2100) then aso2 = AO2_MAX - ((MINUTE-30)*3 + SECOND/20)
if aso2 > AO2_MAX then aso2 = AO2_MAX
if aso2 < AO2_MIN then aso2 = AO2_MIN
ao2 = aso2
goto END_LIGHT2
#END_AUTO_LIGHT2
if value2 = AO2_AUTO_INC then aso2 = aso2 + 1
if value2 = AO2_AUTO_DEC then aso2 = aso2 - 1
if (aso2 = AO2_MAX) AND (value2 = AO2_AUTO_INC) then value2 = 0
if (aso2 = AO2_MIN) AND (value2 = AO2_AUTO_DEC) then value2 = 0
ao2 = aso2
#END_LIGHT2

' Automatic water refill
if (REFILL = ON) then goto CONTROL_REFILL ' if water pump is active
if regdis3 then goto END_REFILL
'if time > 1400 AND time < 2100 then goto END_REFILL ' refill only during night
if ((MINUTE MOD 15) <> 1 ) then goto END_REFILL
if m7 > 100 then goto END_REFILL ' refill only if water level too low
if refill_count > 48 then goto END_REFILL ' maksimum 24 times
REFILL = ON : store_timer = timer : last_refill = HOUR : goto END_REFILL ' start refill
#CONTROL_REFILL
if ((timer - store_timer) < 10000 ) then goto END_REFILL
refill_count = refill_count + 1
refill_sum = refill_sum + 1
if (regdis3 AND m7 < 100) then store_timer = timer else REFILL = OFF
#END_REFILL

' Ca-Mix
'if not regdis4 then if ((time >= 1900 AND time < 2000 )OR((NOT(time > 1400 AND time < 2100))AND((MINUTE > 10 ) AND (MINUTE < 15 ))) ) then WAVE1 = ON else WAVE1 = OFF
#END_CAMIX

' Wave Maker 2 channels
if regdis5 AND regdis7 then goto END_WAVE ' manual control
if regdis5 then goto WAVE_D1 ' demo1
if regdis7 then goto WAVE_D2 ' demo2

' automatic
if (((HOUR MOD 12) = 7 ) AND (MINUTE = 0 ) AND (SECOND < 20 )) then goto WAVE_F ' 55
if (((HOUR MOD 12) = 7 ) AND (MINUTE = 10) AND (SECOND < 20 )) then goto WAVE_R ' 35
if (((HOUR MOD 12) = 7 ) AND (MINUTE = 20) AND (SECOND < 60 )) then goto WAVE_R '-20
if (((HOUR MOD 12) = 7 ) AND (MINUTE = 30) AND (SECOND < 50 )) then goto WAVE_F ' 30

if (((HOUR MOD 12) = 1 ) AND (MINUTE = 0 ) AND (SECOND < 60 )) then goto WAVE_R '-20
if (((HOUR MOD 12) = 1 ) AND (MINUTE = 10) AND (SECOND < 50 )) then goto WAVE_F '-30
if (((HOUR MOD 12) = 1 ) AND (MINUTE = 20) AND (SECOND < 60 )) then goto WAVE_F ' 55
if (((HOUR MOD 12) = 1 ) AND (MINUTE = 30) AND (SECOND < 10 )) then goto WAVE_R ' 45
goto WAVE_0

#WAVE_D1 ' demo1
if ((MINUTE MOD 4) < 2 ) then goto WAVE_R else goto WAVE_F
goto END_WAVE

#WAVE_D2 ' demo2
if (((MINUTE MOD 12) = 7 ) AND ( SECOND < 20 )) then goto WAVE_F
if (((MINUTE MOD 12) = 8 ) AND ( SECOND < 20 )) then goto WAVE_R
if (((MINUTE MOD 12) = 9 ) AND ( SECOND < 60 )) then goto WAVE_R
if (((MINUTE MOD 12) = 10 ) AND( SECOND < 50 )) then goto WAVE_F

if (((MINUTE MOD 12) = 1 ) AND ( SECOND < 60 )) then goto WAVE_R
if (((MINUTE MOD 12) = 2 ) AND ( SECOND < 45 )) then goto WAVE_F
if (((MINUTE MOD 12) = 3 ) AND ( SECOND < 60 )) then goto WAVE_F
if (((MINUTE MOD 12) = 4 ) AND ( SECOND < 10 )) then goto WAVE_R
goto WAVE_0

#WAVE_0
r5 = OFF
r7 = OFF
goto END_WAVE
#WAVE_R
r5 = ON
r7 = OFF
goto END_WAVE
#WAVE_F
r5 = OFF
r7 = ON
#END_WAVE

' temperature regulator chiller
'if regdis7 then goto END_CHILLER
'value = 150 + (m2*100/100)
'if value > 259 then CHILLER = OFF
'if value < 256 then CHILLER = ON
'#END_CHILLER

#ENDREG


'--------------------------------- Display ----------------------------
define NUM_PAGES 3
on page goto PAGE1, PAGE2, PAGE3
 


Program je prilagojen za LCD velikosti 4 x 20 znakov, sama programska oprema pa je narejena tako, da so oblikovane tri strani izpisa na LCD, med katerimi se pomikamo s tipko NEXT.  Kot ena stran je mišljeno področje LCD 4 x 20 znakov. Običajno je na LCDju prikazana prva stran.

Pa še nekaj komentarjev na izpis prve strani

param = &H80 : gosub LCD_GOTOCHAR  pomeni da nastavimo kurzor na začetek prve vrstice

gosub WR_TIME na mesto kjer je kurzor izpišemo tekst, ki je definiran v subrutini WR_TIME

param = &H8A : gosub LCD_GOTOCHAR  pomeni da nastavimo kurzor na 10 znak  prve vrstice

param =  &Hxy pomeni nastavitev pozicije kurzorja za tekstovne LCDje v šestnajstiškem sistemu

x definira vrstico (8 prva, C druga, 9 tretja, D četrta)

y definita stolpec (1 prvi, ... 9 deveti, A deseti, ...)



#PAGE1
param = &H80 : gosub LCD_GOTOCHAR : gosub WR_TIME
param = &H8A : gosub LCD_GOTOCHAR : gosub WR_DATE

param = &HC0 : gosub LCD_GOTOCHAR : gosub WR_RELAY
param = SPACE : gosub LCD_WRITECHAR
if m7 > 100 then param = SPACE else param = Lv : gosub LCD_WRITECHAR
value = 3050 + m6*58 : gosub WR_VOLTAGE1

param = &H94 : gosub LCD_GOTOCHAR
value = 150 + (m2*100/100) : gosub WR_TEMP
param = SPACE : gosub LCD_WRITECHAR
'value = 150 + (m3*100/100) : gosub WR_TEMP
param = SPACE : gosub LCD_WRITECHAR
value = 500 + (m1*PH_KALIB/50) : gosub WR_PH

param = &HD4 : gosub LCD_GOTOCHAR
value = refill_count : gosub WR_CONSUMPTION
param = SPACE : gosub LCD_WRITECHAR
value = refill_sum : gosub WR_CONSUMPTION
goto ENDPRINT

#PAGE2
param = &H80 : gosub LCD_GOTOCHAR
param = NULL + 1 : gosub LCD_WRITECHAR
value = m1*98 : gosub WR_VOLTAGE
param = SPACE : gosub LCD_WRITECHAR
param = NULL + 2 : gosub LCD_WRITECHAR
value = m2*98 : gosub WR_VOLTAGE

param = &HC0 : gosub LCD_GOTOCHAR
param = NULL + 3 : gosub LCD_WRITECHAR
value = m3*98 : gosub WR_VOLTAGE
param = SPACE : gosub LCD_WRITECHAR
param = NULL + 4 : gosub LCD_WRITECHAR
value = m4*98 : gosub WR_VOLTAGE

param = &H94 : gosub LCD_GOTOCHAR
param = NULL + 5 : gosub LCD_WRITECHAR
value = m5*98 : gosub WR_VOLTAGE
param = SPACE : gosub LCD_WRITECHAR
param = NULL + 6 : gosub LCD_WRITECHAR
value = m6*73 : gosub WR_VOLTAGE1

param = &HD4 : gosub LCD_GOTOCHAR
param = NULL + 7 : gosub LCD_WRITECHAR
value = m7*98 : gosub WR_VOLTAGE
param = SPACE : gosub LCD_WRITECHAR
param = NULL + 8 : gosub LCD_WRITECHAR
value = m8*98 : gosub WR_VOLTAGE

goto ENDPRINT

#PAGE3
param = &H80 : gosub LCD_GOTOCHAR : gosub WR_FILEFREE
param = &H88 : gosub LCD_GOTOCHAR : gosub WR_RELAY
param = &HC0 : gosub LCD_GOTOCHAR
value = aso1 : gosub WR_AO
param = SPACE : gosub LCD_WRITECHAR
value = aso2 : gosub WR_AO
#ENDPRINT


'--------------------------------- Read Keyboard -------------------
if delay then pause KEYB_DELAY*2 : delay = OFF
gosub READKEYBOARD
if page = 2 then goto KEY_PAGE2
if param = KEY_1 then gosub TEST_RELAY1
if param = KEY_2 then gosub TEST_RELAY2
'if param = KEY_3 then gosub TEST_RELAY3
if param = KEY_4 then gosub TEST_RELAY4
if param = KEY_5 then gosub TEST_RELAY5
'if param = KEY_6 then gosub TEST_RELAY6
if param = KEY_7 then gosub TEST_RELAY7
if param = KEY_8 then gosub TEST_RELAY8
if param = KEY_9 then gosub RESET_REFILL
goto END_KEY_PAGE2
#KEY_PAGE2
if param = KEY_1 then gosub INC_AO1
if param = KEY_2 then gosub INCF_AO1
'if param = KEY_3 then gosub DEC_AO1
if param = KEY_4 then gosub INC_AO2
if param = KEY_5 then gosub INCF_AO2
'if param = KEY_6 then gosub DEC_AO2
#END_KEY_PAGE2
if param = KEY_CROSS then gosub TEST_RELAY_END
if param = KEY_ASTERIX then gosub MAIN_MENU
if param = KEY_0 then gosub NEXT_PAGE

'--------------------------------- Events --------------------------
if hour <> lasthour then gosub LOG ' time based - once every one hour
if day <> lastday then gosub NEW_DAY
if rxd then gosub DUMP ' event based - serial communication
goto LOOP

#NEXT_PAGE
gosub LCD_INIT
page = page + 1 : if page > NUM_PAGES-1 then page = 0 : delay = ON :return
#TEST_RELAY1
BEEP 400,10,0 : if regdis1 then tog r1 else regdis1 = ON : return
#TEST_RELAY2
BEEP 400,10,0 : if regdis2 then tog r2 else regdis2 = ON : return
#TEST_RELAY3
BEEP 400,10,0 : if regdis3 then tog r3 else regdis3 = ON : return
#TEST_RELAY4
BEEP 400,10,0 : if regdis4 then tog r4 else regdis4 = ON : store_timer = timer :return
#TEST_RELAY5
BEEP 400,10,0 : if regdis5 then tog r5 else regdis5 = ON : return
#TEST_RELAY6
BEEP 400,10,0 : if regdis6 then tog r6 else regdis6 = ON : return
#TEST_RELAY7
BEEP 400,10,0 : if regdis7 then tog r7 else regdis7 = ON : return
#TEST_RELAY8
BEEP 400,10,0 : tog r8 :
return
#INC_AO1
BEEP 400,5,0 : aso1 = aso1 + 1 : ao1 = aso1 : return
#INC_AO2
BEEP 400,5,0 : aso2 = aso2 + 1 : ao2 = aso2 : return
#INCF_AO1
BEEP 400,5,0
if aso1 <= AO1_MIN then value2 = 1 else value2 = 2 : return
#INCF_AO2
BEEP 400,5,0
if aso2 <= AO2_MIN then value2 = 3 else value2 = 4 : return
#DEC_AO1
BEEP 400,5,0 : aso1 = aso1 - 1 : ao1 = aso1 : return
#DEC_AO2
BEEP 400,5,0 : aso2 = aso2 - 1 : ao2 = aso2 : return
#RESET_REFILL
BEEP 400,10,0 : refill_count = 0 : refill_sum = 0 : return
#TEST_RELAY_END
BEEP 400,20,0 : regdis = 0 :gosub LCD_INIT:return
#NEW_DAY
refill_count = 0 : lastday = day : return

#MAIN_MENU
define NUM_MENUS 2
page = 0 ' use the same variable as for display
goto NEXT_MENU1
#NEXT_MENU
page = page + 1 : if page > NUM_MENUS-1 then page = 0
#NEXT_MENU1
gosub LCD_CLS
param = &H80 : gosub LCD_GOTOCHAR : on page gosub WR_SETTIME, WR_SETLOG
pause KEYB_DELAY*2
#MAIN_MENU1
gosub READKEYBOARD
if param = KEY_CROSS then goto MAIN_MENU_EXIT
if param = KEY_ASTERIX then on page gosub SET_TIME, SET_LOG
if param = KEY_0 then goto NEXT_MENU
goto MAIN_MENU1
#MAIN_MENU_EXIT
page = 0
gosub LCD_CLS
return

#LOG
lasthour = hour
open# for append
if filefree < 10 then goto LOG_ERASE
value_a = year*12+month : value_b = day : print# value
time_a = hour : time_b = minute : print# time
value1a = m2 : value1b = m3 : print# value1
value2a = m1 : value2b = m4 : print# value2
goto LOG_END
#LOG_ERASE
close#
open# for write
#LOG_END
close#
return

#DUMP
get a
print
print " Measurements"
open# for read
#DUMPNEXT
if eof then goto DUMPEND : input# value
if eof then goto DUMPEND : input# time
if eof then goto DUMPEND : input# value1
if eof then goto DUMPEND : input# value2
print value_b;"/";value_a mod 12;"/";value_a/12;" ";time_a;":";time_b;",",
yz = 150 + value1a*100/100
print yz/10;".";yz mod 10;",",
yz = 150 + value1b*100/100
print yz/10;".";yz mod 10;",",
yz = 500 + value2a*PH_KALIB/50
print yz/100;".";(yz mod 100)/10;(yz mod 100) mod 10
goto DUMPNEXT
#DUMPEND
close#
return

#FILE_INIT
open# for read
time_a = 12
#FILENEXT
if eof then goto FILEEND : input# value
if eof then goto FILEEND : input# time
if eof then goto FILEEND : input# value1
if eof then goto FILEEND : input# value2
goto FILENEXT
#FILEEND
second = 0
minute = 30
hour = time_a
day = value_b
month = value_a mod 12
year = value_a/12
close#
if year > 0 then goto FILEEND1
minute = 35
hour = 19
day = 2
month = 11
year = 3
#FILEEND1
return

#SET_LOG
param = &HC0 : gosub WR_SETLOG_OP
#SET_LOG1
gosub READKEYBOARD
if param = KEY_CROSS then return
if param = KEY_1 then goto SET_LOG_ERASE
goto SET_LOG1
#SET_LOG_ERASE
open# for write : close#
#SET_LOG_END
BEEP 400,10,0
pause KEYB_DELAY
return

#WR_SETLOG_OP
param = &HC0
gosub LCD_GOTOCHAR
param = NULL + 1 : gosub LCD_WRITECHAR
param = MINUS : gosub LCD_WRITECHAR
param = Ev : gosub LCD_WRITECHAR
param = R_ : gosub LCD_WRITECHAR
param = A_ : gosub LCD_WRITECHAR
param = S_ : gosub LCD_WRITECHAR
param = E_ : gosub LCD_WRITECHAR
return

#SET_TIME
param = &H8A + 2 : gosub LCD_GOTOCHAR : param = COLON : gosub LCD_WRITECHAR
y = &H8A : z = 23 : gosub ENTER_NUMBER : time_a = a ' Hour
y = &H8A + 3 : z = 59 : gosub ENTER_NUMBER : time_b = a ' Minute
param = &HC0 + 2 : gosub LCD_GOTOCHAR : param = PERIOD : gosub LCD_WRITECHAR
param = &HC0 + 5 : gosub LCD_GOTOCHAR : param = PERIOD : gosub LCD_WRITECHAR
y = &HC0 : z = 31 : gosub ENTER_NUMBER : value_b = a ' Day
y = &HC0 + 3 : z = 12 : gosub ENTER_NUMBER : value_a = a ' Month
y = &HC0 + 6 : z = 99 : gosub ENTER_NUMBER : value1a = a ' Year
#SET_TIME1
gosub READKEYBOARD
if param = KEY_CROSS then return
if param = KEY_ASTERIX then goto SET_TIME2
pause KEYB_DELAY
goto SET_TIME1
#SET_TIME2
hour = time_a
minute = time_b
second = 0
day = value_b
month = value_a
year = value1a
BEEP 400,10,0
pause KEYB_DELAY
return


#ENTER_NUMBER ' parameters y ... position on display
' z ... maks number
' result a ... number
a=0
param = y : gosub LCD_GOTOCHAR
#ENTER_NUMBER1
gosub READKEYBOARD
if param > (z/10) then goto ENTER_NUMBER1
a = param * 10
param = NULL + param : gosub LCD_WRITECHAR
pause KEYB_DELAY
#ENTER_NUMBER2
gosub READKEYBOARD
if (a + param) > z then goto ENTER_NUMBER2
a = a + param
param = NULL + param : gosub LCD_WRITECHAR
pause KEYB_DELAY
return

#WR_TITLE
param = Cv : gosub LCD_WRITECHAR ' Cubicus Ver 2.7
param = U_ : gosub LCD_WRITECHAR
param = B_ : gosub LCD_WRITECHAR
param = I_ : gosub LCD_WRITECHAR
param = C_ : gosub LCD_WRITECHAR
param = U_ : gosub LCD_WRITECHAR
param = S_ : gosub LCD_WRITECHAR
param = SPACE : gosub LCD_WRITECHAR
param = Vv : gosub LCD_WRITECHAR
param = E_ : gosub LCD_WRITECHAR
param = R_ : gosub LCD_WRITECHAR
param = SPACE : gosub LCD_WRITECHAR
param = NULL + 2 : gosub LCD_WRITECHAR
param = PERIOD : gosub LCD_WRITECHAR
param = NULL + 7 : gosub LCD_WRITECHAR
return

#WR_TIME
param = NULL + hour / 10 : gosub LCD_WRITECHAR
param = NULL + hour mod 10 : gosub LCD_WRITECHAR
param = COLON : gosub LCD_WRITECHAR
param = NULL + minute / 10 : gosub LCD_WRITECHAR
param = NULL + minute mod 10 : gosub LCD_WRITECHAR
param = COLON : gosub LCD_WRITECHAR
param = NULL + second / 10 : gosub LCD_WRITECHAR
param = NULL + second mod 10 : gosub LCD_WRITECHAR
return

#WR_DATE
param = NULL + day / 10 : gosub LCD_WRITECHAR
param = NULL + day mod 10 : gosub LCD_WRITECHAR
param = PERIOD : gosub LCD_WRITECHAR
param = NULL + month / 10 : gosub LCD_WRITECHAR
param = NULL + month mod 10 : gosub LCD_WRITECHAR
param = PERIOD : gosub LCD_WRITECHAR
param = NULL + year / 10 : gosub LCD_WRITECHAR
param = NULL + year mod 10 : gosub LCD_WRITECHAR
return

#WR_SETTIME
param = Sv : gosub LCD_WRITECHAR ' Set Time
param = E_ : gosub LCD_WRITECHAR
param = T_ : gosub LCD_WRITECHAR
param = SPACE : gosub LCD_WRITECHAR
param = Tv : gosub LCD_WRITECHAR
param = I_ : gosub LCD_WRITECHAR
param = M_ : gosub LCD_WRITECHAR
param = E_ : gosub LCD_WRITECHAR
return

#WR_SETLOG
param = Sv : gosub LCD_WRITECHAR ' Set Log
param = E_ : gosub LCD_WRITECHAR
param = T_ : gosub LCD_WRITECHAR
param = SPACE : gosub LCD_WRITECHAR
param = Lv : gosub LCD_WRITECHAR
param = O_ : gosub LCD_WRITECHAR
param = G_ : gosub LCD_WRITECHAR
return

#WR_FILEFREE
value = FILEFREE
param = SPACE : gosub LCD_WRITECHAR
param = NULL + value/1000 : gosub LCD_WRITECHAR : value = value mod 1000
param = NULL + value/100 : gosub LCD_WRITECHAR : value = value mod 100
param = NULL + value/10 : gosub LCD_WRITECHAR : value = value mod 10
param = NULL + value : gosub LCD_WRITECHAR
param = SPACE : gosub LCD_WRITECHAR
param = Wv : gosub LCD_WRITECHAR
param = SPACE : gosub LCD_WRITECHAR
return

#WR_VOLTAGE
param = SPACE : gosub LCD_WRITECHAR
param = NULL + value/5000 : gosub LCD_WRITECHAR : value = value mod 5000
param = PERIOD : gosub LCD_WRITECHAR
param = NULL + value/500 : gosub LCD_WRITECHAR : value = value mod 500
param = NULL + value/50 : gosub LCD_WRITECHAR :
param = SPACE : gosub LCD_WRITECHAR
param = Vv : gosub LCD_WRITECHAR
param = SPACE : gosub LCD_WRITECHAR
return

#WR_VOLTAGE1
param = SPACE : gosub LCD_WRITECHAR
param = NULL + value/10000 : gosub LCD_WRITECHAR : value = value mod 10000
param = NULL + value/1000 : gosub LCD_WRITECHAR : value = value mod 1000
param = PERIOD : gosub LCD_WRITECHAR
param = NULL + value/100 : gosub LCD_WRITECHAR
param = SPACE : gosub LCD_WRITECHAR
param = Vv : gosub LCD_WRITECHAR
param = SPACE : gosub LCD_WRITECHAR
return

#WR_TEMP
param = NULL + value/100 : gosub LCD_WRITECHAR : value = value mod 100
param = NULL + value/10 : gosub LCD_WRITECHAR : value = value mod 10
param = PERIOD : gosub LCD_WRITECHAR
param = NULL + value : gosub LCD_WRITECHAR
param = DEG : gosub LCD_WRITECHAR
param = Cv : gosub LCD_WRITECHAR
return

#WR_PH
param = NULL + value/100 : gosub LCD_WRITECHAR : value = value mod 100
param = PERIOD : gosub LCD_WRITECHAR
param = NULL + value/10 : gosub LCD_WRITECHAR : value = value mod 10
param = NULL + value : gosub LCD_WRITECHAR
param = P_ : gosub LCD_WRITECHAR
param = Hv : gosub LCD_WRITECHAR
return

#WR_AO
if value > 99 then param = NULL + value /100 else param = SPACE
gosub LCD_WRITECHAR : value = value mod 100
param = NULL + value /10 : gosub LCD_WRITECHAR : value = value mod 10
param = NULL + value : gosub LCD_WRITECHAR
return

#WR_CONSUMPTION
if value > 99 then param = NULL + value /100 else param = SPACE
gosub LCD_WRITECHAR : value = value mod 100
param = NULL + value /10 : gosub LCD_WRITECHAR : value = value mod 10
param = PERIOD : gosub LCD_WRITECHAR
param = NULL + value : gosub LCD_WRITECHAR
param = SPACE : gosub LCD_WRITECHAR
param = L_ : gosub LCD_WRITECHAR
return

#WR_DELETE
for a = 1 TO 12
param = MINUS : gosub LCD_WRITECHAR
next
return

#WR_RELAY

if regdis1 then goto WR_RELAY_1
if r1 then param = MINUS else param = PLUS : gosub LCD_WRITECHAR
goto WR_RELAY_1E
#WR_RELAY_1
if r1 then param = SPACE else param = O_ : gosub LCD_WRITECHAR
#WR_RELAY_1E

if regdis2 then goto WR_RELAY_2
if r2 then param = MINUS else param = PLUS : gosub LCD_WRITECHAR
goto WR_RELAY_2E
#WR_RELAY_2
if r2 then param = SPACE else param = O_ : gosub LCD_WRITECHAR
#WR_RELAY_2E

if regdis3 then goto WR_RELAY_3
if r3 then param = PLUS else param = MINUS : gosub LCD_WRITECHAR
goto WR_RELAY_3E
#WR_RELAY_3
if r3 then param = O_ else param = SPACE : gosub LCD_WRITECHAR
#WR_RELAY_3E

if regdis4 then goto WR_RELAY_4
if r4 then param = MINUS else param = PLUS : gosub LCD_WRITECHAR
goto WR_RELAY_4E
#WR_RELAY_4
if r4 then param = SPACE else param = O_ : gosub LCD_WRITECHAR
#WR_RELAY_4E

if regdis5 then goto WR_RELAY_5
if r5 then param = PLUS else param = MINUS : gosub LCD_WRITECHAR
goto WR_RELAY_5E
#WR_RELAY_5
if r5 then param = O_ else param = SPACE : gosub LCD_WRITECHAR
#WR_RELAY_5E

if regdis6 then goto WR_RELAY_6
if r6 then param = PLUS else param = MINUS : gosub LCD_WRITECHAR
goto WR_RELAY_6E
#WR_RELAY_6
if r6 then param = O_ else param = SPACE : gosub LCD_WRITECHAR
#WR_RELAY_6E

if regdis7 then goto WR_RELAY_7
if r7 then param = PLUS else param = MINUS : gosub LCD_WRITECHAR
goto WR_RELAY_7E
#WR_RELAY_7
if r7 then param = O_ else param = SPACE : gosub LCD_WRITECHAR
#WR_RELAY_7E

if r8 then param = SPACE else param = O_ : gosub LCD_WRITECHAR
return


 


Vmesniki

Omenjeni del kode ni potrebno prilagajati posamezni aplikaciji, zato je umaknjen na ločeno stran.