Digital Thermometer

EE 331 Final Design Report

12/1/2009

University of Saskatchewan

Anna Thomas

Jose Cheruvallath

Introduction:

We have designed a digital thermometer using the concepts we learnt in our EE331 class to interface a Microchip PIC16F886 microcontroller with an external analog temperature sensor (National Semiconductor, device LM35DZ). The temperature output was made to display the temperature in degrees Celsius.

The LM35DZ temperature sensor comprises of a precision integrated-circuit whose output voltage is linearly proportional to the Celsius temperature. Thus, due to this convenience of having the output voltage calibrated to a Celsius reading, the voltage output is typically a low value when compared to the higher numbers displayed by sensors having Fahrenheit related outputs. The relative ease of having a three pin sensor is countless, as circuit connections are made simpler.

The Microchip PIC16F886 microcontroller is an efficient controller which is suitable for a mini scale project such as ours. It is capable of analog to digital conversion, and provides for several calculation tasks that have enabled us to display the temperature. With the use of 7 segment led displays, outputs from the microcontroller have been displayed as decimal numbers depicting the current temperature.

Understanding our task:

We considered this task of most importance towards implementing a working prototype of our design. Our first priority was to try and implement our design using a Microchip PIC16F886 microcontroller which is readily available in our labs. Keeping this in mind, we started to add components together with an attempt to finally have a working digital thermometer.

It was evident that we were in need of some sort of sensor would be required for temperature collection which would then be fed into the system as the input. Upon talking with James from the electrical department, we were made aware of a digital sensor (Maxim DS1620) which would read and give a corresponding digital output via a 3 wire connection. Our preliminary efforts towards our design were spent in learning how this sensor worked and communicated with a microcontroller.

We also realized that if we were going to display the temperatures accurately we would need several 7 segment displays. Unfortunately, due to the restriction on the number of output ports available on our chosen microcontroller, we needed some sort of external manipulation in order to use more 7 segment displays. Professor W. Khan, suggested that we could make use of latches or flip flops to store the latch the outputs to corresponding 7 segment displays thereby providing an efficient use of minimum output ports.

Thus, our first design for the project included 6 quad transparent latches (Semiconductor Components Industries, IC -MC14042BCP), which enabled us to display on three 7 segment led displays. Unfortunately, things are always easier said than done. The idea of using latches to hold output data values was discarded due to the complexity in connecting up the circuit on the circuit board provided to us from the electrical department. Our first prototype of our design was the complete circuit which contained a PIC16F886 microcontroller, 4 7segment led displays, 6 quad type D-latches and the DS1620 temperature sensor.

However, due to connection difficulties, and delay/interference with noise through wiring we decided to discard this prototype. A picture of our first prototype is enclosed below depicting an image of the circuit which was ultimately discarded due to the simple reason that encountered several glitches, and delays in transferring data to the 7 segment led’s.

Prototype 1 (Discarded due to delay and glitches caused due to noise)

Thus we decided to discard the use of latches as we were advised to implement our circuit keeping the components as close as possible to reduce errors due to noise. Without the presence of latches, we were not able to light up the required number of led’s using our chosen PIC microcontroller.

Our design circuit had to be changed to accommodate for the loss of the latches. Thus we reduced the number of 7 segment displays to be used by two, and decided to have two working 7 segments to display temperature readings anywhere in the range of 0 to +100 degrees Celsius.

Having consulted with Mr. James and Ramin from the electrical department, we spent a great deal of time trying to make sure we were communicating with our various devices correctly. Our display modules were up and running, capable of displaying any number within a range of 0 to 99 decimal values, while we tried to establish a successful communication with our sensor (DS1620). After several fruitless hours of troubleshooting, we decided to check our corresponding outputs to the sensor via a logic analyzer. We seemed to be sending the correct information using appropriate delays as stated in the DS1620 datasheet, but we got no response from the sensor, which was confirmed from waveforms observed on scope.

Data being sent to DS1620 sensor (top to bottom: Data_line,clk,rst)

Data being sent to set a pin in DS1620 to set a pin connected to a LED, but this test also failed. Hence we concluded that the sensor was bad (top to bottom: Data_line,clk,rst)

Thus we were now convinced that the DS1620 chip we had was non functional and hence it had to be discarded. Given the little time remaining prior to our scheduled demonstration, we chose an analog sensor manufactured by National Semiconductor (device - LM35DZ). This sensor chip being analog would now give us an analog input which needs to be converted to a digital value via the ADC module in the PIC microcontroller. The operating range of this sensor enables us to measure a temperature reading in the range of 2 degrees to over +100 degrees Celsius.

Final design prototype:

After several fruitless design implementations using latches and a digital temperature sensor, we arrived at our final design schematic which comprises of the least of devices used, while still providing an accurate but relatively simple digital thermometer capable of measuring temperature reading from 2 to 99 degrees Celsius and displaying it on two 7 segment led displays. Having only 2 displays meant that when we had a decimal point lit up, it implies a degree Celsius reading of +0.5 Celsius.

Rationale of choosing the MCU:

