Witam,
Nabyłem moduł MMega01 firmy http://www.propox.pl/index.phtml?lang=pl
Problem polega na braku komunikacji z urządzeniami 1wire... Probowałem podłączyć termometr DS18b20(nie jeden - myślałem że ten co mam jest uszkodzony) i nic... taktowanie procka to ok 16MHz.
Jako rezystor podciągający na magistrali 1wire daje 2,2k np w ATmega32 zawsze wystarczało.
Program który sprawdzam to:
Proszę o pomoc w rozwiązaniu problemu.
Nabyłem moduł MMega01 firmy http://www.propox.pl/index.phtml?lang=pl
Problem polega na braku komunikacji z urządzeniami 1wire... Probowałem podłączyć termometr DS18b20(nie jeden - myślałem że ten co mam jest uszkodzony) i nic... taktowanie procka to ok 16MHz.
Jako rezystor podciągający na magistrali 1wire daje 2,2k np w ATmega32 zawsze wystarczało.
Program który sprawdzam to:
Code:
Config 1wire = Porte.2
Declare Sub Init
Declare Sub Convallt
Declare Function Decigrades(byval Sc(9) As Byte) As Integer
Dim B As Byte
Dim W As Word
Dim Dg As Integer .
Dim Min1 As Integer
Dim Min2 As Integer
Dim Max1 As Integer
Dim Max2 As Integer
Dim Dsid1(8) As Byte
Dim Dsid2(8) As Byte
Dim Sc(9) As Byte
Cls
W = 1wirecount()
Dsid1(1) = 1wsearchfirst()
Do
Dsid2(1) = 1wsearchnext()
Loop Until Err = 1
If Dsid1(8) = Crc8(dsid1(1) , 7) Then
Locate 1 , 1
Lcd "CRC OK Sensor 1 ID"
Waitms 100
Locate 1 , 1
For B = 1 To 8
Lcd Hex(dsid1(b))
Next
End If
If Dsid2(8) = Crc8(dsid2(1) , 7) Then
Locate 2 , 1
Lcd "CRC OK Sensor 2 ID"
Wait 1
Locate 2 , 1
For B = 1 To 8
Lcd Hex(dsid2(b))
Next
End If
Waitms 100
Cls
Init
' Main loop
Do
Convallt ' "Convert ALL T on the 1w-bus"
Waitus 250 : Waitus 250 : Waitus 250 : Waitus 250 'if you use 2-wire, could be reduced to 200us
1wverify Dsid1(1) 'Issues the "Match ROM "
Locate 1 , 1
If Err = 1 Then
Lcd "Err " 'Err = 1 if something is wrong
Elseif Err = 0 Then 'lcd " Sensor found"
1wwrite &HBE
Sc(1) = 1wread(9) 'read bytes into array
If Sc(9) = Crc8(sc(1) , 8) Then
Dg = Decigrades(sc(9))
If Min1 > Dg Then Min1 = Dg
If Max1 < Dg Then Max1 = Dg
Lcd Dg : Locate 1 , 7 : Lcd Min1 : Locate 1 , 14 : Lcd Max1
End If
End If
1wverify Dsid2(1)
Locate 2 , 1
If Err = 1 Then
Lcd "DsId2 not on bus "
Elseif Err = 0 Then ' lcd " Sensor found "
1wwrite &HBE
Sc(1) = 1wread(9)
If Sc(9) = Crc8(sc(1) , 8) Then
Dg = Decigrades(sc(9))
If Min2 > Dg Then Min2 = Dg
If Max2 < Dg Then Max2 = Dg
Lcd Dg : Locate 2 , 7 : Lcd Min2 : Locate 2 , 14 : Lcd Max2
End If
End If
Wait 1
Loop
End 'end program
Sub Init
Cls
Lcd " Min Max"
Locate 2 , 1
Lcd " Min Max"
Min1 = 999 ' to get a real value from start
Min2 = 999
End Sub
Sub Convallt
1wreset ' reset the bus
1wwrite &HCC ' skip rom
1wwrite &H44 ' Convert T
End Sub
Function Decigrades(byval Sc(9) As Byte)
Decigrades = 0
Decigrades = Makeint(sc(1) , Sc(2))
Decigrades = Decigrades * 10
Decigrades = Decigrades / 16
End Function
Proszę o pomoc w rozwiązaniu problemu.