Sie sind hier: Home » Datenlogger V2 » Programm V2 » Prg Def V2

'*******************************************************************************
'***********************   DATENLOGGER V2  Definitionen  ***********************
'*******************************************************************************

'name                     : Datenlogger2_Definitionen.bas
'copyright                : (c) 16.04.2017 jep
'purpose                  : Definitionen zu Datenlogger_V2
'micro                    : Mega1284P-PU


Declare Sub Twi_show_state(byref State As Byte)
Declare Sub Write_edip
Declare Sub WP_aktiv(Inv_schalten as Byte)
Declare Function Spitransfer(byval Dout As Word) As Word
Declare Function Decigrades(byval Sc(9) As Byte) As Integer

'################################  ADRESSEN  ###################################
'                                                                             ##
'Funkadressen                                                                 ##
Const Zentr_adr = 85                                        'ist für ZSE      ##
Const SlZi = 1                                              '                 ##
Const Ziob = 2                                              '                 ##
Const aSued = 3                                             '                 ##
Const WiGa = 4                                              '                 ##
Const WoZi = 5                                              '                 ##
Const Reserve = 6                                           '                 ##
'                                                                             ##
'I2C-Adressen                                                                 ##
Const I2C_ZSE = 118                                         'Hex 76           ##
Const I2C_Zentr = 114                                       'Hex 72           ##
'                                                                             ##
'###############################################################################

 

'======================== Tastenkonfiguration ==================================

Config Porta.0 = Input                                      'Taste OK
Porta.0 = 1                                                 'Pullup
Ok Alias Pina.0
Config Porta.4 = Input                                      'Taste UP
Porta.4 = 1                                                 'Pullup
Up Alias Pina.4
Config Porta.3 = Input                                      'Taste Down
Porta.3 = 1                                                 'Pullup
Down Alias Pina.3
Config Porta.2 = Input                                      'Taste LEFT
Porta.2 = 1                                                 'Pullup
Links Alias Pina.2
Config Porta.1 = Input                                      'Taste RIGHT
Porta.1 = 1                                                 'Pullup
Rechts Alias Pina.1

Config Porta.5 = Input                                      'restl. Ports anbinden
Porta.5 = 1
Config Porta.6 = Input                                      'restl. Ports anbinden
Porta.6 = 1
Config Porta.7 = Input                                      'restl. Ports anbinden
Porta.7 = 1


Config Debounce = 20                                        '20 ms entprellen

'========================== Portkonfiguration ==================================
Config Portb.3 = Output                                     'blockiert DCF-Eingang
PortB.3 = 0                                                 'blockiert

Config Portb.4 = Output                                     'CS für SD-Karte
Portb.4 = 1                                                 'Pullup
SS Alias Portb.4

Config Portb.5 = Output                                     'MOSI out / RFM_SDI in
Portb.5 = 1                                                 'Pullup
MOSI Alias Portb.5

Config Pinb.6 = Input                                       'MISO in / RFM_SDO out
Portb.6 = 1                                                 'Pullup
MISO Alias Pinb.6

Config Portb.7 = Output                                     'SCK out / RFM_SCK in
Portb.7 = 1                                                 'Pullup
SCK Alias Portb.7

'PinD.2 = RX1                                               'Daten vom Display
'PortD.3 = TX1                                              'Daten zum Display

Config Portd.4 = Input                                      'Input WP_Laufzeit
Portd.4 = 1                                                 'Pullup
Wp Alias Pind.4

'PortD.5 = 1-wire                                            'pro Memoria
'PortD.6 = DCF77-Eingang                                     'pro Memoria

Config Portd.7 = Input                                      'Input Röbby in Garage
Portd.7 = 1                                                 'Pullup
Roebbystatus Alias Pind.7

'=================== restliche Ports konfigurieren =============================

'Port C.0 ist I2C-SCL                                        'pro Memoria
'Port C.1 ist I2C-SDA                                        'pro Memoria

Config Portc.2 = Input                                      'Input anbinden
Portc.2 = 1
Config Portc.3 = Input                                      'Input anbinden
Portc.3 = 1
Config Portc.4 = Input                                      'Input anbinden
Portc.4 = 1
Config Portc.5 = Input                                      'Input anbinden
Portc.5 = 1
Config Portc.6 = Input                                      'Input anbinden
Portc.6 = 1
Config Portc.7 = Input                                      'Input anbinden
Portc.7 = 1


