а если менять задержку Waitms 750 на 250 (150) тормоза исчезают но 1 из 4 температурников пропадает .
Как я понял всё это как раз из за этой задержки так вот как побороть тормоза секунд и проблему с датчиком.
- Код: Выделить всё • Развернуть
- Do
 1wreset
 1wwrite &HCC
 1wwrite &H44
 Waitms 750
 Call Gettime
 Text = Bcd(h) + ":" + Bcd(m) + ":" + Bcd(s)
 Locate 1 , 1
 Lcd Text
 1wverify Dsid1(1)
 1wwrite &HBE
 Sc(1) = 1wread(9)
 If Sc(9) = Crc8(sc(1) , 8) Then
 If Dsid1(1) = 16 Then
 Dg = Decigrades(sc(9))
 End If
 If Dsid1(1) = 40 Then
 Dg = Decigrades2(sc(9))
 End If
 Ss = Str(dg)
 Ss = Format(ss , " 0.0")
 Locate 2 , 1
 Lcd "1 - " ; Ss ; Chr(0) ;
 End If
 1wverify Dsid2(1)
 1wwrite &HBE
 Sc(1) = 1wread(9)
 If Sc(9) = Crc8(sc(1) , 8) Then
 If Dsid2(1) = 16 Then
 Dg = Decigrades(sc(9))
 End If
 If Dsid2(1) = 40 Then
 Dg = Decigrades2(sc(9))
 End If
 Ss = Str(dg)
 Ss = Format(ss , " 0.0")
 Locate 2 , 12
 Lcd "2 - " ; Ss ; Chr(0) ;
 End If
 1wverify Dsid3(1)
 1wwrite &HBE
 Sc(1) = 1wread(9)
 If Sc(9) = Crc8(sc(1) , 8) Then
 If Dsid3(1) = 16 Then
 Dg = Decigrades(sc(9))
 End If
 If Dsid3(1) = 40 Then
 Dg = Decigrades2(sc(9))
 End If
 Ss = Str(dg)
 Ss = Format(ss , " 0.0")
 Locate 3 , 1
 Lcd "3 - " ; Ss ; Chr(0) ;
 End If
 1wverify Dsid4(1)
 1wwrite &HBE
 Sc(1) = 1wread(9)
 If Sc(9) = Crc8(sc(1) , 8) Then
 If Dsid4(1) = 16 Then
 Dg = Decigrades(sc(9))
 End If
 If Dsid4(1) = 40 Then
 Dg = Decigrades2(sc(9))
 End If
 Ss = Str(dg)
 Ss = Format(ss , " 0.0")
 Locate 3 , 12
 Lcd "4 - " ; Ss ; Chr(0) ;
 End If
 Loop
 'get time
 Sub Gettime
 Dim Dum As Byte
 I2cstart 'generate start
 I2cwbyte 160 'write addres of PCF8583
 I2cwbyte 2 'select second register
 I2cstart 'generate repeated start
 I2cwbyte 161 'write address for reading info
 I2crbyte S , Ack 'read seconds
 I2crbyte M , Ack 'read minuts
 I2crbyte H , Ack 'read hours
 I2crbyte Yd , Ack 'read year and days
 I2crbyte Wm , Nack 'read weekday and month
 I2cstop 'generate stop
 End Sub
 Sub Settime(s As Byte , M As Byte , H As Byte , D As Byte , Month As Byte)
 'values are stored as BCD values so convert the values first
 S = Makebcd(s) 'seconds
 M = Makebcd(m) 'minuts
 H = Makebcd(h) 'hours
 D = Makebcd(d) 'days
 Month = Makebcd(month) 'months
 I2cstart 'generate start
 I2cwbyte 160 'write address
 I2cwbyte 0 'select control register
 I2cwbyte 8 'set year and day bit for masking
 I2cstop 'generate stop
 I2cstart 'generate start
 I2cwbyte 160 'write mode
 I2cwbyte 2 'select seconds Register
 I2cwbyte S 'write seconds
 I2cwbyte M 'write minuts
 I2cwbyte H 'write hours
 I2cwbyte D 'write days
 I2cwbyte Month 'write months
 I2cstop
 End Sub
 'DS18b20
 Function Decigrades2(byval Sc(9) As Byte)
 Decigrades2 = 0
 Decigrades2 = Makeint(sc(1) , Sc(2))
 Decigrades2 = Decigrades2 * 10
 Decigrades2 = Decigrades2 / 16
 End Function
 'DS18s20
 Function Decigrades(byval Sc(9) As Byte)
 Dim Tmp As Byte , T As Integer , T1 As Integer
 Tmp = Sc(1) And 1 ' 0.1C precision
 If Tmp = 1 Then Decr Sc(1)
 T = Makeint(sc(1) , Sc(2))
 'Print Hex(t)
 'Print T
 T = T * 50 'here we calculate the 1/10 precision like
 T = T - 25 'DS18S20 data sheet
 T1 = Sc(8) - Sc(7)
 T1 = T1 * 100
 T1 = T1 / Sc(8)
 T = T + T1
 Decigrades = T / 10
 'As integer, this routine gives T*10, with 1/10 degree precision
 End Function


