Code:
$regfile = "m168def.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***************************
$baud = 19200
Match_rom Alias &H55
Skip_rom Alias &HCC
Read_scratchpad Alias &HBE
Write_scratchpad Alias &H4E
Copy_scratchpad Alias &H48
Start_conversion Alias &H44
' Pin für 1wire Schnittstelle festlegen. => DS1820 am Port C.1
Config 1wire = Portc.1
Dim Ds1820id(32) As Byte
Dim Sc(9) As Byte '????
Dim T As Integer
Dim I As Byte
Dim Id As Byte
Dim T_mess As Single
Dim Spalte As Byte
'Die Adresse aller meiner DS1820 die ich vorher ausgelesen habe:
Restore Sensor_ids
For I = 1 To 32
Read Ds1820id(i)
Next I
1wreset
1wwrite Skip_rom
1wwrite Start_conversion 'Alle angeschlossenen DS18B20 zum Messen veranlassen
Waitms 500
'Ausgabe alle 0,5 Sekunden
Do
___lcdno = 0
Locate 1 , 1 : Lcd "Zeile 1"
'Locate 2 , 1 : Lcd "Zeile 2"
For Id = 1 To 25 Step 8 'ID für alle 4 DS1820 1,9,17,25
1wreset '1Wire Reseten
1wwrite &H55 'MATCHROM=>Adress.den DS1820 anhand des ROM Inhaltes
1wwrite Ds1820id(id) , 8 '8 Byte ID wird uebertragen
1wwrite &HBE 'READ SCATCHPAD => Liest alle Bytes des SP Memorys
Sc(1) = 1wread(9)
T = Sc(1)
T = Makeint(sc(1) , Sc(2)) 'komprimiert zwei Bytes in die Integervariable T
T_mess = T / 16 'Die Nachkommastelle entfernen
'Locate I , 11
Spalte = I * 6
Spalte = Spalte + 1
___lcdno = 0
'Locate 1 , 1 : Lcd " Inn Auss Kess Vorl Rück "
Locate 2 , Spalte 'Temperatur in Grad ausgeben
Lcd Fusing(t_mess , "#.#" )
Incr I
Next Id
I = 0
Spalte = 0
1wreset
1wwrite Skip_rom
1wwrite Start_conversion 'Alle angeschlossenen DS1820 zum Messen veranlassen
Waitms 2000
' Cls 'Ausgabe alle 0,5 Sekunden
Loop
End
Sensor_ids:
Data &H28 , &H25 , &H67 , &HAA , &H03 , &H00 , &H00 , &H55
Data &H28 , &HA2 , &H75 , &HAA , &H03 , &H00 , &H00 , &HC5
Data &H28 , &HA7 , &H64 , &HAA , &H03 , &H00 , &H00 , &H9F
Data &H28 , &HE6 , &H63 , &HAA , &H03 , &H00 , &H00 , &H8C
'Data &H10 , &HE8 , &HF4 , &H23 , &H01 , &H08 , &H00 , &HEF '
Danke schon einmal für die Hilfe
Lesezeichen