Dim Nspi As Integer
Dim Dspi As Integer
Dim Dmiso As Word

'=========================== Display konfigurieren =============================

Config Com2 = 57600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "com2:" For Binary As #2

Dim Inv_schalten as Byte
Dim Gbuffer As String * 64                                  'die ans Display zu übertragenden Zeichen
Dim Dat As Byte                                             'entfällt eventuell
Dim Bcc As Byte                                             'Checksumme
Dim C As String * 1                                         'Auszug aus String
Dim M As Integer                                            'Länge des gbuffer
Dim Disp_quit As Byte                                       'Quittugseingang vom Display

Const Z1 = 1                                                'Zeile 1
Const Z2 = 15                                               'Zeile 2
Const Z3 = 29                                               'Zeile 3
Const Z4 = 43                                               'Zeile 4
Const Z5 = 57                                               'Zeile 5
Const Z6 = 71                                               'Zeile 6
Const Z7 = 85                                               'Zeile 7
Const Z8 = 99                                               'Zeile 8
Const Z9 = 113                                              'Zeile 9
Const Pdate = 1                                             'Position Datum
Const Pzeit = 64                                            'Position Zeit
Const Pdcf = 134                                            'Position DCF
Const Pd = 190                                              'Position Datenzähler
Const PF = 28                                               'Position Fehlermeldung


'=================== HW-SPI konfigurieren ======================================
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 16 , Noss = 1 , Spiin = 255
'Config Spisoft = Soft , Din = Pinb.6 , Dout = Portb.5 , Ss = Portd.3 , Clock = Portb.7 , Spiin = 255 , Mode = 1
Spiinit
Dim Cmd(2) As Byte                                          'Ausgabewort
Dim Readin(2) As Byte                                       'gleichzeitiges Eingangswort


'======================= DCF77 und Zeit-Konfiguration ==========================

Config Dcf77 = Pind.6 , Inverted = 1 , Timer = 1 , Debug = 0 , Check = 1 , Gosub = Sectic , Update = 2 , Updatetime = 3 , Switchpower = 1 , Powerpin = PinB.3 , Powerlevel = 1
'DCF77 benutzt Timer1     Update = 2 , Updatetime = 3 ,
Config Date = Dmy , Separator = .


Dim Neue_sekunde As Bit                                     'Flag
Dim Alte_minute As Byte                                     '
Alte_minute = 99                                            'unmöglicher Startwert = soforige Neusynchronisation
Dim Synchron As Bit                                         '1=synchron  0:kein korrekter Empfang
Dim Syncanzeige As String * 1                               'für die LCD-Anzeige
'Dim Dcfsyn As String * 8                                    'für Textanzeige
Dim Wochentag As Byte                                       '0..6
Dim Jahr(9) As Byte                                         'für Manipulationen nötig
Dim Monat(9) as Byte
Dim Tag(9) As Byte
Dim Stunden(9) As Byte
Dim Minuten(9) As Byte
Dim Sekunden(9) As Byte                                     'für Manipulationen nötig
Dim IstSynchron as Byte
IstSynchron = 0
Dim T As Byte                                               'Speicherintervall-Zeitzähler
T = 1

Dim Timeout As Byte                                         'Timeout für Eingaben in Sekunden
Timeout = 10                                                'Initialwert für Timeout (wenn nichts mehr passiert)
Dim Speicherintervall As Byte
Speicherintervall = 15                                      'Initialwert des Speicherintervalls
Dim Speicherintervall1 as String * 2
Dim Intervallanzeige As Byte                                'dient beim Einstellen zur Anzeige
Intervallanzeige = Speicherintervall                        'und initialisieren

'Time$ = "23:58:59"                                          ' Zeit setzen  h/m/s
'Date$ = "12-29-15"                                          ' Datum setzen Monat/Tag/Jahr


'======================= I2C-Konfiguration, SW???-I2C-Bus =========================
'$lib "i2c-multibus.Lib"                                     'Library für Multi-I2C-Busse
Config I2CBus = 0 , SCL = PortC.7 , SDA = PortC.6
Config I2Cdelay = 10                                        '100 kHz Clock
I2CBus = 0
I2cinit                                                     'sie sind HW-mässig festgelegt

