Task 8

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Leonardo Diaz Martinez

Sec 077L

UNIVERSITY OF PUERTO RICO


MAYAGÜEZ CAMPUS – COLLEGE OF ENGINEERING
MECHANICAL ENGINEERING DEPARTMENT

MECHATRONICS LABORATORY
INME4235
TASK: Closed Loop Temperature Control Using One-Wire
Temperature Sensor and Arduino Microcontroller
OBJECTIVE:
The purpose of this task is to learn how an Arduino microcontroller can be used to measure tem -
perature using a digital temperature sensor and external libraries uploaded to the Arduino. Stu-
dents will also learn how to build a temperature control circuit using the digital temperature sen-
sor, a thermoelectric heater, a DC fan, and relays. The Arduino will be programmed to control
the temperature within a given temperature range.

MATERIALS:
1. Arduino Microcontroller
2. DS18B20 One-wire Temperature sensor
3. Relays
4. DC Fan
5. Peltier heater
6. Breadboard
7. Jumper wires
8. 4.7kΩ resistor
9. Power supply
Leonardo Diaz Martinez
Sec 077L

(a) (b)

Figure 1. Closed loop temperature control system (a) schematic and (b) components.
Part I. Connecting and programming the OneWire
Figure 1 represents the closed loop temperature control system setup. The OneWire is a digital
temperature sensor that requires the use of an external library, which can be installed using your
Arduino software. You can use the Library Manager to install a library into the Arduino. Open the
IDE and click to the "Sketch" menu and then Include Library > Manage Libraries. You may also
add a library manually by downloading the library as a ZIP file, expanding the folder, and placing
it in the proper Arduino directory. A tutorial for both methods may be found here:
https://www.arduino.cc/en/guide/libraries.
IMPORTANT NOTE: Make sure to have the latest version of Arduino,
https://www.arduino.cc/en/Main/Software
Once the files are installed, proceed to connect the DS18B20 as shown in Figure 2. Notice the
4.7kΩ pull-up resistor connected between the DQ and VDD pins.
#include <OneWire.h>
OneWire ds(2); // on pin 2

(a) (b)
Figure 2. (a) OneWire Arduino connections. (b) OneWire pin layout.
Leonardo Diaz Martinez
Sec 077L

(5 points) Each student will install the external library. Take pictures of the library install window
and include in Task document.

(5 points) Each student will connect the OneWire sensor as required by the datasheet. Take
pictures of the OneWire connected to the breadboard and Arduino and include in Task
document.

Write a program to obtain temperature measurements from the OneWire. Make sure the
OneWire is sending temperature data to the Arduino, no need to copy/paste code yet, this will
occur later.

(10 points) Include pictures of the sensor and serial monitor showing temperature
measurements.
Leonardo Diaz Martinez
Sec 077L

R= 4.61
Part II. Connecting the Peltier heater, DC fan, relays, and sensor

Assemble the circuit shown in Figure 3, which shows the temperature sensor connected to the
Arduino following datasheet specifications, the relays that control the loads and are connected
to the Arduino, and each load connected to the external power supply.

(10 points) Each student will develop their own circuit. Take pictures of the circuit and include in
Task document.

Figure 3. Hardware connection schematic.


Make sure that the One-Wire is measuring temperature before the external power supply is
turned on, since otherwise the heater temperature may increase quickly and dramatically. The
power supply is represented as an equivalent 12V battery setup in Figure 3. Figure 3 shows that
the positive end of both the fan and the heater are connected to the positive pole of the power
supply. Connect the other end of both the fan and heater to the “common” of its corresponding
relay. Connect the negative polarity of the power supply to either the “normally open” or
“normally closed” (this will depend on the relay being used and the program being developed).
Connect both relay coils to an Arduino pin and ground.
Leonardo Diaz Martinez
Sec 077L

(20 points) Adapt your program to maintain a controlled temperature range in the system by
turning ON the heater and turning OFF the fan when heat is needed and turning OFF the heater
and turning ON the fan when cooling is needed.

The heater should elevate the temperature until the range’s upper limit is met and then be
coordinated to switch off as the fan is turned on to cool the system until the temperature range’s
lower limit is met. The heater should again turn on and the fan should turn off as the
temperature falls below the lower temperature limit. Both systems are switching their on/off
state to maintain temperature equilibrium within the system.

Copy/paste the code from Arduino to your Task document. Explain code (either line by line using
comments or by blocks of code that carry out some function). DO NOT use screenshots, rather
copy/paste text.

Experimental Measurements

Using the Arduino code, take the temperature measurements using the Arduino microcontroller
as the system maintains equilibrium in a selected temperature range. Choose a three-degree
range, anywhere between 27ºC and 35ºC; for example, control between 27ºC and 30ºC or
between 32ºC and 35ºC.

Use (30 points) Table 1 to record the One-Wire temperatures as the heater is turned on and off.
Compare these experimental values to the temperature range’s upper and lower limits
programmed in the Arduino, find the error (%e) between these two values.

(30 points) Table 1. Temperature control experimental measurements.


Arduino Programmed
Cycle Begin process DS18x20 temperature %e
temperature
Heating 27
1
Cooling 30
Heating 25
2
Cooling 31
Heating 28
3
Cooling 32

(20 points) Plot the heating and cooling data for at least three ON/OFF cycles. Hint: Normalize
time data to zero, i.e. the plotted data begins at zero. Include this data in your report.

You might also like