Interfacing DS1620 with PIC Microcontroller

 Project Over View:

In this project we are interfacing DS1620 chip with the PIC Microcontroller. The Temperature will be read from DS1620, its feature for indication of high , low temperature will also be used. 

Description of DS1620:

The DS1620 is a single chip having two major functionalities combine together named Digital Thermometer and the Thermostat. The DS1620 provides 9bit temperature measurement results the temperature of this chip corresponds to the environmental temperature. The second functionality is thermostatic control with the three alarm outputs correspond to three set points which are also programable. Due to the provision of this feature in this chip, we can say that the DS1620 can be used as a thermostat. The name of the three alarms pins are THIGH, TLOW and TCOM. The THIGH pin will be high if the temperature is greater than or equal to defined temperature named TH. The TLOW pin will be high if the measured temperature is less than or equal to predefined temperature named TL. The TCOM pin will be high when the measured temperature is greater than TH and will remain high until the measured temperature is lesser than TL.

The predefined temperature values for TH and TL are saved in the nonvolatile memory of DS1620.It may be noted that these values can be programmed any time during the execution while going through the procedure for updating these values to DS1620 by using microcontroller. If DS1620 is going to be used as a stone alone system, then these values will be programmed first, so that chip can perform proper operation as required by user. The predefined Temperature values of TH and TL can be written or read to or from the chip DS1620 by using the simple 3 wire interface.

The chip DS1620 measures the temperature using a built-in temperature sensor. The measured temperature value is available to read in a specific format which is a 9bit and two’s complement. The measured values are only possible to read by proper utilization of a “READ TEMPERATURE” command. After receiving the “READ TEMPERATURE” command by DS1620 the measured temperature value is transmitted serially LSB first. The chip DS1620 is usable to measure temperature in the range of -55°C to +125°C with the increment of 0.5°C. The temperature in degree Celsius can be converted to Fahrenheit using a lookup table or conversion factor.

OPERATION AND CONTROL OF DS1620

There is configuration register in the DS1620 which is required to address properly before expecting any useful operation from the chip. The configuration register of DS1620 is defined as under:

Configuration Register of DS1620
Configuration Register of DS1620

The values of this register is explained as under:

DONE is the Conversion Done Bit the value in this bit shows logical 1 if the conversion is completed the logical 0 will show that the conversion is in progress. Then the next bit comes it is THF which corresponds to the Temperature High Flag. This bit will be set to logical level 1 when the measured temperature is greater than or equal to the predefined value of TH. This bit will remain at logical level 1 until reset by writing 0. This is very useful feature which provides a way to determine if the DS1620 has ever high temperatures above TH since it is powered up. The next bit is TLF which corresponds to the Temperature Low Flag. This bit will be set to logical level 1 when the measured temperature is less than or equal to the predefined value of TL. It will remain at the logic level 1 until reset by writing 0. This is a very useful feature of DS1620 which provides a way to determine if the chip measured temperature below TL since powered up. The next bit is NVB which corresponds to the Nonvolatile Memory Busy Flag. The logical level 1 indicates that the writing to memory cell is in progress. Whereas the logical level 0 means that the nonvolatile memory is not busy at this time. The next bit is CPU corresponds to the CPU Use Bit. If CPU is 0, the CLK and / or CONV pin will act as the conversion start control. If CPU is 1, the DS1620 will be used with a CPU communication using the 3 wire port protocol.

Components used in Thermostat Project:

  1. Microcontroller : PIC 16f876A
  2. DS1620, The Digital Temperature sensor and Thermostat
  3. Crystal: 4MHz
  4. Capacitors: 22pF x 02Nos
  5. LCD: The liquid crystal Display; 2line 16 Character
  6.  Resistors: as required and shown in diagram
  7. Power Supply: +5V regulated DC power supply
  8. LEDs: 03Nos of different colors
  9. push button as required
  10. Variable resistors: as required and shown in diagram.

circuit diagram of DS1620 interface with PIC Microcontroller 16F876A:

The following is the circuit diagram in which the electrical connection of various components is described and DS1620 is interfaced with Microcontroller 16f876A along with the other components. The LEDs of three different colors are used to show the functions of thermostat of DS1620. The red LED indicates the high temperature then user defined temperate set value if occur. The Orange LED indicates the low Temperature than the user defined set value if occur. The green LED indicates the normal behavior of thermostat.
DS1620 PIC 16f876A
Circuit diagram of the Digital Thermometer and Thermostat