'Adresse der I2C-Temperatursensoren DS1621
'(
Const Whz_adr_w = &H90                                      'Wohnzimmer Schreibadresse (144 dez)
Const Whz_adr_r = &H91                                      'Wohnzimmer Leseadresse (145 dez)
Const Res_adr_w = &H92                                      'Reservebaustein Schreibadresse (146 dez)
Const Res_adr_r = &H93                                      'Reservebaustein Leseadresse (147 dez)
')
'zum Testen gedreht da nur der Reservebaustein zur Verfügung steht
Const Whz_adr_w = &H92                                      'Wohnzimmer Schreibadresse (144 dez)
Const Whz_adr_r = &H93                                      'Wohnzimmer Leseadresse (145 dez)
Const Res_adr_w = &H90                                      'Reservebaustein Schreibadresse (146 dez)
Const Res_adr_r = &H91                                      'Reservebaustein Leseadresse (147 dez)


Const Es_adr_w = &H4E                                       'Erdsondenauswertung Schreibadresse
Const Es_adr_r = &H4F                                       'Erdsondenauswertung Leseadresse

'Adresse des DS1307 Uhrchips
Const Ds1307w = &HD0                                        'DS1307 clock Schreibadresse ( 208 dez)
Const Ds1307r = &HD1                                        'DS1307 clock Leseadresse ( 209 dez)
$lib "ds1307clock.lib"                                      'DS1307 Library


'======================= TWI-Konfiguration, HW-I2C-Bus =========================

Dim twi_mst_buff(33) as Byte                                'Buffer für Masterfunktion Transmit
Dim twi_msr_buff(33) as Byte                                'Buffer für Masterfunktion Receive
Dim Twi_slv_buff(33) As Byte                                'Buffer für Slavefunktionen
Dim TWI_Eingangspuffer(33) as Byte
Dim TWI_E_status as Byte                                    'Kopie des TWI Empfangsstatus

Twi_slv_addr = I2C_Zentr                                    'lokale I2C-Adresse (Zentrale)
Twi_sr_data = Varptr(twi_slv_buff(1))                       'Zeiger auf Datenbuffer Empfangsfall
Twi_st_data = Varptr(twi_slv_buff(1))                       'Zeiger auf Datenbuffer Sendefall

Twar = Twi_slv_addr + 1                                     'I2C Adress + GCA
Config Twi = 200000                                         'I2C Speed
On Twi Twi_mst_slv_isr , Nosave                             'ISR f. TWI


'alles für für die Zustände von maximal 10 Funksender

'Funkzust(100) für 10 Sender zu je max. 10 Byte
'+----+----+-  -+----+----+----+----+  --+----+----+----+-  -+----+----+----+----+----+----+
'| 1  | 2  |    | 9  | 10 | 11 | 12 |    | 21 | 20 | 21 |    | 90 | 91 | 92 |    | 99 |100 |
'+----+----+-  -+----+----+----+----+  --+----+----+----+   -+----+----+----+----+----+----+
'|<------- Funk 1 ------->|<------- Funk 2 ------->|<---     ---->|<------ Funk 10 ------->|
'Byte1;  11; ... Byte91:  Sender-Nummer
'Byte2;  12; ... Byte92:  Stunde
'Byte3;  13; ... Byte93:  Minute
'Byte4;  14; ... Byte94:  Temperatur
'Byte5:  15; ... Byte95:  Temperatur
'Byte6;  16; ... Byte96:  Feuchte
'Byte7;  17; ... Byte97:  Feuchte
'Byte8;  18; ... Byte98:  Batt.Spg
'Byte9;  19; ... Byte99:  Batt.Spg
'Byte10; 20: ... Byte100: Reserve

'Namenszuordnung der 10 Funksender:

Dim FName(10) as String * 6
FName(1) = "SchlZi"                                         'Index entspricht der Funkadresse
FName(2) = "Zioben"
FName(3) = "a.Sued"                                         'Index entspricht der Funkadresse
FName(4) = "WintGa"
FName(5) = "WohnZi"                                         'Index entspricht der Funkadresse
FName(6) = "oben  "
FName(7) = "Res1  "                                         'Index entspricht der Funkadresse
FName(8) = "Res2  "
FName(9) = "Res3  "
FName(10) = "Res4  "                                        'Index entspricht der Funkadresse

