Problems with Microcontroller Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you the Codes for Registered Members of this site only, at free service...Follow Me.

Temperature Indicator project

This project indicates the temperature from a 1 wire temperature sensor DS1820 and display it over an LCD display. The circuit uses Atmega8515 and 16x2 LCD display. Atmega8515 is selected because it is pin compatible with 8051 Microcontroller. ATmega uses the inbuilt RC oscillator for this project, so select the fuse bits for internal oscillator of 8Mhz.

About DS1820


The DS1820 Digital Thermometer provides 9–bit centigrade temperature measurements and has an alarm function with nonvolatile user-programmable upper and lower trigger points. The DS1820 communicates over a 1-wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor. It has an operating temperature range of –55°C to +125°C and is accurate to ±0.5°C over the range of –10°C to +85°C. In addition, the DS1820 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.

Circuit Diagram

Program

'----------------------------------------------------------------------------------------- 'copyright : (c) 2008-2009, AVRprojects.info 'purpose : DS1820 / DS18S20 Temperature Indicator '----------------------------------------------------------------------------------------- 
$regfile = "m8515.dat" ' specify the used micro $crystal = 8000000 ' used crystal frequency 
Declare Sub Read1820
Config 1wire = Portd.Config Lcd = 16 * 2 Config Lcdpin = Pin , Db4 = Porta., Db5 = Porta., Db6 = Porta., Db7 = Porta., E = Porta., Rs = Porta.0

'Temp variables Dim Bd1 As Byte Dim Bd2 As Byte Dim Bd7 As Byte Dim Bd8 As Byte 
Dim I As Byte , Tmp As Byte Dim T As Integer , T1 As Integer Dim Bd(9) As Byte 'Scratchpad 0-8 72 bits incl CRC, explanations for DS1820 'Sc(1) 'Temperature LSB 'Sc(2) 'Temperature MSB 'Sc(3) 'TH/user byte 1 also SRAM 'Sc(4) 'TL/user byte 2 also SRAM 'Sc(5) 'config also SRAM x R1 R0 1 1 1 1 1 - the r1 r0 are config for resolution - write FF to byte for 12 bit - others dont care 'Sc(6) 'res 'Sc(7) 'res 'Sc(8) 'res 'Sc(9) '8 CRC 
'DALLAS DS1820 ROM and scratchpad commands''''''''''''''''''''''''''1wwrite.... '&H 33 read rom - single sensor '&H CC skip rom '&H BE read scratchpad '&H 44 convert T 
' Main loop Cls Cursor Off Do
1wwrite &HCC : 1wwrite &H44 ' start measure
Waitms 400 ' wait for end of conversion
Read1820
Wait 1 Loop End 'end program 
'Read the DS1820 by skipping the ROM checking, since we are using only 1 sensor 
Sub Read1820 ' reads sensor ans calculate ' T for 0.1 C
1wreset ' reset the bus
1wwrite &HCC ' read internal RAM
1wwrite &HBE ' read 9 data bytest
Bd
(1) = 1wread(9)
Bd1 
= Bd(1)
Bd2 
= Bd(2)
Bd7 
= Bd(7)
Bd8 
= Bd(8)
' read bytes in array
1wreset ' reset the bus
Tmp 
= Bd1 And 1
If Tmp = 1 Then Decr Bd1 ' 0.1C precision
= Bd1
= T * 50
= T - 25
T1 
= Bd8 - Bd7
T1 
= T1 * 100
T1 
= T1 / Bd8
= T + T1
T1 
= T / 100 'store tens
= T Mod 100 'store decimal number
Cls
Locate 1 , 3
Lcd "Temperature"
Locate 2 , 7
Lcd T1 ; "." ; T End Sub 
End

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Recent Comments

Popular Projects

Give Support

Give Support
Encourage Me through Comments

Microcontroller Projects

Total Pageviews