dual zone thermometer

31

Click here to load reader

Upload: jeran-cloete

Post on 01-Nov-2014

44 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Dual Zone Thermometer

SOUTH AFRICAN ASTRONOMICAL

OBSERVATORY

Dual Temperature Sensor

Date: 17 February 2012

Page 2: Dual Zone Thermometer

P a g e | 2

SAAO - Electronics Department Dual Temperature Sensor

Contents

Introduction

Objectives

Block diagram

Planning

Sensor circuit

Amplifier circuit

Offset circuit

Regulator circuit

Components

Circuit diagram

Summary of Operation

Testing

Conclusion

Appendix

Datasheets

Equations

Source code

Page 3: Dual Zone Thermometer

P a g e | 3

SAAO - Electronics Department Dual Temperature Sensor

Introduction

This report focuses on the development and construction of a dual temperature sensing system,

which interfaces with the internet via the Sparkfun Pro Ethernet microcontroller.

Objectives

The objective of this task was to design and construct a circuit capable of sensing a temperature

(from -10°C to 50°C) and displaying it online (via the Ethernet module of the Sparkfun

microcontroller).

However, the main objective was to familiarise ourselves with the Arduino code and use the

Ethernet connection to display data online.

Page 4: Dual Zone Thermometer

P a g e | 4

SAAO - Electronics Department Dual Temperature Sensor

Planning / Design and Calculations

Block Diagram

Figure 1

Page 5: Dual Zone Thermometer

P a g e | 5

SAAO - Electronics Department Dual Temperature Sensor

Planning

Sensor circuit

Since the circuit we are designing is to sense the temperature, temperature sensing IC’s (integrated

circuits) were necessary.

Most temperature sensing IC’s require a positive and negative supply voltage, this was not

desirable as we planned to use a single power source (positive voltage). We decide on using the

LM3351 IC as it measures in Kelvin, meaning it only operates with positive values.

From the datasheet (LM335), the range of the output voltage is from +2.63VDC to +3.23VDC (-10°C to

50°C) with steps of 10mV per degree Celsius (0°C is equivalent to 273K (+2.73VDC)).

Figure 2.1 [LM335 IC’s]

Page 6: Dual Zone Thermometer

P a g e | 6

SAAO - Electronics Department Dual Temperature Sensor

Amplifier circuit

Selecting the Operational amplifier (Op-amp) IC was challenging as most require a dual supply

(positive and negative) for operation. Hence we chose the LM3242, 4 IC as it only requires a positive

supply voltage.

Because the output voltage range (LM335) is only 600mV (+2.63VDC to +3.23VDC), we decided to

amplify this voltage to achieve a range from 0VDC to +5VDC. This was done to fully utilise the analog

input voltage range of the Sparkfun microcontroller (0VDC to +5VDC).

To calculate the amount of amplification (gain) necessary, the following formula is used

(approximately). From this value, the necessary components for the amplifier circuit

can be realised.

Figure 2.2 [LM324 IC]

Page 7: Dual Zone Thermometer

P a g e | 7

SAAO - Electronics Department Dual Temperature Sensor

Offset circuit

In order to achieve a 0VDC to +5VDC range, +2.63VDC (-10°C) had to be reduced to 0VDC. To do this, an

offset of +2.63VDC was needed for each Op-Amp (one for each temperature sensor).

The offset voltage adjustment circuit was implemented in conjunction with the amplifying circuit, to

reduce necessary components and connections.

Figure 2.3 [Potentiometers for offset]

Page 8: Dual Zone Thermometer

P a g e | 8

SAAO - Electronics Department Dual Temperature Sensor

Regulator circuit

A variable positive voltage regulator was needed (LM3173 IC was sufficient), due to the fact that the

amplifier circuit must be able to output a maximum voltage of +5VDC. The necessary input voltage

(from the offset circuit) was assumed to be at least +5VDC. However, through trial and error, it was

found that the voltage input necessary was actually larger (+6.3VDC in our case). This input voltage

brought about the desired maximum output voltage of +5VDC.

Figure 2.4 [LM317 IC]

Page 9: Dual Zone Thermometer

P a g e | 9

SAAO - Electronics Department Dual Temperature Sensor

Components

Type Value Description Quantity

IC

LM324 Operational amplifier 1

LM317 Positive voltage regulator 1

LM335 Temperature sensor 2

4

Resistor

4K7 Single-turn Pot 1

10K Multi-turn Pot 2

200K Multi-turn Pot 2

120Ω 1% Tolerance 1

3K3Ω 1% Tolerance 2

56KΩ 1% Tolerance 2

6K8Ω 1% Tolerance 2

100KΩ 1% Tolerance 2

330KΩ 1% Tolerance 2

16

Capacitor

10µF Polarised 2

100ηF Non-polarised 4

6

Diode

1N4007 Rectifier 2

Connector

3-Way Molex 3

4-Way Molex 1

2-Way block 1

5

Total 30

Figure 3

Page 10: Dual Zone Thermometer

P a g e | 10

SAAO - Electronics Department Dual Temperature Sensor

Circuit Diagram

Figure 4

Page 11: Dual Zone Thermometer

