Thursday, April 10, 2014

Thermal Systems Day Two: The Puzzle of MATLAB continues.....

Today, my partner Kirstin and I expanded our simulated behavior from the previous day to an actual thermal system, namely a resistor with a sensor attached to it. The sensor, called a thermistor, would measure the heat dissipated by the resistor, which we could control by altering the energy output of the system.

Our first experiment was to determine the physical constants (Rth and C) from our simulated heating experiment in order to conduct our experimental run.

Using:
Rth = (T-Tair)/p

And the knowledge that our maximum power was 6.5 volts.

(354.92 - 303.5)/6.5 = 7.9 T/W

And 
C= p/initial slope of graph

C = 6.5/ [(325.5-312.3)T/(54-10)s) = 21.6 W/(T/s)



Because (Rth)*(C) = ti, the time constant or time in which it would take our system to reach 63.2% of its final asymptotic value, we could check our answers.

(7.9)*(21.6) = 170.64

At this time in seconds, out graph was approximately two thirds the way to its final value, so we knew we were correct.

Our two calculated values were dramatically different from our simulated values in the previous post because of the dramatic change in power. Now, we only had a 6.5 v battery to power our system, so the answer had to adhere to this stipulation. 


Next, we modified our simulated heating program to incorporate these parameters. 

Our simulated heater evenly tapers off and maintains a constant temperature once it reaches the desired temperature. Additionally, the incline is smooth, whereas the experimentally measured incline was rougher. This is probably the result of slightly fluctuating surrounding air temperatures or wind.  However, just line the experimentally measured values, the temperature rises more sharply at the beginning and then gently tapers off to a smaller slope.
Next, Kirsten and I constructed a bang-bang controlled heater that would raised the temperature to the desired value and then try to keep it there. 

Bang-Bang control experimental script


Bang-bang control experimental graph



Unlike our simulated bang-bang control, the experimental graph did not fluctuate evenly on it reached the desired temperature. Instead, it bounced randomly to different values around the desired temperature based on the system was interacting with the air temperature around it. It behaved more like a realistic system should because it is a real system. Next, Kirsten and I implemented Proportional Control to help our system. To do this, we experimented with various proportional gains (.05, .2, and .5). We had to calculate the coefficients each time. To do this, we set up a proportionality ratio:

100 is to 6.5 as (blank) is to .05

Our calculated coefficients were:

.7679 for .05, 3.077 for .2, and 7.692 for .5

Finally, we inserted these values into our coefficients into the script to observe their effects.


.5 Gain

.2 Gain

.05 Gain

Our results were varied, but after ultimately the coefficient of 7.69 proved to be the best option for our realistic system.

Gain of .5, Coefficient 7.69


Gain of .2, Coefficient 3.077
Gain of .05, Coefficient .769
Ultimately, the experimental system never reached its target Temperature of 340 Kelvin. When the proportional gain is small, the system does not add enough power to reach its destination. Even when there is a large difference between the final and initial temperatures, the small coefficient results in a low power setting. Conversely, a large coefficient results in a much larger power setting. When Kp was almost 8, the system did come extremely close to reaching it's goal. 
Graph of Simulated Proportional Control
                              
Unlike our simulation, the experimental graphs never made it to 350 Kelvin, let alone exceed it.


Finally, we constructed our very own PI Controller. A Pi Controller incorporates both integral and proportional control to achieve and maintain a certain temperature. 

Script PI Controller
                              
Script PI Controller and Graphs of Temperature and Power vs Time
After a bit of experimentation, we found that the Ki value from the equation: 

P_desired = Kp*error+Ki*integral_error

Was approximately .5. However, we ended up having to increase our Kp value from 7.69 to 12 in order for the system to eventually reach its destination. The graph shows that, even when we blew on the resistor, thus cooling it, the temperature remained mostly constant while the power fluctuated heavily in order to maintain this constant temperature. Unlike our simulated PI Controller from the previous post, this controller did not fluctuate so dramatically or predictably. More often than not, as evidenced by the above red line on the upper graph, the temperature was constant, even under cooling conditions. 
Simulated PI Controller and Graph
                             

Thursday, April 3, 2014

Thermal Systems Day One: The Puzzle of MATLAB.....

Today in class, my partner Kirsten and I set to work modeling the heat and cooling of an average cup of coffee.

We started by modeling a simulation of a cooling cup of coffee. First, we calculated the effect the heat capacity (C) and the thermal resistance (Rth) have on the system. Given that a change in temperature can be calculated by:

dT = - ((T-Tair)/(Rth*C))dt




The change in temperature is inversely proportional to any change in either C or Rth.  A larger Rth resulted in a smaller dT and a smaller Rth resulted in a larger dT.

