einstein wrote:Dear mohammad, you're welcome.
To facilitate the work of those who might help you,
try to write or translate the next topics in Italian language.
Ciao.
deluca wrote:@mohammad,
this is an italian forum, but we could somehow help you.
But first, according to the rules of the forum, you should first introduce yourself in section created for this purpose.
Next, you must indicate which microcontroller and development tools and are using.
Without these elements we can't help you.
Best regards.
einstein wrote:mohammad, prova a postare il codice bascom, intanto iniziamo da li,
poi cercheremo di capire i problemi dell'hardware.
ciao
$regfile = "m8adef.dat"
$crystal = 1000000
$hwstack = 40
$swstack = 16
$framesize = 32
Config Lcdpin = Pin , Rs = Portb.1 , E = Portb.2 , Db4 = Portb.3 , Db5 = _
Portb.4 , Db6 = Portb.5 , Db7 = Portb.6
Config Lcd = 16 * 2
Config 1wire = Portb.0
Deflcdchar 0 , 8 , 20 , 8 , 32 , 32 , 32 , 32 , 32
Dim Read__(8) As Byte
Dim A__ As Integer
Dim B__ As Single
Cls
Cursor Off
Lcd " DS18B20 Sensor"
Do
If Err = 1 Then
Cls
Lcd "Err"
Do
Loop
Else
1wreset
1wwrite &HCC
1wwrite &H44
Waitms 800
1wreset
1wwrite &HCC
1wwrite &HBE
Read__(1) = 1wread(8)
Wait 1
A__ = Makeint(read__(1) , Read__(8))
B__ = A__ / 16
Lowerline
Lcd Fusing(b__ , "#.&") ; Chr(0) ; "C"
End If
Loop
End
'*******************************************
'* Compiler : BasCom *
'* Hardware : AVR-Ctrl *
'* Temp.Sens : DS1820 *
'* Chip type : MEGA128 *
'* Clock frequency : 16,000000 MHz *
'*******************************************
$regfile = "m128def.dat"
$crystal = 16000000
Config 1wire = Portc.0 'use this pin
Dim Ar(2) As Byte , A As Byte , I As Byte , Temperatur As Integer
Dim Halb As Byte
Cls
Lcd "Temp:"
Do
Waitms 300
1wreset 'reset the device
1wwrite &HCC 'read ROM command
1wwrite &H44
Waitms 200 'read ROM command
1wreset 'reset the device
1wwrite &HCC 'read ROM command
1wwrite &HBE 'read ROM command
For I = 1 To 2
Ar(i) = 1wread() 'place into array
Next
Locate 2 , 1
Temperatur = Ar(1)
If Ar(2) > 0 Then Temperatur = 0 Else Shift Temperatur , Right
Lcd Temperatur ; ".";
Halb = Ar(1) And 1
If Halb = 1 Then Lcd "5" Else Lcd "0"
Lcd " C"
Loop
End
deluca wrote:@mohammad,
prova a modificare questo codice per il tuo micro. Ti assicuro che funziona benissimo su ATmega128
- Code: Select all
'*******************************************
'* Compiler : BasCom *
'* Hardware : AVR-Ctrl *
'* Temp.Sens : DS1820 *
'* Chip type : MEGA128 *
'* Clock frequency : 16,000000 MHz *
'*******************************************
$regfile = "m128def.dat"
$crystal = 16000000
Config 1wire = Portc.0 'use this pin
Dim Ar(2) As Byte , A As Byte , I As Byte , Temperatur As Integer
Dim Halb As Byte
Cls
Lcd "Temp:"
Do
Waitms 300
1wreset 'reset the device
1wwrite &HCC 'read ROM command
1wwrite &H44
Waitms 200 'read ROM command
1wreset 'reset the device
1wwrite &HCC 'read ROM command
1wwrite &HBE 'read ROM command
For I = 1 To 2
Ar(i) = 1wread() 'place into array
Next
Locate 2 , 1
Temperatur = Ar(1)
If Ar(2) > 0 Then Temperatur = 0 Else Shift Temperatur , Right
Lcd Temperatur ; ".";
Halb = Ar(1) And 1
If Halb = 1 Then Lcd "5" Else Lcd "0"
Lcd " C"
Loop
End
deluca wrote:Il programma che ti ho postato funziona perfettamente
https://www.dropbox.com/s/47bm1nyaqtw9gs2/DS1820.jpg
Qui il valore della temperatura viene trasmesso sulla seriale.
Quindi, controlla i tuoi collegamenti e le alimentazioni. Nel caso in cui il problema si presenti ancora, prova ad accorciare il collegamento tra il micro e il sensore, oppure prova ad abbassare il valore della res-pullup.
Users browsing this forum: No registered users and 3 guests