P a g e | 11

SAAO - Electronics Department Dual Temperature Sensor

Summary of Operation

In order for the voltage regulator to output a regulated voltage of +6.3VDC, a minimum input voltage

of +7.8VDC is needed. For this reason we decided to use a +9VDC power supply as it is commonly

found in electrical stores.

A 9V power supply feeds the regulator which outputs a regulated voltage of +6.3VDC (this in turn

becomes the secondary supply voltage which powers all other components).

The temperatures sensors’ senses the temperature and outputs a temperature dependant voltage.

This voltage is then offset by +2.63VDC and then amplified by a factor of 8.3.

This amplified voltage is then sent to the analog inputs of the microcontroller. The microcontroller

then interprets the voltage(s) in steps, ranging from 0 to 1023 where 0 is equivalent to 0VDC and

1023 is equivalent to +5VDC.

The source code within the microcontroller then converts the steps back to an analog voltage. This

voltage is then inserted into an equation5 which calculates the temperature as a measurement of

Degrees Celsius (°C).

The calculated voltages and temperatures are then displayed on a webpage.

Figure 5 [Sparkfun Pro Ethernet microcontroller in-use]

Page 12: Dual Zone Thermometer

P a g e | 12

SAAO - Electronics Department Dual Temperature Sensor

Testing

To test the operation of the amplifier circuit, we needed to ensure that the input and output

voltages corresponded. For an input of +2.63V, 0V should be output. For an input of +3.23V, +5V

should be output. To ensure a 0V output, the 200KΩ potentiometer (as seen below) must be

adjusted.

According to the equation;

[Refer to figure 6.2]

Gain = 4.089

The reason the gain does not equal 8.3, is because the resistor values used for a gain of 8.3 yielded

incorrect results (outputs).

To calibrate the sensor, the room temperature needed to be known. The Fluke Thermocouple

Module (80TK) was used to sense the room temperature.

Figure 6.1 [Thermocouple Module]

Page 13: Dual Zone Thermometer

P a g e | 13

SAAO - Electronics Department Dual Temperature Sensor

Once this value was known, it was possible to calculate the voltage which should be output from

the sensor. The equation was as follows;

Sensor output = +2.9565VDC [If room temperature = 22.5 °C]

The value being output may, at some point, be incorrect due to the fact that this IC has a tolerance

of ±0.5°C.

Figure 6.2 [Sensor and amplifier circuit]

Displaying the data on a webpage was challenging for three reasons:

1. We had no prior HTML knowledge

2. The USB-to-Serial connector only supplied +3.3VDC, which was insufficient.

3. The microcontroller was unable to upload pictures from the computer to the webpage.

The problem, with regard to the HTML knowledge, was easily resolved as there are many helpful

resources available online6.

The USB –to-Serial connector problem was resolved once we noticed +5VDC may be supplied to the

microcontroller by jumping certain pads below the connector.

The reason pictures were not able to be uploaded was because we were under the impression that

the microcontroller could get the file from the computer and display it online, which is not possible.

This issue was resolved by uploading the images to an image hosting website7, from which the

microcontroller would get the file and display it.

Page 14: Dual Zone Thermometer

P a g e | 14

SAAO - Electronics Department Dual Temperature Sensor

Figure 6.3 [Final Webpage]

Page 15: Dual Zone Thermometer

P a g e | 15

SAAO - Electronics Department Dual Temperature Sensor

Conclusion

In conclusion, the final constructed circuit performed well with respect to theoretical expectations.

At times, the error of half a degree was negligible, as the displayed temperature was accurate to

one tenth of a degree.

From testing, we found that the temperatures were able to be displayed online which meets the

objective of this project.

Page 16: Dual Zone Thermometer

P a g e | 16

SAAO - Electronics Department Dual Temperature Sensor

Appendix

References

[1] Datasheet: LM335 IC (Pg. 20-23)

[2] Datasheet: LM324 IC (Pg. 24-25)

[3] Datasheet: LM317 IC (Pg. 17-19)

[4] Datasheet: Operational amplifier circuits (Pg. 26)

[5] Equation:

[6]HTML Tutorials: http://www.htmlgoodies.com/

[7] Image Host: http://imagehost.co.za/

Source code (Pg. 27-31)

Page 17: Dual Zone Thermometer

P a g e | 17

SAAO - Electronics Department Dual Temperature Sensor

Page 18: Dual Zone Thermometer

P a g e | 18

SAAO - Electronics Department Dual Temperature Sensor

Page 19: Dual Zone Thermometer

P a g e | 19

SAAO - Electronics Department Dual Temperature Sensor

Page 20: Dual Zone Thermometer

P a g e | 20

SAAO - Electronics Department Dual Temperature Sensor

Page 21: Dual Zone Thermometer

P a g e | 21

SAAO - Electronics Department Dual Temperature Sensor

Page 22: Dual Zone Thermometer

P a g e | 22

SAAO - Electronics Department Dual Temperature Sensor

Page 23: Dual Zone Thermometer

P a g e | 23

SAAO - Electronics Department Dual Temperature Sensor

Page 24: Dual Zone Thermometer