Dim Funkzust(100)as Byte                                    'für die Funküberwachung
Dim Adr_F(10) as Byte                                       'Adresse des Funksenders

Dim TF as Integer                                           'Temperatur Funksender
Dim TFsingle as Single
Dim TFTempkomma as String * 7
Dim TF_Temp(10) as String * 7

Dim FF as Integer                                           'Feuchte Funksender
Dim FFint as Integer
Dim FFsingle as Single
Dim Feuchte(10) as String * 5

Dim SF as Integer                                           'Speisung Funksender
Dim Betrspgsingle as Single
Dim Betrspgkomma as String * 6
Dim Betrspg(10) as String * 6

Dim CRC_16e as Word
Dim LL as Word
Dim Funktimeout as Byte                                     'wenn grösser x min dann Funkausfall
Funktimeout = 10                                            'Timeout ist 10 min
Dim Funkttest_erfolgt as Byte                               'damit nur ein Durchgang erfogt
Funkttest_erfolgt = 0                                       'Initialwert
Dim Funk_Fehler as string * 30                              'Funkfehlermeldung

'=========================== 1-Wire Konfiguration ==============================
Dim Portnummer As Byte                                      'VERSUCH DEN 1WIRE-BEFEHL DYNAMISCH AUF VERSCHIEDENE PORTS ZU LEGEN
Portnummer = 5
Config 1wire = Portd.portnummer                             '1-Wire-Port

Dim Dg As Integer                                           'DECIgrades, I call it, cause I have no space for commas on the display....
Dim Degr As Single                                          'zur Darstellung umgewandelt
Dim B As Byte

Const Max18s20_sensoren = 5                                 'max. Anzahl 18S20-Sensoren um nicht nachfolgende zu überschreiben
Const Adressbytes_pro_sensor = 8
Const Anzahl_speicherplaetze = Max18s20_sensoren * Adressbytes_pro_sensor
Dim Dsid(anzahl_speicherplaetze) As Byte                    'Dallas ID 64 bits incl CRC x 8 Stk
Dim Sensor_nr As Byte
Dim Sc(9) As Byte                                           'Scratchpad 0-8 72 bits incl CRC
Dim Tempkomma As String * 10
Dim Startmessung_erfolgt as Byte                            'damit nur ein Durchgang erfolgt
Startmessung_erfolgt = 0                                    'Initialwert

'hier werden direkt die Adressen der Sensoren zugewiesen

'(
Dsid(1) = &H10                                              '1---Sensor 7 für Tests und Entwicklung
Dsid(2) = &HC0
Dsid(3) = &H64
Dsid(4) = &H90
Dsid(5) = &H02
Dsid(6) = &H08
Dsid(7) = &H00
Dsid(8) = &HB2
')

Dsid(1) = &H10                                              '1---Heizung Vorlauf am Verteiler
Dsid(2) = &H5B
Dsid(3) = &H17
Dsid(4) = &H90
Dsid(5) = &H02
Dsid(6) = &H08
Dsid(7) = &H00
Dsid(8) = &HD8


Dsid(9) = &H10                                              '2---Heizung Rücklauf
Dsid(10) = &HD2
Dsid(11) = &H8F
Dsid(12) = &H77
Dsid(13) = &H02
Dsid(14) = &H08
Dsid(15) = &H00
Dsid(16) = &HE2

Dsid(17) = &H10                                             '3---Sole Vorlauf
Dsid(18) = &H07
Dsid(19) = &H8D
Dsid(20) = &H77
Dsid(21) = &H02
Dsid(22) = &H08
Dsid(23) = &H00
Dsid(24) = &H4E

Dsid(25) = &H10                                             '4---Sole Rücklauf
Dsid(26) = &H40
Dsid(27) = &H11
Dsid(28) = &H90
Dsid(29) = &H02
Dsid(30) = &H08
Dsid(31) = &H00
Dsid(32) = &HE7

Dsid(33) = &H10                                             '5---Aussen Nord
Dsid(34) = &H39
Dsid(35) = &H8D
Dsid(36) = &H8D
Dsid(37) = &H02
Dsid(38) = &H08
Dsid(39) = &H00
Dsid(40) = &HDA
'(
Dsid(41) = &H10                                             '6---Reserve 1
Dsid(42) = &H3B
Dsid(43) = &H90
Dsid(44) = &H77
Dsid(45) = &H02
Dsid(46) = &H08
Dsid(47) = &H00
Dsid(48) = &H4E
')

