پاسخ : استفاده از DS1820 در محیط صنعتی
با چه کامپایلری کار می کنید؟
با چه کامپایلری کار می کنید؟
$regfile = "m8def.dat"
$crystal = 8000000
Config Lcdpin = Pin , Rs = Pinc.0 , E = Pinc.1 , Db4 = Pinc.2 , Db5 = Pinc.3 , Db6 = Pinc.4 , Db7 = Pinc.5
Config Lcd = 16 * 2
Cursor Off
Config 1wire = Portb.2
'--------------------------------dim-------------------------------------------
Dim A1 As Byte : Dim Sens1(8) As Byte , Sens2(8) As Byte , Sens3(8) As Byte
Dim T As Single
Dim Th As Byte , Tl As Byte , S_no As Byte
Dim A As Byte , A2 As Byte
Dim W As Byte , Q As Byte , T2 As Byte , T1 As Byte ,
Dim H As Byte , M As Byte , F As Byte , L As Byte , K As Byte , G As Byte
Dim Temp1 As Integer , Temp2 As Integer , Temp3 As Integer , Temp1s As String * 5 , Temp2s As String * 5 , Btemp As Integer , Buft1 As Integer , Buft2 As Integer , Buft3 As Integer
Dim Temp3s As String * 5
Dim Dsid1(8) As Byte
Dim Dsid2(8) As Byte
Dim Dsid3(8) As Byte
Dim Dsid4(8) As Byte
Dim I1 As Integer , Ss As String * 6
Dim I2 As Integer
Dim I3 As Integer
Dim I4 As Integer
Dim B As Byte
Dim Num As Byte
Do
Num = 1wirecount()
Dsid1(1) = 0
Dsid2(1) = 0
Dsid3(1) = 0
Dsid1(1) = 1wsearchfirst()
Dsid2(1) = 1wsearchnext()
Dsid3(1) = 1wsearchnext()
1wreset
If Err = 1 Then B = 0
1wwrite &H55
1wverify Dsid1(1)
1wwrite &HBE
I1 = 1wread(2)
Waitms 250
'---------------------------------
1wreset
If Err = 1 Then W = 0
1wwrite &H55
1wverify Dsid2(1)
1wwrite &HBE
I2 = 1wread(2)
Waitms 150
'---------------------------------
1wreset
If Err = 1 Then T = 0
1wwrite &H55
1wverify Dsid3(1)
1wwrite &HBE
I3 = 1wread(2)
Waitms 150
'---------------------------------
1wreset
1wwrite &HCC
1wwrite &H44
Waitms 600
'=====================================================
If Num > 0 Then
I1 = I1 * 10
I1 = I1 / 16
Ss = Str(i1)
Ss = Format(ss , " 0.0")
Locate 1 , 1
Lcd "I1:" ; Ss
End If
'===================================================
If Num > 1 Then
I2 = I2 * 10
I2 = I2 / 16
Ss = Str(i2)
Ss = Format(ss , " 0.0")
Locate 2 , 1
Lcd "I2:" ; Ss
End If
'=====================================================
If Num > 2 Then
I3 = I3 * 10
I3 = I3 / 16
Ss = Str(i3)
Ss = Format(ss , " 0.0")
Locate 1 , 9
Lcd "I3:" ; Ss
End If
Loop

دیدگاه