Larger Rth Value

Smaller Rth Value
The same was true for the C values.

Larger C Value
Smaller C Value
After we explored the cooling simulation, we moved on to a warmer topic. When energy is added to the system (the coffee, in this case), the temperature of the system increases. We simulated a heating process where heat was added to the coffee at a constant rate (P) based on the equation:

dT = dE/C = [(P/C) - ((T - Tair)/RthC)]dt

When the coffee is heated to the desired temperature (the Starbucks ideal 84 degrees Celsius), the change in T is zero.

0 = [(P/100) - (64/(1000*.85))] *10
0 = [(P/100) - 0.075] *10
(P/100) = .75
P = 75

Incorporating this value into the simulation script resulted in a steady increase in temperature. The rate of the increase in temperature became smaller the closer the coffee was to its desired temperature.

Working backwards from such a graph, it is possible to deduce the values of C and Rth. Working from the following equation: 

 dT = dE/C = [(P/C) - ((T - Tair)/RthC)]dt
P = (T-Tair)/Rth
Rth = (T-Tair)/P
Rth = 64K/75W = .85 K/W

Working from the equation: 

dE/dt = (T-Tair)/Rth

And from the deduced equation:

Rth = (T-Tair)/P

We get: 
dT/dt = P/C

Which is the slop of the graph. For our graph, the initial slope was about 30K/400s, ergo:

C = P/slope
C = 75W/.075K/s
C = 1000 J/K

These were the values given to us with the initial script, so we knew that our calculations were correct.

Finally, we moved on to incorporating feedback and control into our models.We started by simulating a temperature sensor in our coffee mug that used bang-bang control to reach and maintain the desired temperature (84 degrees Celsius or 357 degrees Kelvin). 

We simply stated that if the T value was above 357, then the P value should drop to 0, allowing the coffee to cool. Otherwise, the P value should be 100. This heated the coffee successfully and maintained a relatively constant temperature. The bang-bang control system is simple, and for a system that only requires basic yes/no procedures, it is ideal. However, the temperature constantly fluctuated between just below 357 Kelvin and exactly 357 Kelvin. For a Starbucks employee, that means that the coffee might not be exactly 84 degrees Celsius when it is served to the customer. However, the temperature will never be above 357 Kelvin.


We moved on to proportional control.Unlike with the race cars, the proportional control did not work very well to heat the coffee. The P value could only fluctuate between 0 and 100. Because the temperature had to be some value between 357 and 0, by the equation:

dT = P (T-Tair)
(gain)*(error)

At most, the P value could only be .28. This resulted in a system that could not heat the coffee anywhere near 357 Kelvin. Even when the P value was raised to an unrealistically high 20, the coffee was still just under the desired temperature. Though the proportional control method maintained a constant temperature better than the bang-bang control did, it could not successfully heat the coffee to the desired temperature. For a Starbucks employee, this method would result in some very unhappy customers.

P Value .28

P Value 20

Finally, we played with the idea of applying a delay between when the time the coffee reached a certain temperature and the time when the sensor recorded that fact. This would make the system more realistic, as the computer assumes everything happens instantaneously. This effect was achieved by applying a three second delay to the program. Each measured interval (i) was set between 1 and n, and the delay was the mathematical result of multiplying T by (i-3).

delay = 3
i = 1:n
error = 357 - T(i - delay)
P = 20*(error)

When the delay was applied to the proportional control script, the result was a sine curve that diminished over time into a straight line.



This means that at certain points, the coffee is heated past the desired temperature and the delay causes the sensor to alert the system too late. Once the system is alerted to the increase, it places 0 as the P value and the temperature eventually levels off.

For the bang-bang control, the delay script had to be altered slightly:

if T(i-delay) > 357, then P = 0
else P = 100


When it was applied to the script, the temperature increased to the desired amount and the fluctuated along a sine curve above and below it. Unlike the proportional control, the bang-bang control did not level off. It could not maintain the temperature successfully. When there is a delay to take into account, a bang-bang control method is not a good for a thermal control system.

However, there are other delays to take into account in a thermal system. the temperature of the coffee could not be evenly distributed, so some portions may be hotter or cooler than the sensor records. This could result in coffee that is too hot or too cold, despite the added sensor. If the coffee temperature is measured in a container larger than a single cup, this kind of error is especially possible, as cooler liquid will sink to the bottom while warmer liquid will rise. There could also be a delay between when the heater turns off and on once the sensor has recorded the temperature. The temperature may be just right, and the sensor may know that, but it might take a few seconds for the heater to know that. The result could be either coffee that is too hot or too cold.

The perfect cup of coffee is harder to achieve than one would think.