P a g e | 24

SAAO - Electronics Department Dual Temperature Sensor

Page 25: Dual Zone Thermometer

P a g e | 25

SAAO - Electronics Department Dual Temperature Sensor

Page 26: Dual Zone Thermometer

P a g e | 26

SAAO - Electronics Department Dual Temperature Sensor

Page 27: Dual Zone Thermometer

P a g e | 27

SAAO - Electronics Department Dual Temperature Sensor

/***********************************************************

Dual Thermometer (online)

February 2012

By: Anees Omar and Adrian Wyngaard

***********************************************************/

//Libraries-------------------------------------------------

#include <SPI.h>

#include <Dhcp.h>

#include <Dns.h>

#include <Ethernet.h>

#include <EthernetClient.h>

#include <EthernetServer.h>

#include <EthernetUdp.h>

#include <util.h>

//----------------------------------------------------------

//-

byte mac[] = 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED ; // MAC (Media Access Control) address of the Ethernet

Board

//-

EthernetClient client;

EthernetServer server = EthernetServer(80); // Port select (port 80 is default for HTTP)

//-

//Bit Definitions-------------------------------------------

#define T1 A0 // Temperature sensor 1 output

#define T2 A1 // Temperature sensor 2 output

//----------------------------------------------------------

//Variables-------------------------------------------------

Page 28: Dual Zone Thermometer

P a g e | 28

SAAO - Electronics Department Dual Temperature Sensor

float tempV1; // Temperature in volts

float tempV2; // Temperature in volts

float temp1; // Temperature in degrees

float temp2; // Temperature in degrees

String s;

//----------------------------------------------------------

//Initialisation--------------------------------------------

void setup()

Serial.begin(9600); // Baud rate (bps)

Ethernet.begin(mac); // Start the Ethernet connection and the server

server.begin(); // Enables the server (Ethernet board) to start listening to clients

Serial.println(Ethernet.localIP()); // Display the Ethernet boards IP address

//----------------------------------------------------------

//Loop------------------------------------------------------

void loop()

client = server.available(); // listen for incoming clients

if (client)

while (client.connected())

Page 29: Dual Zone Thermometer

P a g e | 29

SAAO - Electronics Department Dual Temperature Sensor

if (client.available()) // wait for data coming from the server

//Calculations---------------------------------------

tempV1 = analogRead(T1)/204.8; // Read sensor 1 voltage

tempV2 = (analogRead(T2)/204.8) + 0.02; // Read sensor 2 voltage

temp1 = ((tempV1/7.4)*100) - 10; // calculate temperature 1

temp2 = ((tempV2/7.4)*100) - 10; // calculate temperature 2

//---------------------------------------------------

//HTML Code--------------------------------------------------------------------------------

client.println("<html>");

client.println("<head>");

client.println("<TABLE ALIGN=\"center\" BORDER=\"5\" BORDERCOLOR=\"green\">");

client.print("<TR>");

client.print("<TD>");

client.println("<title> Arduino Online Thermometer </title>"); // Page title

client.println("<meta http-equiv= \"refresh\" content= \"1\">"); // Refresh page every 1 second(s)

client.println("</head>");

client.println("<body align= \"center\" style= background-color:#000000 TEXT= #00FF00>");

//Heading----------------------------------------------------------------------------------

client.println("<h1 align= \"Center\"> SAAO </h1>");

client.println("<h2 align= \"Center\"> ELECTRONICS DEPARTMENT THERMOMETER </h2>");

//Data Table-------------------------------------------------------------------------------

client.println("<TABLE ALIGN=\"center\" BORDER=\"5\" BORDERCOLOR=\"green\">");

Page 30: Dual Zone Thermometer

P a g e | 30

SAAO - Electronics Department Dual Temperature Sensor

client.print("<TR>");

client.print("<TD></TD>");

client.print("<TD align=\"center\" > Analog Voltage </TD>");

client.print("<TD align=\"center\" > Temperature </TD>");

client.print("</TR><TR>");

client.print("<TD align=\"center\" > Outdoor Temperature </TD>");

client.print("<TD align=\"center\" >");

client.print(tempV1);

client.print(" V");

client.print("<TD align=\"center\" >");

client.print(temp1);

client.print((char)223);

client.print("C");

client.print("</TR><TR>");

client.print("<TD align=\"center\" > Indoor Temperature </TD>");

client.print("<TD align=\"center\" >");

client.print(tempV2);

client.print(" V");

client.print("<TD align=\"center\" >");

client.print(temp2);

client.print((char)223);

client.print("C");

client.print("</TR>");

client.print("</TABLE>");

//Footer---------------------------------------------

client.println("<h3 align= \"Center\"> By: Anees and Adrian </h3>");

//End of page----------------------------------------

Page 31: Dual Zone Thermometer

P a g e | 31

SAAO - Electronics Department Dual Temperature Sensor

client.println("<br>");

client.print("</TR>");

client.print("</TABLE>");

client.println("</body></html>"); // End of the web page

//---------------------------------------------------

//-

delay(1); // wait 1 milliseconds before closing connection

client.stop(); // close the connection

//-