Thursday, April 14, 2016

MATLAB: So take of all your clothes~ (thermal systems part 2)

Partner: Katrina Montales

In this activity, we worked with an actual thermal system composed of the following parts:
  • heater - a 50 ohm resister powered by 18 V supply (we can control adjust the power) that converts electrical energy into thermal energy
  • thermal reservoir - the resister is inside a brass casing with good thermal conductivity (note: do not touch)
  • temperature sensor (thermistor) - has contact with the thermal reservoir, it is wired into a 10 kilo-ohm resistor, creating a "voltage divider circuit"
Baseline information about our specific thermal system (given):

Task 1: run the script test_thermal.m that runs for 300 seconds at 100% power (6.5 Watts) and calculate the unknown physical parameters Rth and C

test_serial code:

test_thermal code:

Resultant graph (note the little blips in the first run were due to disturbance in the environment (someone moving the thermal reservoir, changing the measured temperature)):
let the thermal reservoir cool down and ran the program again, no blips!






























Calculate Rth and C:
(for a refresher on these equations, see MATLAB: It's getting hot in here~ (thermal systems part 1))
Gut check your work:



The time constant is about 138 seconds.

The graph shows that y(300) = 378K and y(1) = 315K. Thus the time constant is the x value that corresponds to the y-value of (378K-315K)*(63.2%) = 39.82. Using a ruler, we determined that the value of time with a temperature change of 39.82 degrees is about 130 seconds, which is close to the calculated time constant value of 137.74 seconds.

In laypeople terms, we predict the heater will heat up 63.2% in 130 seconds, which is close to what the experimental data showed for 137 seconds. Not bad!

Task 2: Run Matlab simulation of the heatsim.m (using the Rth, C, and P that we calculated):

heatsim.m code:



(heatsim vs actual)



Ignoring the difference in scaling, the differences between the experiment and simulation were not that different. The simulation predicts that the heater could heat up at a rate much faster than in reality (perhaps due to environmental factors or delays). 

Task 3: Bang-bang Control -- modify test_thermal.m to change the power based on whether the measured temperature is above or below the target temperature (340K)

Bang-Bang experiment failed code (we never turned the heater back on):


Our failed bang-bang experiment:



Success!




Bang-bang simulation code:



Overall, the differences between the experiment and simulation are not all too large. There are more dramatized differences in the temperature changes when the experiment has the heater on and off, but this is probably because there are more delays between the actual temperature of the heater and the time that the sensor senses the temperature and adjusts the power. All in all, pretty closely well replicated results!


Task 4: Proportional Control
-review on proportional control-
error = target state - present state
set power = Kp * (target temp - T) when Kp is the proportional gain coefficient

Code for Simulation:


Code for Experiment:



Kp = 0.02, Simulation(top) and Experimental (bottom)




The simulation shows a very minor increase in temperature while the experiment shows even less or no change in temperature over the 300 seconds. What we can see in both the simulation and the experiment is that a proportional gain coefficient of 0.02 is far too little power to create significant temperature change, thus we never reach the control set point.























Kp = 0.2, Simulation(top) and Experimental (bottom)



The simulation shows a more gradual but constant increase in temperature from t=0 to t=50 while the experiment shows that the heater takes a little while to "heat up". In other words, there seems to be a small delay in the temperature increase in the experiment because the power takes a little bit of a buffer time to create an actual change in temperature. In both the simulation and experiment, we do not achieve the target temperature because the power (theoretical and actual) being supplied to the heater is still too small.




















Kp = 0.5, Simulation(left) and Experimental (right)

The simulation shows a very steep initial change in temperature in the first 50 seconds. In the experiment, we also see a very steep initial increase in temperature, but it is delayed a little bit, as seen in the previous experiment as the heater takes some time to heat up. In addition the slope of the rate of increase in temperature for the experiment is not as steep as that of the simulation because the experimental data is limited by reality. In reality, we are limited to 6.5 Watts of power. However, even if we put in an infinite amount of power (aside from all dangerous and actual problems with that), there would still be a limit to how fast the heater could heat up, making the slope of the temperature increase less steep than that of the simulation.

















When the gain is too small (0.05), the experimental results do not show a significant temperature change. If the gain is too high, the system behaves very similar to that of a bang-bang controller, since the thermal system is basically at full power until the target temperature is achieved, rendering the temperature graph for the first 50 seconds practically linear. (more power is not always better!) Thus, the ideal gain is somewhere between 0.2 and 0.5 so that we can reach the target temperature, but still more efficiently use the power.

Reflection:
In this assignment, we were able to see how the simulations and actual experimental results were similar and different. Although they are often very similar, there are a couple of differences due to limitations of reality -- such as delays and power limits. In addition, this was a great way to practice coding for bang-bang and proportional control because we were able to see the actual experimental results of code that was not correct. Thermal systems are not only interesting, but also important to the final projects tackling the problem of temperature regulation for people who can no longer do so. Just as in this assignment's experiments, there are limitations to how hot and how fast you can heat up someone while keeping everything safe. Just 100 years ago, houses were smaller because they could much more efficiently be heated and maintained at the ideal temperature because there was less air to heat-up and maintain. Thanks to modern technology and the implementation of ventilation systems, we have a bit more control over heating and temperature regulation, but we still have far to go! If you want to read more about modern air temperature regulation and heating in thermal systems, check out the nest -- the smart way to heat/cool your home that fluctuates as people are in or not in the home.

Animals have complex heat regulation systems too!



1 comment:

  1. I liked how you posted a copy of the graph of the bang bang code that didn't work. The same thing happened in our group and I'm glad to see that we weren't the only ones

    ReplyDelete