'========================== I2C-Speicher-Management ================================
Dim Adresspointer As Dword                                  'zeigt auf die nächste zu schreibenden EEPROM-Adresse
Dim Anzahldatensaetze As Dword                              'wird für die Displayanzeige benötigt
Dim Anzahldatensaetze1 as String * 4
Dim Apl As Word At Adresspointer Overlay                    '\
Dim Aph As Word At Adresspointer + 2 Overlay                ' |
Dim Apl_l As Byte At Apl Overlay                            ' \
Dim Apl_h As Byte At Apl + 1 Overlay                        '  > dienen zum einfachen Speichern des
Dim Aph_l As Byte At Aph Overlay                            '  > Adresspointers im EEProm (Byte-Zugriff)
Dim Aph_h As Byte At Aph + 1 Overlay                        '_/
Dim Auslesepointer As Dword                                 'zeigt auf die Ausleseadresse beim Anzeigen
Dim Ausleseadresse As Dword                                 'zeigt auf die zu lesende EEPROM-Adresse
Dim LetzteAdresse As DWord
Dim Speicheradresse As Dword                                'Speicher-Manipulationsadresse über alle EEPROMs
Dim Eeprom_adresse As Word At Speicheradresse Overlay       'low-Word von Speicheradresse
Dim Eeprom_dev_adresse As Word At Speicheradresse + 2 Overlay       'Overlay für die EEProm-Adresse
Dim Eeprom_dev_adr As Byte                                  'Device-Adress for EEPROM
Eeprom_dev_adr = Low(eeprom_dev_adresse)                    'Low-Byte von EEProm-Dev_Adresse
Const Maxspeicher = &H0057FFE0                              'höchste mögliche Speicheradresse der Daten
Const Startspeicher = &H00500020                            'Startadresse der Daten

'Filepointer = &B00000000_01010000_00000000_00001000         'Adresse des Pointers auf die File_Version der SD-Karte
Adresspointer = &B00000000_01010000_00000000_00100000       'Startadresse des Pointers auf die Daten
Speicheradresse = Adresspointer                             'EEPROM-Manipulationsadresse

'Speicheradress-Management:
'                    |<------- Speicheradresse ------->|     DWord
'            EEPROM- |<-Dev_Adresse->| |<---Adresse--->|     Word
'            EEPROM- |<Dev_>| |<Dev_>| |<-H-->| |<-L-->|     Byte
'                    |  h   | | Adr  | |      | |      |
'Speicheradresse = &b00000000_01010000_00000000_00100000     Startadresse des Pointers auf die Daten
'      oder          |        ||  |||| |          |    |
'Adresspointer       |        ||  |||| |          ++++++---- Startadresse 32 = h20
'                    |        ||  |||| +++++++++++++++++---- Adresse eines Blocks (0...65536)
'                    |        ||  ||++---------------------- Device-Adresse (0...3)
'                    |        ||  |+------------------------ Blockadresse (0 oder 1)
'                    |        |++++------------------------- Control-Code (b1010), immer gleich
'                    ++++++++++----------------------------- immer 0, wird nicht gebraucht
' wenn das EEPROM adressiert wird muss das Read- oder Write-Bit noch eingeschoben werden!!!
' Es gibt keine Überprüfung auf Überlauf von einem IC auf das andere!!!
' Ist hier auch nicht nötig, da in Inkrementen von 32 (oder später 64) gespeichert wird (siehe max_Daten).
'                   _________________________________________

'Umwandlung 2 Byte in Integer
'        +--------+--------+- -+--------+--------+             TB  Daten  Daten_out
' -----> | Byte 1 | Byte 2 |   | Byte 31| Byte 32| =====>      |   |      ^
'        +--------+--------+- -+--------+--------+             |   |      |
' =====> |    Integer 1    |   |   Integer 16    | ----->      v   v      |
'        +-----------------+- -+-----------------+             TE  TE     TemperaturInteger
'
'
'
'===================================== Messdatenverwaltung ================================
Const Max_daten = 32                                        'maximale 32 Datenbytes pro Datensatz
Dim Maxdaten As Byte
Maxdaten = Max_daten                                        'Wert zuweisen
Const Max_integer = 14                                      'max. 14 Integerwerte (Temperaturen)                    so es denn mit 0 beginnt
Dim Maxinteger As Byte
Maxinteger = Max_integer                                    'Wert zuweisen
Const Max_single = 14                                       'max. 14 Singlewerte (Temperaturen)                     so es denn mit 0 beginnt
Dim Maxsingle As Byte
Maxsingle = Max_single                                      'Wert zuweisen

