Hallo,
meine Sache läuft mit 4 Sensoren und 0.1Grad
Was mich nur stört sind die ganzen waitms.
Momentan lasse ich alle 5 sec. die 4 Sensoren hintereinander auslesen und dann wird mir der Wert ausgegeben.
Nur wenn ich die 4 Dinger hintereinander auslese steht mein Programm wegen den waitms so ca. 3 sec und ich kann nichts weiter machen.(Menü durchblättern usw.)
Kann man das nicht anders lösen?
Müssen die ganzen waitms da hin?
Hier mal mein Ausschnitt der auf meinem Steckbrett läuft:
Code:
$regfile = "m32def.dat"
$crystal = 8000000
Config Lcdpin = Pin , Db4 = Portd.0 , Db5 = Portd.1 , Db6 = Portd.4 , Db7 = Portd.3 , E = Portb.7 , Rs = Portb.6
Config Lcd = 16 * 2
Config Lcdbus = 4
Cursor Off
Cls
Config 1wire = Portc.5
Dim T As Integer
Dim T1 As Integer
Dim T2 As Integer
Dim T3 As Integer
Dim T4 As String * 10
Dim T5 As String * 10
Dim T6 As Single
Dim T7 As Single
Dim Id1(8) As Byte
Dim Id2(8) As Byte
Dim Ar1(9) As Byte
Dim Ar2(9) As Byte
Dim I As Byte , Tmp As Byte , Tmp2 As Byte
Dim 1t As Integer
Dim 1t1 As Integer
Dim 1t2 As Integer
Dim 1t3 As Integer
Dim 1t4 As String * 10
Dim 1t5 As String * 10
Dim 1t6 As Single
Dim 1t7 As Single
Dim Id3(8) As Byte
Dim Id4(8) As Byte
Dim 1ar1(9) As Byte
Dim 1ar2(9) As Byte
Dim 1i As Byte , 1tmp As Byte , 1tmp2 As Byte
Id1(1) = 1wsearchfirst()
Id2(1) = 1wsearchnext()
Id3(1) = 1wsearchnext()
Id4(1) = 1wsearchnext()
Do
1wreset
1wwrite &H55
1wwrite Id1(1) , 8
1wwrite &H44
Waitms 300
1wreset
1wwrite &H55
1wwrite Id1(1) , 8
1wwrite &HBE
Ar1(1) = 1wread(9)
1wreset
Tmp = Ar1(1) And 1
If Tmp = 1 Then Decr Ar1(1)
T = Makeint(ar1(1) , Ar1(2))
T = T * 50
T = T - 25
T1 = Ar1(8) - Ar1(7)
T1 = T1 * 100
T1 = T1 / Ar1(8)
T = T + T1
T = T / 10
T6 = T / 10
T4 = Fusing(t6 , "#.#")
Waitms 500
1wreset
1wwrite &H55
1wwrite Id2(1) , 8
1wwrite &H44
Waitms 300
1wreset
1wwrite &H55
1wwrite Id2(1) , 8
1wwrite &HBE
Ar2(1) = 1wread(9)
1wreset
Tmp2 = Ar2(1) And 1
If Tmp2 = 1 Then Decr Ar2(1)
T2 = Makeint(ar2(1) , Ar2(2))
T2 = T2 * 50
T2 = T2 - 25
T3 = Ar2(8) - Ar2(7)
T3 = T3 * 100
T3 = T3 / Ar2(8)
T2 = T2 + T3
T2 = T2 / 10
T7 = T2 / 10
T5 = Fusing(t7 , "#.#")
1wreset
1wwrite &H55
1wwrite Id3(1) , 8
1wwrite &H44
Waitms 300
1wreset
1wwrite &H55
1wwrite Id3(1) , 8
1wwrite &HBE
1ar1(1) = 1wread(9)
1wreset
1tmp = 1ar1(1) And 1
If 1tmp = 1 Then Decr 1ar1(1)
1t = Makeint(1ar1(1) , 1ar1(2))
1t = 1t * 50
1t = 1t - 25
1t1 = 1ar1(8) - 1ar1(7)
1t1 = 1t1 * 100
1t1 = 1t1 / 1ar1(8)
1t = 1t + 1t1
1t = 1t / 10
1t6 = 1t / 10
1t4 = Fusing(1t6 , "#.#")
Waitms 500
1wreset
1wwrite &H55
1wwrite Id4(1) , 8
1wwrite &H44
Waitms 300
1wreset
1wwrite &H55
1wwrite Id4(1) , 8
1wwrite &HBE
1ar2(1) = 1wread(9)
1wreset
1tmp2 = 1ar2(1) And 1
If 1tmp2 = 1 Then Decr 1ar2(1)
1t2 = Makeint(1ar2(1) , 1ar2(2))
1t2 = 1t2 * 50
1t2 = 1t2 - 25
1t3 = 1ar2(8) - 1ar2(7)
1t3 = 1t3 * 100
1t3 = 1t3 / 1ar2(8)
1t2 = 1t2 + 1t3
1t2 = 1t2 / 10
1t7 = 1t2 / 10
1t5 = Fusing(1t7 , "#.#")
Locate 1 , 1 : Lcd "T1:" ; T4
Locate 1 , 10 : Lcd "T2:" ; T5
Locate 2 , 1 : Lcd "T3:" ; 1t4
Locate 2 , 10 : Lcd "T4:" ; 1t5
Waitms 500
Loop
Den Code habe ich hier aus dem Forum, habe das nur mal verdoppelt und vor die neuen Variablen ne 1 vorgehängt.
Lesezeichen