Lab 4 due 12/4
We will predict and measure the time response of a thermal system to a step change in temperature. We will also be working with Arduino.
!!! Since you will be working in your home environment with potentially hazardous items like soldering iron, glue gun, hot water and sensitive equipment like Arduino, computers and temperature sensor, we caution you to extra careful and attentive to prevent any physical damage to yourself, the equipment or your working environment. !!!
Make sure that you read the instructions carefully and thoroughly before you start the experiment, and follow them to the dot!
Chapter 4 in the textbook on comparing mathematical models to experimental observations.
“Using figures and tables”, “Written Assignment Checklist”, and “Common mistakes” from the writing resources page link.
This will be a simpler report, compared to the other labs in this course. This document should be formatted professionally (Title, your name, class number, sections, subsections, Figure/Table captions, etc.). Please focus on the underlying theory and the discussion/analysis of the obtained results. Following are the questions to be answered.
Question 1: Compare Model Prediction and Experimental Measurements
Summarize your experimental results and compare the first-order model (Read Chapter 2 of Models to Measurements: Observing Dynamic Systems by Brian Bingham) with your experimental observations using figures and tables for communication. Describe the results of this comparison in text, making sure to cross-reference the figures in the text. This summary of your results should be a few paragraphs in length and should highlight the most important results of your laboratory. The experimental summary should include:
Visual illustration of you experimental results including the step response graphs.
Qualitative comparisons between your model prediction and experimental results, i.e., what do you observe about the similarities and differences between the mathematical model and the experimental results?
A table summarizing the predicted time constants, measured time constants and fractional difference between predicted and measured values for the various experimental scenarios.
Question 2: Defending a Thesis with Evidence.
Select one of the following assertions to defend in a written paragraph:
We are able to accurately model the time response of the LM35 temperature sensor with a first-order model.
The first-order model is not sufficient to accurately capture the behavior of the LM35 temperature sensor.
Write a single paragraph (or two if necessary) that starts with a topic sentence (perhaps one of the two sentences above) and proceeds by providing evidence to support your claim. Strive to make this paragraph as succinct and clear as possible. Likely sources of evidence might include mathematical models, simulations (numerical solutions), and/or experimental evidence. Your paragraph should present a logical argument that uses evidence to substantiate your claim (i.e., the topic sentence). There is no 'right' answer to this question; either statement can be argued with the evidence you have from the lab. Your challenge is to make a compelling, thoughtful case using topics from the class.
Following equipment are required for data collection
An Arduino uno board
USB Cable
Temperature sensor (LM35-DT)
Breadboard
Jumper wires
Computer with following software
Arduino IDE
ArduinoScope
Make sure you have a recent version of the Arduino IDE installed on your computer. You can visit the Arduino Software page, download and install the latest version for Windows.
Download the ArduinoScope application. This is a Windows executable program to display the A/D signals connected to an Arduino.
Installation Instructions: Extract all the files in a directory (e.g., a folder on your desktop called "ArduinoScope_v0.2"). The directory/folder should have the program (ArduinoScope.exe) and various libraries (*.dll files).
Double-click the .exe and start up ArduinoScope.
The "arduinoscope402.ino" sketch is for using the the Arduino board (with our without the SD card) and the ArduinoScope Windows application. The sketch samples up to three analog input channels and sends the measurements over the serial port. The ArduinoScope application reads the incoming serial messages and graphs the values.
Other useful Arduino Links:
Arduino IDE user interface
ArduinoScope user interface
Soldering: This is an interesting and useful skill to have, but it has its risks!! Let's be careful with these by getting started with some tutorials (Link1, Link2 - Youtube, Link3). Always wear safety glasses while using a soldering iron, and make sure the surface is not conductive or fire-prone! Be extra careful while handling the tools.
Make sure the wires soldered to the sensor are long enough (20-25 cm) to get the set up far enough from the water cups!
Be careful if you are using wire cutters/strippers, to avoid cuts. Never use on a live circuit wire!
Hot glue for insulation is another heat/burn hazard. Be careful while handling. Make sure the sensor is properly insulated after soldering to avoid short-circuit while accidentally dipping the conductive surfaces in water!
To be safe, only submerge the metal tab of the sensor and not the electrical connections! If the sensor is well waterproofed you could submerge the sensor, but it is not advised.
Let the sensor rest for some time after applying glue. Also, do not dip in hot water long enough for the glue to soften/melt, which may expose the electrical connections and cause short-circuit!
Hot water may cause accidental short-circuits or burns if spilled. Be extra careful while handling, as this often happens during these experiments.
You may reset the Arduino after each trial run. If doing so, you will need to re-upload the sketch on the Arduino, and refresh the connection on the ArduinoScope.
We will be using the LM35DT temperature sensor.
To make the necessary electrical connections you will need three wires, each about 20-25 centimeters long: red, black and blue wire. (Any color other than red or black can be substituted for the blue.) All the ends should be stripped (approx. ¼”)
We will solder the following connections to the LM35DT (see the pinout on page 2 of the LM35DT Datasheet)
The supply voltage (+Vs) should be connected to the red wire
The ground (GND) should be connected to the black wire
The signal (Vout) should be connected to the blue wire
Next we will apply a small amount of hot glue (or silicon) to waterproof the connection.
Make the connections as shown and described below carefully, and verify them before connecting the power cable.
Connect the temperature sensor and the Arduino as shown above (Courtesy). Make sure you get the pins and the connections right before you connect the power!
+Vs of the sensor to +5V of Arduino
GND of the sensor to GND of Arduino
+Vout of the sensor to pin A1 of Arduino
Note: You can use a breadboard as shown in the demo figure. This will allow you to work freely without getting connection interruptions.
Connect the Arduino to the PC via USB-cable.
Copy and paste the following code to the IDE and save the sketch as "arduinoscope402.ino" in the same folder with the ArduinoScope.exe.
int val;
int tempPin = 1;
void setup(){
Serial.begin(9600);
}
void loop(){
val = analogRead(tempPin);
float mv = ( val/1024.0)*5000;
float cel = mv/10;
float far = (cel*9)/5 + 32;
// Serial.print("TEMPRATURE = ");
Serial.print(celsius);
//Serial.print("*C");
Serial.println();
delay(1000);
Serial.println();
}
Note: You can customize to choose between Celsius and Fahrenheit. Please see the trend and make minor edits as required.
Click Tools->Board and Select "Arduino Uno"
Now it is time to compile the code. Click the "verify sketch" button. Check the error console for possible errors.
Upload the sketch to the Arduino by clicking the right-arrow button ("compile and upload sketch to Arduino"). Again check for possible errors.
Open the ArduinoScope window
Select the appropriate serial port (COM port) with the dropdown box on the right of the application.
Now check the "Connect" box.
Now you should see a trace showing the analog input values.
Notes on operating the ArduinoScope application:
If you start the ArduinoScope application before attaching your Arduino to your PC, you can click the "Refresh Ports" button below the COM port selection box. This should give you a list of all the active COM ports.
Logging data to a text file:
You can use the Pause box or the Run Once button to collect a snapshot of data.
Then click the Save *.txt button to save a series of log files. The log files are given unique names based on the current time on your PC and saved to the same location as the ArduinoScope executable. A separate log file is created for each channel recorded.
To make sure that you are ready to measure temperature with the LM35DT, you should make sure that it is working. One quick way to do this is to simply hold the LM35 in your hand and see that the voltage (as read by the ArduinoScope or in the text output) is slowly rising.
Another debugging approach is to use the handheld multimeter to check the supply voltage (from the Arduino pins) and the output from the LM35DT. If you have a problem with the system, having an independent measurement of the temperature sensor input and output will allow you to determine if the problem is with the DAQ or with the temperature sensor.
The sensitivity of the LM35DT is 10 mV/°C. Estimate the temperature of the LM35DTand compare this to room temperature (20-25 °C).
Have three Styrofoam cups ready at this point, one each for hot water (near boiling), cold water (near zero, ice water) and normal temperature tap water. Needless to say, extra attention is required from this point on - with water around the equipment, and hot water in play!
We use two cups for this part: one with hot water and one with cold water.
Start data acquisition on ArduinoScope so that the data is being collected.
Insert the temperature sensor into the ice water and monitor its output as it reaches equilibrium with the water. To be safe, only submerge the metal tab of the sensor and not the electrical connections! If the sensor is well waterproofed you could submerge the sensor, but it is not advised.
(*~*) Carefully remove the sensor and then insert the probe into the hot water bath. Monitor the temperature rise.
When the probe has reached equilibrium with the hot water, quickly remove the probe and the insert it in the room temperature water.
Stop data acquisition when the probe has reached equilibrium with the room temperature water.
Pause the ArduinoScope and save the data as a .txt file in the same folder. Give the data file an informative name such as “lab1_HotCold_trial1.txt”. Do not include any spaces in your filename!
The steps above constitute one run of the experiment. Repeat these steps two more times so that you have a total of three experimental runs for the hot-cold transition.
Repeat the fourth step (*~*) in experiment (1), but dilute the hot water so that it is now just “warm”, i.e., somewhere between room temperature and boiling AND replace the ice bath with room temperature water.
Save the data and rename the file.
Again, repeat the experiment twice more so that you have a total of three experiments were you acquire temperature data as the sensor transitions from warm water to room temperature water.
Repeat the fourth step (*~*) in experiment (1), but instead of cooling the temperature sensor in room temperature water, now cool the sensor in still air.
You only need to do this experiment once; it takes some time for the sensor to cool completely.
At this point you should have run a total of seven experiments:
Three experiments recording the transition from hot to cold water.
Three experiments recording the transition from warm to room-temperature water.
One experiment recording the transition from warm water to room-temperature air.
One of the best things you can do to avoid trouble is to do a quick quality check of your data. Ideally you would do this a few times during the experiment to make sure the measurements you collect for later processing are in good order. You should check your data by making a plot of measured temperature versus time.
Create a folder on your desktop called “Lab3”. Put all your data files in this folder.
The following MATLAB program is an example for importing and plotting log files from the application. Copy an paste the code to MATLAB and save the script as "importArduinoScopeExample.m" in the same folder with the data you just saved. This program allows you to display the data in MATLAB. The following MATLAB program is an example for importing and plotting log files from the application. Copy an paste the code to MATLAB and save the script as importArduinoScopeExample.m in the same folder with the data you just saved. This program allows you to display the data in MATLAB.
For each heating or cooling event you will need to find the time-constant of the temperature sensor. We will use MATLAB to do this. There are a few ways to estimate the time-constant. The following are suggestions, but there are many other ways to make this estimate.
Plot the temperature versus time for each heating or cooling event (Note: The acquired data is the output voltage from the LM35. This can be converted to a temperature in °C using the sensitivity of the sensor: 10 mV/°C). Based on this plot you can measure the initial and final temperatures. Calculate the temperature that is 63.2% of the way between the initial and final temperatures. From the graph estimate the time difference between the initial start of heating (or cooling) and the time of the temperature that is 63.2% of the way between initial and final.
For the above method, the ginput() MATLAB command is helpful. It allows you to make measurements from a figure window using the mouse. Type help ginput in the command window to learn more.
A slightly more general method is to normalize the temperature values based on the initial and final temperature values. Plotting this normalized temperature can make it easier to identify the time constant.
% Example of importing data from ArduinoScope log file
% The importdata command imports the text data, separated by %commas
fname = 'YourExptFileName.txt';
% data0 includes the time and the amplitude of the signal as %two columns.
data0 = importdata(fname,',');
% Now plot the results
figure(1)
clf();
plot(data0(:,1),data0(:,2),'r')
% Add an expression to convert the voltage output to %temperature (Hint: use the sensitivity of the sensor )
xlabel('----')
ylabel('----')
title('Relevant title')
Note: Since you are familiar with MATLAB and using mathematical expressions by this point, you should be able to add the equation for the unit conversion as suggested in the code and show the end results.