Monday, March 31, 2014

MATLAB Introduction: The Puzzle of Physical Modeling

Today in class, we were introduced to the wonderful world of MATLAB. The program is a way of modeling events mathematically. Although we've only just barely begun to scratch the surface of the program's potential, we did manage to complete some sample exercises.

We started by simply making a Fibonacci Script. We had to translate the Fibonacci expression into MATLAB, set n=10 and see if the answer (Fn=ans) was 55 to check our work.


Our answer was, indeed, 55. 




Our next challenge was to calculate the number of cars a dealership had in each of its two location each week. Each week, 3% of the cars in B move to Lot A, and 5% of the cars in lot A move to Lot B. Each Lot starts the year with 150 cars 




We achieved this by adding and subtracting the desired number of cars each week. In addition, we also had to remember that the amount of cars in each lot changed per week, so 5% of the cars in Lot A one week would be a different from 5% in any other week.

Once we had completed this, we moved on to leaning about loops in MATLAB. Our challenge was to create a loop for out car calculating program and make it run 52 times, so that we could see what each car lot would look like at the end of one year. We set our initial A and B values to be 150.




We achieved a long stream of random numbers on our screen, but it was clear that the program was working because each week the number of cars in each lot changed. Some of our numbers were decimals, however, and because we knew a lot could not contain 'half a car', we used the round command to make our cars whole again. 

To make our data easier to interpret, we learned how to plot a graph. 




The graph allowed us to visually understand exactly how our numerous results were trending over the 52 week period. We then compared Lot A to Lot B to see how the entire stock of 300 cars was trending over the year.




In general, the number of cars in Lot A decreased at a decreasing rate and the number of cars in Lot B increased at a decreasing rate. In other words, Lot A always lost cars, but how many cars it lost each week became less over time. Conversely, Lot B always gained cars, but the number of cars it gained dropped lower and lower each week. The result was the same, even when Lot A and Lot B initially began with 10000 cars each.


For our next challenge, we left the car rentals behind and returned to our Fibonacci sequences. Our challenge was to compute the first 10 numbers in the sequence (we would have to specify the first two, but after that everything else was computable). 



Using our previous code and our knew knowledge of forever loops, we managed to complete the task. By checking online to see what the actual values of the first ten numbers in the sequence were, we were able to confirm our results. Next, we had to adjust the code such that it could calculate the sequence to any number (n) beyond (or even below) 10, but not less than 2. 


We achieved this by defining i as a variable able to be changed by the user. The starting point, 3, would remain the same, but the user could change the end point to anything.

From here, we went one step farther in our Fibonacci fun. Using vectors, we determined the ratio to which that F(n+1)/Fn converges, as well as graphed it. 


 


By using the vector to store of Fibonacci numbers, we were able to graph the ratio and see that the sequence converges to approximately 1.62 as the value of 'n' increases.

Finally, we were charged with maximizing the range of a baseball. Given a script, we had to alter it to determine the launch angle needed to produce the maximum range. Using the equation,

d = ((v^2)*(sin2x))/g,

we graphed distance vs angle on a separate script to see what angle would produce the greatest range. 




 
The optimal angle ended up being 45 degrees. Our code has the pre-condition that the user run our fabricated script first to acquire the needed angle before running the code. Conversely, our script can also be used to find an angle for a different distance, or to determine the angle based off a known distance.




Tuesday, March 11, 2014

Final Project Initial Brainstorming: The Puzzle of What's Next...

Now that my fellow novice engineers and I have completed all our basic training, it is time to begin working on what will consume the rest of the semester.....the final project!

What is it, exactly? We don't know yet. The theme for this semester is education, so whatever my future partner(s) and I do, it will have to be able to teach someone something about what we've been learning this semester. We're begining to put together some idaes. On Friday we will be takin a trip to the Museum of Science in Boston for inspiration and meeting with an engineer there who works on the exhibits, Peter. Some potential question for him, or in general might be...


1.     What do kids seem most interested in?
2.     What do kids seem least interested in?
3.     What do kids understand very well?
4.     What aspect of the science (of any theme or item) is the least intuitive to kids?
5.     Do you hear any complaints/compliments about the hands-on exhibits?If so, what are these complaints and how can they be avoided?
6.   What makes an exhibit enticing to potential attendees? 
7.     What are kids allowed/not allowed to do in hands -on areas? I.E. What are the safety concerns when it comes to hands-on learning?
8.     What kinds of hands-on learning things are better for partners/large groups and what are better for just an individual?
9.     Even with exciting things, what can ‘bore’ kids and make them less interested? (What is the difference between hands on learning and teaching, where is the line, how involved should the instructor be?)
10. Do you have to consider the attention span of the viewer? IE they may want to do the hands on stuff, but not listen to instructions/educational stuff? They’re not bored, they just do not want to listen and prefer to dive right in. 