'in das EEProm zu speichernde Temperaturen
'+----+----+----+----+----+----+----+----+----+----+----+----+ +----+----+----+----+----+----+
'| 1  | 2  | 3  | 4  | 5  |  6 | 7  | 8  | 9  | 10 | 11 | 12 | | 27 | 28 | 29 |30  |31  |32  | Daten_in(32); Bytes
'+----+----+----+----+----+----+----+----+----+----+----+----+ +----+----+----+----+----+----+
' Tag Monat Jahr Std  Min  stat|    1    |    2    |    3    | |    11   |    12   |    13   | Te(13); Integer
'                              +----+----+----+----+----+----+ +----+----+----+----+----+----+

Dim Daten_in(Max_daten)as Byte                              'Datenarray(32 Bytes) zum Schreiben ins EEPROM
Dim Te(Max_integer) As Integer At Daten_in(7) Overlay

 

'aus dem EEProm zurückgelesene Temperaturen
'+----+----+----+----+----+----+----+----+----+----+----+----+ +----+----+----+----+----+----+
'| 1  | 2  | 3  | 4  | 5  |  6 | 7  | 8  | 9  | 10 | 11 | 12 | | 27 | 28 | 29 |30  |31  |32  | Daten_out(32); Bytes
'+----+----+----+----+----+----+----+----+----+----+----+----+ +----+----+----+----+----+----+
' Tag Monat Jahr Std  Min  stat|    1    |    2    |    3    | |    11   |    12   |    13   | Ta(13); Integer
'                              +----+----+----+----+----+----+ +----+----+----+----+----+----+

Dim Daten_out(Max_daten) As Byte                            'Datenarray(32 Bytes) gelesen aus EEPROM
Dim Ta(Max_integer) As Integer At Daten_out(7) Overlay      '
Dim Temperatursingle(Max_single) As Single
Dim Text_aus(13) As String * 10                             'Temperaturanzeige wie sie im Display steht

'Zuweisungen der Temperatursensoren zu Speicher und deren Anbindung

H_Vor alias Text_aus(1)                                     'TE(1) = TA(1):  Heizung Vorlauf     Dsid(1)
H_Ruck alias Text_aus(2)                                    'TE(2) = TA(2):  Heizung Rücklauf    Dsid(9)
S_Vor alias Text_aus(3)                                     'TE(3) = TA(3):  Sole Vorlauf        Dsid(17)
S_Ruck alias Text_aus(4)                                    'TE(4) = TA(4):  Sole Rücklauf       Dsid(25)
A_Nord alias Text_aus(5)                                    'TE(5) = TA(5):  Aussen Nord         Dsid(33)
S_Zi alias Text_aus(6)                                      'TE(6) = TA(6):  Schlafzimmer        Funk
Wi_Ga alias Text_aus(7)                                     'TE(7) = TA(7):  Wintergarten        Funk
A_Sud alias Text_aus(8)                                     'TE(8) = TA(8):  Aussen Süd          Funk
Oben alias Text_aus(9)                                      'TE(9) = TA(9):  Zimmer oben         Funk
W_Zi alias Text_aus(10)                                     'TE(10) = TA(10): Wohnzimmer         Funk
ReserveF alias Text_aus(11)                                 'TE(11) = TA(11): Reserve Funk       Funk
E_unten alias Text_aus(12)                                  'TE(12) = TA(12): Erdsonde unten     USB / seriell
E_oben alias Text_aus(13)                                   'TE(13) = TA(13): Erdsonde oben      USB / 1Wire


'================================================================================================
Dim Ausgabe_lcd(9) As String * 125                          '9 Zeilen zu je 14 Temperaturen + 2 x statischer Text = 16x7=122x9=1098
Dim Displp_horiz As Byte                                    'Pointer auf horizontale Stelle im Display