Software part of project:

The Proton plus basic compiler is used for the coding of this project and source code is placed below:
'*****************************************************************
'*Name : DS1620_PIC16f876A.BAS                                   *
'*Author : Dr.Rana                                               *
'*Notice : https://microcontroller-atmel-pic-avr.blogspot.com/   *
'*: All Rights Reserved                                          *
'*Date : 9/4/2022                                                *
'*Version : 1.0                                                  *
'*Notes :                                                        *
'*:                                                              *
'*****************************************************************
' Display the temperature from a Dallas DS1302 sensor
'
' For use with the ISIS 16F628 Virtual Evaluation Board.
 Device = 16F876A ' PIC 16f876A is selected for this project
 DECLARE Xtal = 4 ' Crystal used in this project is 4MHz
 ''LCD is used in 4 bit interface Mode, Upper four I/O lines
 '' of PortB are connected to the Upper four data lines of LCD
 DECLARE LCD_DTPin = PORTB.4 ' 4 bit LCD interface 
 DECLARE LCD_RSPin = PORTB.1 ' LCD RS PIN connection
 DECLARE LCD_ENPin = PORTB.2 ' LCD E PIN connection
 DECLARE LCD_Interface = 4 ' 4-bit Interface
 DECLARE LCD_Lines = 2 ' 2-Line LCD
 DECLARE LCD_Type = 0 ' Alphanumeric LCD type
' Define DS1620 Pins
 Symbol DQ = PORTC.5 ' DQ = Data pin
 Symbol CLK = PORTC.6 ' CLK = Clock pin
 Symbol RST = PORTC.7 ' RST = Reset pin
' Define Variables
 DIM DSdata AS Word ' Word variable to hold 9-bit data.

' Define variables
 DIM IdCt AS Byte
 DIM HighVal2 AS Byte
 DIM LowVal2 AS Byte
' Define Constants for DS1620 configuration
 Symbol Rconf = $AC ' Read Configuration
 Symbol Wconf = $0C ' Write Configuration
 Symbol CPUon = %10 ' Operate with Microcontroller mode
 Symbol Cont = %00 ' Continuous conversions on start
 Symbol StartC = $EE ' Start Conversion
 Symbol Rdtemp = $AA ' Read Temperature
 ' Define Thermostat functions
 Symbol RhiT = $A1 ' Read High-Temperature Setting
 Symbol WhiT = $01 ' Write High-Temperature Setting
 Symbol RloT = $A2 ' Read Low-Temperature Setting.'
 Symbol WloT = $02 ' Write Low-Temperature Setting.'
 DIM HighVal AS Byte = $32 
' High Temperature Setting 25C for Thigh
 DIM LowVal AS Byte = $31 
' High Temperature Setting 24C for Tlow
'----------------------------------------------------------
' Define Push Button Interface
 Symbol Sw1 = PORTC.4 ' Sw1 = Mode Switch "Push Button"
 Symbol Sw2 = PORTC.3 ' Sw2 = Increment the variables
 Symbol Sw3 = PORTC.2 ' Sw3 = Decrement the variables 

' Start of main Program
 DECLARE All_Digital = ON 
' All analog PINs will be treated as Digital
 CLS ' Clear the LCD
 LowVal2 = ERead 0 
' Read the stored data in EEPROM Built in MCU 
 HighVal2 = ERead 1 
' Two bytes are just stored for temperature 
settings
 OUTPUT RST ' Make the RST pin an output
 OUTPUT CLK ' Make the CLK pin an output
 INPUT Sw1 ' push Button Switches are declared as input to MCU
 INPUT Sw2
 INPUT Sw3
 PRINT At 1,1, "WELLCOME"
 PRINT At 2,1,"DS1620 Interface"
 CLEAR RST ' Shutdown the DS1620
 DelayMS 1 ' Time for reset to occur
 Set RST ' Get ready to write data
 SHOut DQ,CLK,LsbFirst,[Wconf\8,CPUon|Cont\8] 
' Set configuration
 CLEAR RST ' Reset teh DS1620
 DelayMS 50
 Set RST
 SHOut DQ,CLK,LsbFirst,[StartC\8] 
' Start a conversion
 CLEAR RST ' Reset the DS1620