We decided to choose the PIC16F886 microcontroller for several reasons:

  • Available in the labs
  • Cheap
  • Had the right number of I/O pins for our design to light up enough number of LEDs
  • Easy to program – programmed using assembly language
  • Fewer instructions - there were only 35 instructions

Key features of the design:

1) Simple circuit containing only two 7 segment led’s, where the decimal point if lit up if we have 0.5 degrees Celsius. We have not displayed a decimal digit merely due to the fact that the decimal point value is not precise due to our error margin within the range ±0.5 degrees Celsius

2) Relatively consistent, and accurate analog sensor, which has given us consistent temperature reading in Celsius

3) SI units of temperature scale displayed (Celsius), less hassle direct output

4) Temperature reading is held for 30 seconds, before displaying a ‘ - - ‘ indicating next temperature reading is going to be displayed

5) Displays room temperatures within the range from 2 to +99 degrees Celsius

Our Design:

Design schematic:

Block diagram of our design

The schematic of the mini scale project we designed is shown above. The schematic design comprises of three main parts mainly:

a) PIC 16F886 microcontroller – which is a 8 bit microcontroller sufficient for performing control tasks required by our design

b) Temperature sensor LM35DZ – an analog sensor, capable of measuring the degree Celsius temperature of its surrounding

c) Two 7 segment displays (common cathode LDS-C512RI) – a set of led’s arranged in such a manner making it capable to display a number based upon having the appropriate led’s lit up

d) 15 - Resistors (270 Ω)

The microcontroller we used is PIC16F886. It is a 28 pin microcontroller with 24 I/O pins. The main functionality of the microcontroller is to get the analog data from the temperature sensor and convert it into a digital output and make it available for the LEDs to display the temperature readings. The MCU is programmed using the assembly language. The maximum output current sunk and sourced by an I/O pin is 25 mA.

The PIC16F886 microcontroller is sensitive to its input voltage. The maximum supply voltage to it can only be +5 V. Thus the input voltage is regulated from the source to be no more than 5 V dc.

The temperature sensor on the other hand, has an input voltage from the range from 4 to 30 V. Thus, we were capable of using the same input voltage that was fed to the microcontroller (+5 V dc). The outputs on the other hand are connected to led’s. As a safety procedure to ensure that the led’s are never subjected to currents above 25 mA as stated in the data sheet, we placed resistors of 270 ohms across each of the output lines leading to the 7 segment displays. The picture below shows the rating specifications for the 7 segment displays as taken from the datasheet for the device (diagram on next page).

Picture illustrating 7 segment display ratings (from device’s datasheet)

Understanding the digital value being stored through the ADC module of PIC16F886:

The ADC module in pIC16F886 is a 10bit ADC convertor. Thus an analog signal will be converted and represented by a 10 bit binary number. A 10 bit number can hold a maximum decimal number equivalent of 1024. So we have measurements ranging from 0 to 1023 digital reading.

From the datasheet for the analog temperature sensor, it is given that the sensor gives a corresponding output voltage of 10mV per degrees Celsius temperature reading. Also the pictures shown below are taken from the datasheet for the sensor LM35DZ.

The picture above is a representation of how we used the sensor in our design implementation.

Pictures taken from the datasheet showing the linearity in output current, voltage and temperature accuracy are shown below.

Pictures taken from datasheet for LM35DZ temperature sensor illustrating linearity of curves

Calculating the digital value equivalence:

Settings in PIC16F886 for ADC module,

Vref set to +Vdd (+5V)

Vss set to ground

Thus ADC conversion formula is:

Where X is the digital reading received after ADC conversion. The numerator terms comprise of the Vref voltage (+5V) multiplied by 100 (because 10mV is given per degrees Celsius).

Thus, the result of this equation can be approximated to be equivalent to,

Thus dividing the ADC converted value by 2, gives us the binary equivalent of the temperature reading in degrees Celsius. By dividing by 2, we will always get either a remainder of 0 or 1, which is equivalent to a degrees Celsius reading of 0.0 or 0.5 degrees. Thus we claim our designed thermometer to have an accuracy of ±0.5 degrees.

Design Shortcomings:

1) Enhance ability to measure temperatures below 2 degrees Celsius, basically negative temperatures

2) Ability to enhance accuracy to 0.1 degrees Celsius, by having more precise conversions by ADC module

3) Ability to display temperature reading in degrees Fahrenheit if desired

4) Make it even more compact and portable

Tasks performed by group members:

Anna Thomas:

  • Studied how the temperature sensor works
  • Building the circuit and circuit diagrams
  • Studied the devices used in the circuit – through the datasheets
  • Helped in coming up with a final efficient circuit
  • Temperature sensor programming

Jose Cheruvallath:

  • Coded the digital thermometer (sensor and display) using assembly in MPlab
  • Design troubleshooting (sensor failures, new sensor implementation)
  • Helped in building our design circuit
  • Helped in documentation of our work and process
  • Analog to digital conversion calculation

List of files included in final folder sent:

1) MPlab project folder “Project_Anna_Jose_MPlab”

2) Final report file – Report.docx (includes schematic diagram)

References

Microchip PIC16F886 datasheet referenced throughout our project. Referenced from

7 segment led display data sheet referenced from

National Semiconductor Temperature sensor LM35DZ datasheet referenced from