We know all the science, but maybe not all the people variables. After all you can take a
horse to water, but you cannot make it drink. The goal here is making the horse (or kids, or
adults, or anyone, really) want to drink.

The other thing we have to worry about is time. We only have so much of it and there are a
lot of things to see and do in the museum. So how do we narrow down our choices? After
carefully reviewing the list of current exhibits, I composed a small list based off which
exhibits were technology based and included hands-on aspects. I also kept an eye out for
any exhibits working with sensors.

The list goes thus...
  
  1. Kinematics 
  2. Computerplace (yes, spelled as one word)
  3. Cosmic Light 
  4. Innovative Engineers
  5. Making Models
  6. Nanotechnology
  7. Take a Closer Look
  8. To The Moon


All these exhibits integrate the perameters I layed out and i believe they will help us gain a
better understanding about hands-on learning and how it relates to our specific class. They
may also provide ideas for our final projects...

Speaking of which, below is a list (yes, another one) of the ideas I have generated so far.

1.) Mars Rover Retrieval! We could design our own miniature Mar's Rover to teach the kids about NASA deals with problems at distances. Just like in real life, we could pose a problem with the Rover on Mars (say, one wheel is stuck in a crevice), list all the sensors and movement possibilities available and let them try to determine a way to solve the problem. Essentially, play astronaut. We would have to have our own program that could un-stick the Rover. If we cannot solve the problem, we should not expect them to, after all.

NASA scientists working on Earth to solve a problem on Mars...




2.) Mars Rover Drop! Using the same Rover idea as above, we could simulate the drop the Rover underwent to actually get to Mars. We could, once again, list all teh sensors and movement possibilities available, pose a problem (safely getting the robot onto the ground, upright and undamaged) and let the learners figure it our on their own. Again, we should have  method of solving the problem. 



3.) Mars Rover Collection Process! Still Mars Rover...we could simply simulate one of the Rover's jobs: sample collection. We could have a variety of different coloered objects on teh floor, and the Rover has to retrieve only certain ones. It would incorporate multiple sensors to do this. We could state a directive (like get only the red legos), list all possible sensors and movement options and then let the lerners come up with their own ideas. 



4.)Mars Rover Mission(s)! Some combination of the above three options: plainly put, we could simulate an entire Mars Rover mission, or just certain aspects of it.  (see above for photos)

5.) Scuttling CrabBots! Design various legged robots (or wheeled ones) that incorporate different gear ratio and kinematic options. The object is to have the fastest little crab bot, so the learners would have to test various gear combination options to find the best one. Numerous options means they might want to learn a little about gears in order to minimize their search.



6.) Dance dance Robot Revolution! Using sound and ultrasonic sensors, we could build several bugs to follow each other, keep certain distances between them and react to sounds (like low beats in a song). The learners could program different responses and test them out to see the results. 



7.) Follow the Sound of My Voice! We could have a precise robot programmed with a variety of sound sensors on all sides. When the bot 'hears' certain sounds, like claps or shouts, it moves towards them or in some certain way. The trick is that the learners would have to understand the measurement of sounds and be able to define the parameters for each sensor. We would have to design an extremely accurate robot for this to work as well as it needs to.



8.)  Photosynthesis Simulation! We could build a model of flowers/grasses that respond to solar panels. The more sunlight they recieve, the more reaction the learners observe. This could teach the attendees about photosynthisis as well as solar power through visual aid. The learners could also engage in teh activity by changing gear ratios on the flowers to see how that would affect them.



9.) Once Upon a Gear Ratio! We could build a kinematic puppet show and have the learners interact with a story told by puppets mounted on sticks attached to various gear (they do not have to just be round). The way a puppet moves, its speed or the frequency of its appearance could be altered by changing the gears. The learners could learn about kinematics and gear ratios while simultaneously putting on a show for their own amusement.



10.) Type to Text! We could build a voice commanded typist. By programming very specific sounds to each key on the keyboard, we could have a robot interpret the sounds like battleship coordinates (or Cartesian plane coordinates) proceed to that spot on the keyboard and push downwards. The kids could learn about the measurement of sound as well as basics of computer programming and sound sensing. 



11.) Rainbow Connection! We could have a robot with a sensor that can differentiate between colors (either a light sensor or a brightness sensor) and the kids can program it t do different things depending on what color it encounters (spin, make cat noises, etc). Then, they could drive it over a multicolored surface ad observe the humorous results. 


I can't wait to find out what we do next!