Monday, April 11, 2016

Final Project Week 1

Partner: Katrina Montales

Problem: For our final project, we are working to solve one of the problems of the Child Study Center (CSC). We want to create scheduling cues, a way to show/teach kids the concept of time. This entails visualizing how long an activity will be and how long it has been.

We were inspired by this video of a marble music machine.

Our goal: Help the children (ages 2 - 6) visualize how much time is left or has elapsed in an activity.

Benefit: Kids are able to understand how long is left without bothering the teacher. Conceptualize time and translate a concrete image of an amount of marbles to the abstract idea of time.

Original plan for marble releasing mechanism
Mechanism: A motor and Arduino/bricktonics shield controlled marble releasing mechanism. Our original plan was along the lines of this. However, when we started working with the legos we had, we found a track that we could use gears to regulate the release of one marble.

Sensing/Feedback/Control: We plan on using a weight sensor under the marble collector cup to tell the Arduino how much weight is in the cup and calculate how much time until the next marble should be released.


Note: Becky wanted us to find a way to keep the different marbles, representing different activities to stay sorted (so for easier resetting of the mechanism after the end of the day). In addition, she wanted two buttons: one that would release all of the marbles for one activity (effectively ending that activity, if, say, an activity ends early), and one to delay/increase the length of the activity (perhaps proportional to the number of times it is pressed.)

Physical Aspects to Create: A marble releasing mechanism, path for the marbles, rotating cup that holds the marbles to sort them by color.

Progress thus far:


Katrina turns our not yet functional motor by hand. 2x2 block is our fake marble.

Monday, April 4, 2016

MATLAB: It's gettin' hot in here~ (thermal systems part 1)


Partner: Katrina Montales

Thermal Systems:
(link to the background on thermal systems above)

**NOTE: all temperatures are in Kelvin**


Question 1: The Cooling Behavior



Consider the equation for dT:


If we increase Rth or C, then we expect the change in temperature to decrease (less steep of a slope)
Red is the given Rth, Blue is the program run with lower Rth


If we decrease Rth or C, then we expect the change in temperature to increase (more steep of a slope)




Question 2: Add a Heater
Suppose the coffee starts out at room temperature and we turn on a heating element that adds thermal energy to the system at a constant rate P.
Consider the following altered equation for dT:


Calculate a good value for P if we want our coffee to heat up to the Starbucks idea 84C, using the Rth from the MATLAB script:
dT = 0 = P  _ T - Tair
dt           C      Rth*C

T - Tair = P
   Rth

P = 64/0.85 = 75





Can we find C and Rth by working backwards?

Rth: At equilibrium, the heat from the heater is equal the the heat leaving the coffee into the room
So, P = Teq-Tair
                 Rth
Rth = deltaT(final) =  63K  = 0.84 K/W
                 P               75W

C: When t = 0, for a very short dt, there is only energy going into the system:
So, dT = dE = Pdt
                C       C
               dT = P
               dt     C
C =        P          =    75W    = 1000J/K
       initial slope    0.075K/s


Question 3: Bang Bang Coffee Heater Temperature Control
Bang bang control is appropriate for many thermal systems because they require a lot of energy and so, in some cases, it may be better to have the heater on high for a short period of time and then turn it off. However, this can be inefficient, as we see in the graph, when trying to maintain the coffee's temperature. (Even though it was efficient when we were heating up the coffee)

Question 5a: note about the code - modified to include a delay of 2 seconds to reflect a real world sensor delay. (the delay was modeled by the expression mod(t, delay) == 0, meaning every 2 seconds enter the loop and check the temperature)









w/ sensor delay:


(they look pretty similar, eh? That is because bang-bang control isn't changed much with a delay, see a larger change in proportional control)

*the red is the temperature of the coffee when the heater is on, the blue is when the heater is off*

Question 4: Proportional Control Coffee Heating
How does the proportional control approach compare to bang-bang control? This was different because the coffee was heated in a much more precise way -- meaning we were not heating the coffee at full power if it was near the ideal temperature (that would be wasteful!). With the delay, we were able to model and visualize when the heat sensor was actually measuring the temperature and adjusting the power.

The delay was modeled by the expression mod(t, delay) == 0 meaning the sensor would sense the coffee's temperature after every delay amount of time.





Proportional Control w/o delay:


(temperature after 1500 seconds on the heater)

Proportional w/ delay of 35s:


(temperature after 1500 seconds on the heater)

Proportional w/ delay of 45s:


(temperature after 1500 seconds on the heater)
Interestingly enough, the delay separated the times the heater was able to readjust the power output, allowing it to get closer to the ideal temperature (rather than inching at an increment too little to make a difference (remember nudge?)).

In the real world, one might expect there to be a sensor delays, computational delays (computer doing calculations, though that is super fast!), heater delay (warming up/cooling down), etc. Delays all over the place! (psst: this is why we use MATLAB to model the ideal situation)

Skills:

  • MATLAB plotting
  • while/if/for loops
  • delays in matlab
  • bang bang control
  • proportional control





Thursday, March 31, 2016

MATLAB Introduction: The "Glorified Calculator"

Partner(s): Jenny Gubner & Meba Gebre

Through the following introductory tasks in this matlab textbook (super #sassy and #funny) by Allen Downey and read chapters 1-4.

General Tips/Notes for coding in Matlab:

  • %    denotes a comment; define what a program does, preconditions, postconditions
  • ;      suppresses the output of the command (otherwise printed in the console)
  • ...    breaks up a line that can take up multiple lines
  • 1/0  denotes true and false (respectively)
  • ~=   not equal
  • script - a savable file/program (not working in the console/interactions pane)
  • to run a file, save it and then run (always save before running)
  • who - this command prints the names of the variables
  • clear _variable name_ - removes/deletes the variable
  • disp(z) - prints the value of the variable z
  • matrix = ones(2, 3) - creates a matrix named matrix filled with ones that is two rows by three columns
  • **indices for accessing stuff in matrices start at 1**
  • all loops/compound statements: for, while, if/else are closed with "end"
  • running a file in the console: 
    • name of the file
      • >>fibonacci2
    • or if n needs to be specified
      • >>n=10; fibonacci2


Exercise 2.1: fibbonacci1 script


Console:


Exercise 2.3: car_update script
The problem with this code is that you would have to input the number of cars at Albany and Boston for every week that you wanted the computation done. (re-enter the new car numbers, so for computing the numbers over multiple weeks, would have to call the script many times)



Exercise 3.1: car_loop script
With each run of the loop, updates the variables a and b to the be the number of cars at the respective locations (Albany and Boston).



Exercise 3.2: car_loop script w/ plotting
This exercise plots the car numbers at Albany(red) and Boston(blue) over the 52 weeks.




(you can see a clear equilibrium point between the two locations)

Run for initially 10000 cars at Albany and 10000 cars at Boston.


Exercise 3.5: fibonacci2 sequence script

>> n=10; fibonacci2


>> n=15; fibonacci2


>>n=20; fibonacci2


**TAKE NOTE: n starts counting at the third fibonacci number**

Exercise 4.6: plotting fibonacci ratios



(as you can see, the fibonacci ratios converged about 8 terms in to a value at about 1.6)

Baseball Simulation:


Max angle: 45 degrees, x value is 261.6295m
If you graph many other angles (leaving the 45 degrees trial red), you get the following graph:
angles tried: 30, 40, 43, 47, 50, 60

Modification: You could easily create a new script to call the bball script multiple times (in a loop), adjusting the angle each time and then at the end, returning the max angle value and the max x distance rather than manually doing trial and error

Skills:

  • matlab
  • plotting
  • functions
  • for loops
  • if/else loops


my favorite catch ever #gocubs