Code:
$regfile = "m8def.dat"
$crystal = 4000000 '3686400
$hwstack = 46
$swstack = 40
$framesize = 40
'**************************Funktionen LCD-Display*******************************
Config Lcd = 40 * 4
Config Lcdpin = Pin , Rs = Portb.0 , Db4 = Portd.5 , Db5 = Portd.4 , Db6 = Portd.3 , Db7 = Portd.2 , E = Portd.6 , E2 = Portd.7
Config Lcdbus = 4
Config Lcdmode = Port
Dim ___lcdno As Byte
___lcdno = 0
Initlcd
Cursor Off
Cls
___lcdno = 1
Initlcd
Cursor Off
Cls
'**************************Def. allgemeiner Variabeln***************************
Dim Tempmessstelle(8) As Single
Waitms 60
'***************************Config 1Wire****************************************
Config 1wire = Portc.1 'DS1820
Match_rom Alias &H55
Read_scratchpad Alias &HBE
Start_conversion Alias &H44
Innen Alias 0
Vorlauf Alias 1
Rücklauf Alias 2
Aussen Alias 3
Kessel Alias 4
Boiler Alias 5
Dim Read_temp As Integer
Dim Sensor_ids(48) As Byte
Dim Id As Byte
Dim Offset As Byte
Dim Ds_array(7) As Byte
Dim Bruchteil As Single
Dim Temperatur As Single
Dim I As Integer
'***************************ID 1Wire configurieren******************************
For Id = 1 To 40 'Einlesen der 5 Sensoren IDs (5*8 Byte)
I = Id - 1
Readeeprom Sensor_ids(id) , I
Next Id
'***********************************Hauptprogramm*******************************
Do
Gosub 1wire
Loop
End
'**********************************1Wire****************************************
1wire:
Wait 1
For Id = Innen To Kessel
Offset = Id * 8
Offset = Offset + 1 'Offset geht auf 1, 9, 17, 25 und 33
1wreset 'hier wird der Temperaturwert eingelesen
1wwrite Match_rom
1wwrite Sensor_ids(offset) , 8 '8 Byte ID wird übertragen
1wwrite Read_scratchpad
For I = 1 To 7 'nur bis 7, weil 8 und 9 uninteressant
Ds_array(i) = 1wread()
Next I
Read_temp = Makeint(ds_array(1) , Ds_array(2))
1wreset 'jetzt wird wieder die Konvertierung gestartet
1wwrite Match_rom
1wwrite Sensor_ids(offset) , 8
1wwrite Start_conversion
Shift Read_temp , Right
'If 127 < Read_temp Then Read_temp = Read_temp - 32768
Bruchteil = 16 - Ds_array(7)
Bruchteil = Bruchteil / 16
Bruchteil = Bruchteil - 0.25
Temperatur = Read_temp + Bruchteil
Tempmessstelle(id + 1) = Temperatur
If Temperatur <> 85.0 Then ' < 80.0 And Temperatur > -20.0 Then
Tempmessstelle(id + 1) = Temperatur
End If
'Innen Alias 0
'Vorlauf Alias 1
'Rücklauf Alias 2
'Aussen Alias 3
'Kessel Alias 4
'Boiler Alias 5
___lcdno = 0
Select Case Id
Case Innen:
Locate 1 , 1 : Lcd "WZ: "
Locate 1 , 5 : Lcd Fusing(temperatur , "#.#")
Case Aussen:
Locate 1 , 11 : Lcd "AT: "
Locate 1 , 14 : Lcd Fusing(temperatur , "#.#")
Case Vorlauf: 'ausgabe im Display ist dann z.B.
Locate 2 , 1 : Lcd "VL: "
Locate 2 , 5 : Lcd Fusing(temperatur , "#.#" ) ' Inn Auss Kess Rück Vorl
Case Rücklauf: ' 14.4 52.4 67.3 43.0 62.8
Locate 2 , 11 : Lcd "RL: "
Locate 2 , 14 : Lcd Fusing(temperatur , "#.#")
End Select
___lcdno = 1
Select Case Id
Case Kessel:
Locate 1 , 11 : Lcd "KE: "
Locate 1 , 14 : Lcd Fusing(temperatur , "#.#")
End Select
Cursor Off
Next Id
Return
'-----------------------------------------
$eeprom
Data &H28 , &H25 , &H67 , &HAA , &H03 , &H00 , &H00 , &H55
Data &H28 , &HA2 , &H75 , &HAA , &H03 , &H00 , &H00 , &HC5
Data &H10 , &H78 , &H37 , &H39 , &H01 , &H08 , &H00 , &H11
Data &H10 , &HC0 , &H46 , &H19 , &H01 , &H08 , &H00 , &H67
Data &H10 , &HE8 , &HF4 , &H23 , &H01 , &H08 , &H00 , &HEF '
Lesezeichen