Dim Fehlermeldung as String * 7                             'Fehlermeldungen auf der 2. Zeile
Dim Wpstatus_kurz As String * 4
Dim Wpstatus_lang As String * 8
Dim WPstatus(9) as Byte                                     'dient zum Invertieren bei der Anzeige
Dim Wpstatus_alt As Bit                                     'Zwischenspeicher für den alten WPstatus
Wpstatus_alt = WP                                           'und initialisieren
Dim WP_Laufzeit as word                                     'Speicher für WP-Laufzeit
WP_Laufzeit = 1                                             '1 ist WP aus
Dim WP_Laufzeit1 as string * 3
WP_Laufzeit1 = "..."
Dim WP_Laufzeit_vorher as string * 3                        'Speicher für vorherige Laufzeit
WP_Laufzeit_vorher = "..."
Dim h_WP_ein as Byte                                        'Startzeitpunkt Wärmepumpe
Dim m_WP_ein as Byte
Dim h_WP_aus as Byte                                        'Stopzeitpunkt Wärmepumpe
Dim m_WP_aus as Byte

Dim Roebbystatus_lang As String * 8
Dim Roebbystatus_alt As Bit                                 'Zwischenspeicher für den alten Roebbystatus
Roebbystatus_alt = Roebbystatus                             'und initialisieren
Dim Roebby_Laufzeit as word                                 'Speicher für Roebby-Laufzeit
Roebby_Laufzeit = 0
Dim Roebby_Laufzeit1 as string * 3                          'Speicher für Roebby-Laufzeit für Darstellung
Roebby_Laufzeit1 = "..."
Dim Roebby_Laufzeit_vorher as string * 3                    'Speicher für vorherige Laufzeit
Roebby_Laufzeit_vorher = "..."
Dim h_Roebby_ein as Byte                                    'Startzeitpunkt Roebby
Dim m_Roebby_ein as Byte
Dim h_Roebby_aus as Byte                                    'Stopzeitpunkt Roebby
Dim m_Roebby_aus as Byte

Dim Helligkeit as Byte                                      'Anzeigehelligkeit
Helligkeit = 60                                             'auf 60%
Dim Helligkeit_minimal as Byte                              'minimale Helligheit
Helligkeit_minimal = 5                                      'auf 5%

Dim Beleuchtungsdauer as Byte                               'Beleuchtungsdauer nach einem Tastendruck
Beleuchtungsdauer = 60                                      'Startwert 60 sec, maximal 255 sec
Dim Beleuchtungsdauer_rest as Byte                          'Beleuchtung Restlaufzeitzeit
Beleuchtungsdauer_rest = 30                                 'Restlaufzeit Startwert
Dim Beleuchtung_aktiv as Bit
Beleuchtung_aktiv = 1                                       'Startwert --> Beleuchtung ein

Dim Es_merker As Bit                                        'Merker dass nochmals die Erdsonde gemessen werden muss
Reset Es_merker                                             'und reseten
Dim Speichern_merker as Bit                                 'Merker wenn WP oder Röbbystatus geändert
Reset Speichern_merker

Dim Temp As Integer
Dim Temp1 As Integer
Dim H As Byte                                               'High Adress Byte von einem Word
'Dim I As Byte
'Dim K As Integer                                            'Laufvariable fuer Schleife
Dim L As Byte                                               'Low Adress Byte von einem Word
Dim N As Byte                                               'Index auf gespeicherte Temperatur
Dim O As Byte                                               'Zählvariable
'Dim Aw As Byte
Dim U as Word
Dim V As Byte
Dim W As Word
Dim X As Byte
Dim Y As Byte
Dim Z As Byte

'SD-Karte: Definitionen
Dim SD_buff as String * 254
Dim Te_sd(13) as string * 8
Dim Statisch(8) as string * 1
Dim SD_Fehler as String * 34
Const Filename = "ALLDATA TXT"

'Ringpufferdefinitionen
Const Records = 300                                         'max. Anzahl Datensätze im Ringpuffer
Const Buffer_Tiefe = Max_Daten * Records
Dim Ringbuffer(Buffer_Tiefe) as Byte
Dim Wrindex as Word
Dim Rdindex as Word
Wrindex = 1                                                 'Startwert
Rdindex = 1                                                 'Startwert