' Writes the config byte for THigh, set for 25C
' With a LED connected THigh pin 7, 
'at 25C or higher the LED will light.
 DelayMS 50
 HighVal = HighVal2 << 1 
' the normal number is converted to two complement
 Set RST
 SHOut DQ,CLK,LsbFirst,[WhiT\8,HighVal\9]
 CLEAR RST
' Writes the config byte for the TLow, set for 24C
' With a LED connected TLow pin 6, 
'at 24C or below the LED will light.
 DelayMS 50
 LowVal = LowVal2 << 1 
' the lower value is converted to two complement
 Set RST
 SHOut DQ,CLK,LsbFirst,[WloT\8,LowVal\9]
 CLEAR RST
 
 DelayMS 1000
 CLS
 DelayMS 1
 IdCt = 0
' Start loop, reads temperature. Loop forever
 WHILE 1 = 1
 DelayMS 100 ' Wait 0.1 second between readings
 IF Sw1 = 0 THEN Inc IdCt ' index function for menu
 IF IdCt >=3 THEN IdCt = 0
 SELECT IdCt
 CASE 0
         IdCt = 0
 CASE 1
        CLS
        IF Sw2 = 0 THEN Inc HighVal2
        IF Sw3 = 0 THEN Dec HighVal2
        IF HighVal2 >=99 THEN HighVal2 = 1
        IF HighVal2 <= 0 THEN HighVal2 = 99
        DelayMS 100
        HighVal = HighVal2 << 1
        Set RST
        SHOut DQ,CLK,LsbFirst,[WhiT\8,HighVal\9]
        CLEAR RST
        EWrite 1, [HighVal2]
 
 CASE 2
         CLS
         IF Sw2 = 0 THEN Inc LowVal2
         IF Sw3 = 0 THEN Dec LowVal2
         IF LowVal2 >= 99 THEN LowVal2 = 1
         IF LowVal2 <= 0 THEN LowVal2 = 99
         DelayMS 100
         LowVal = LowVal2 << 1
         Set RST
         SHOut DQ,CLK,LsbFirst,[WloT\8,LowVal\9]
         CLEAR RST
         EWrite 0,[LowVal2]
 CASE ELSE
         DelayMS 100
         IdCt = 0
 EndSelect
 
 CLEAR CLK
 Set RST ' Start the DS1620
 SHOut DQ,CLK,LsbFirst,[Rdtemp\8] ' Request temperature
 SHIn DQ,CLK,LsbPre,[DSdata\9] ' Get temperature
 CLEAR RST
 PRINT At 1,1,"LTp ",Dec LowVal2,"C"
 PRINT At 1,9,"HTp ",Dec HighVal2,"C"
 DSdata = DSdata >> 1 ' Shift the sign bit into the 
correct position
 ' Display signed temperature in Celsius.
 PRINT At 2,1,"RTp ",Dec DSdata.LowByte,"C"
 PRINT At 2,16, Dec IdCt
 WEND
''Microcontroller PIC16F876A has built in EEPROM 
'The user defined values for High Temperature and 
'Low Temperature limits
' are being stored in EEPROM of MCU
 EData AS Byte 25, 30


temperature sensor interfacing using adc and i2c with pic microcontroller projects interfacing lm35 with microcontroller. How to interface temperature sensor with PIC microcontroller? LM35 interfacing with PIC16F877A pic microcontroller projects pdf How to connect temperature sensor to microcontroller? What is DS1620? Digital Thermometer Ds1620& Pic | PDF | Microcontroller ds18b20 temperature sensor with pic microcontroller projects for beginners Appkit: DS1620 Digital Thermometer, pic, PIC Microcontroller based Dallas DS18S20, What is temperature sensor interfacing?, Temperature sensor using PIC16F877A microcontroller, Digital Thermometer using a PIC Microcontroller, Interfacing the DS1620 with a DS5000/8051 Microcontroller, DS18S20 interfacing with pic and avr microcontroller, Interfacing Temperature Sensor (DS1620) with AT89S51, Interfacing Temperature sensor with lcd, Interfacing at89c2051 & PCF8591 in displaying temperature, pic microcontroller projects pdf, pic microcontroller projects for beginners, temperature sensor interfacing using adc and i2c with pic, pic16f877a projects with source code pdf, ds18b20 temperature sensor with pic, pic projects with source code, Temperature sensor using PIC16F877A microcontroller, LM35 interfacing with PIC16F877A, 

Popular Post (All Time)