DS1820 Temperature Controller using atmega8515 microcontroller

DS1820 Temperature controller

This project displays the temperature on an LCD display with an resolution of 0.06degrees. DS1820 is used for sensing the temperature. It can measure temperature range from -55deg to +125deg. But i take care of only the possitive temperature.
There are 3 switches to change the alarm temperature, the user can increment the Alarm temperature by pressing the UP button and they can decrease the Alarm temperature by pressing the Down button. The Enter button is used to store the Alarm temperature on the microcontroller EEPROM. So that the value retains even after power failure.

Circuit Diagram

DS1820 Temperature controller

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.7
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Porta.2 , Db5 = Porta.3 , Db6 = Porta.4 , Db7 = Porta.5 , E = Porta.1 , Rs = Porta.0
Upbtn Alias Pinb.5
Downbtn Alias Pinb.6
Enterbtn Alias Pinb.7
Alarm Alias Pinc.3
Config Upbtn = Input
Config Downbtn = Input
Config Enterbtn = Input
Config Portc = Output

‘Temp variables
Dim Bd1 As Byte
Dim Bd2 As Byte
Dim Bd7 As Byte
Dim Bd8 As Byte
Dim Alrmtemp 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
‘Read the alarm temperature from EEPROM
Readeeprom Alrmtemp , 10
If Alrmtemp = &HFF Then Alrmtemp = 30
Do
1wwrite &HCC : 1wwrite &H44                              ‘ start measure
Waitms 400                                               ‘ wait for end of conversion
Read1820
Debounce Upbtn , 0 , Uppr , Sub
Debounce Downbtn , 0 , Dwnpr , Sub
Debounce Enterbtn , 0 , Alarmpr , Sub
Waitms 300
Debounce Upbtn , 0 , Uppr , Sub
Debounce Downbtn , 0 , Dwnpr , Sub
Debounce Enterbtn , 0 , Alarmpr , Sub
Waitms 300
Debounce Upbtn , 0 , Uppr , Sub
Debounce Downbtn , 0 , Dwnpr , Sub
Debounce Enterbtn , 0 , Alarmpr , Sub
Waitms 300
Loop
End                                                         ‘end program
Uppr:
If Alrmtemp < 98 Then
Alrmtemp = Alrmtemp + 1
Cls
Lcd “Temp:” ; T1 ; “.” ; T
Lowerline
Lcd “Alarm Temp:” ; Alrmtemp
End If
Return

Read more: DS1820 Temperature Controller using atmega8515 microcontroller

Leave a Comment

Your email address will not be published. Required fields are marked *