MATLAB Introduction


MATLAB

We started our new unit today on MATLAB.  I am working with my new partner Sabrina on this unit (Here's her blog: sabrinaattemptsengineering.blogspot.com)  We will also be working on the final project together.

We started by reading the first four chapters of Allen Downey's Physical Modeling in MATLAB and doing some of the exercises to familiarize ourselves with programming in MATLAB.


Exercise 2.1 -  Fibonacci Sequence 

The fibonacci numbers are a sequence of numbers where the next number is the sum of the previous two: 1, 1, 2, 3, 5, 8, 13, 21, . . .   The following is our first exercise to learn simple coding in MATLAB, and to make sure we got the order of operations correct.


In our code, we decided to split the expression inside the brackets into two elements.  By doing it this way, we reduce the number of parentheses we must use and we don't get so confused.  We name these elements by creating variables called first_element and second_element, and then use those variables in the next expression.  In the command window below, you can see that when we set n = 10, the answer is 55, which is the 10th term in the Fibonacci sequence.





Exercise 2.3 - Car Rental Update

Now things got a little more complicated.  We had the following problem to solve and code.  Our first step was actually understanding the problem and the math behind it.  We did some diagrams and created equations to work it out.


At first, we had our equations as you see in the following code.  To update the number of cars for a, we take away 5% of a and add 3% of b.  The equations are correct, but we realized we were missing a step when the numbers did not come out correctly. The problem is the following:  a and b both start at 150.  Then a updates.  Then b updates, but when b is updating, it is using the value for a that has already been updated, not the original 150.  We fixed this problem in the second code below.  We update the values using anew and bnew and then set a and b to the new values.  After several weeks we see that the number of cars reaches an equilibrium.

Car Update (Almost Correct!)


Car Update (Correct!)



Exercise 3.1 - Car Update with Loop

For the next exercise, we kept the same problem and the same code, but just added a for loop to the code.


Here, we take our code from the last example and add a for loop.  Inside the loop, we have our previous function that updates the number of cars.  The loop runs 52 times, so that the last values will show the number of cars in each location at the end of 52 weeks (1 year).


So at the end of a year, we see that the number of cars in each location reach an equilibrium.  To visualize this, we will learn in the next exercise that we can plot these points over time.



Exercise 3.2 - Car Update Loop with Plot 

Next in our reading we learned how to make plots from our code.  We took our previous code for the Car Update Loop and added code to plot the points.  This way we could see the equilibrium that each city reached.


We added three lines to our code.  "Hold on" tells the plot to keep the previous points during the loop.  Then we plot the values of a versus i with 'ro' red circles.  Then we plot the values of b versus i with 'bd' blue diamonds.


Y-axis: Number of cars.  X-axis: Time in number of weeks.
Initial number of cars in Albany and Boston is 150.
Albany (a) is represented by red circles and Boston (b) is represented by blue diamonds. 



Exercise 3.5 - Fibonacci Sequence with Loop

Now, back to the Fibonacci sequence.  This time, we will add a loop that can compute any number in the sequence.  


First, we have to tell it the first two terms: 1 and 1.  Here we are using a function notation, where F is the function and the number in the parentheses is the term number.  Hence F(1) means the first term and F(2) is the second term.  So F(n) means that we can set n to be something and compute the nth term.  The for loop will run from 3 to n, and inside the loop all we have is the function specifying the Fibonacci sequence.  The next term is the sum of the previous two terms.


To test our code, we set n to be 10, and the result was 55, which is correct.  We tested out 15 and the 15th term of the Fibonacci is 610!




Exercise 4.6 - Fibonacci Ratios with Plot


This last exercise was the most confusing of the afternoon.  It took us a while to actually understand the question.  Basically, take the Fibonacci sequence: 1, 1, 2, 3, 5, 8, 13, . . .  and divide the next term by the previous term, so 1/1 = 1;  2/1 = 2;   3/2 = 1.5;  5/3 = 1.667.  These are the ratios we want to compare.   Over time these ratios converge, or get close to one number.  If I list out the ratios, you can see that they start to converge somewhere around 1.618:  1,  2,  1.5,  1.667,  1.600,  1.625,  1.615,  1.619,  1.618,  1.618.  You can see these ratios in the command window below.

In our code, we have the loop from last time and the only thing we added was the second for loop/  For this loop we have it going from 2 to n, and the function we have is R(n) for ratios.  It take the nth term and divides is by the n-1 term.  For example if I were computing R(2), it would be R(2) = F(2)/F(1), which is 1/1 and so R(2) = 1.  Then, we plot ratio versus n with blue circles.


In the following plot of the Fibonacci ratios, we can see the convergence behavior.  For the first 10 or so terms, the ratios are drastically different and after that, the ratios only differ by small decimals so they seem to converge on one value.



Final Thoughts

That is it for our first day of MATLAB!  I found coding in MATLAB to be pretty similar to the other coding languages I already know, just a few minor syntax differences.  It was great to see that we can apply this to useful situations and I can see why MATLAB is used to model so many things in the sciences.  Next class, we will using MATLAB to model thermal systems, heating and cooling things down.  Also, since we were given our partner assignments today, we will be working on our project during the next few classes in addition to finishing up MATLAB, so look for those updates as well!

Final Project Ideas (CSC Visit)

For our ENGR 160 final project, we are going to design products to improve young childrens' classroom experiences.  We observed preschool-aged children during their class time and talked to the teachers about some of the problems they had in the classroom.  We asked them what we might be able to do to help them in the classroom and what could help the children.

Some challenges we learned about were:
  • Keeping the children on their mats:
    • During certain class times, the teacher has all the children sit on small rectangular mats to keep them still. Sometimes the kids stray off their mats, and teachers have to constantly remind them to stay on their mats.
  • Letting them know not to splash water out of the water table:
    • Each classroom has a water table with toys in it for children to play with.  However, they often like to splash water around and it gets on the floor, making it slippery.
  • Making sure the noise level is not too loud
    • The classrooms often get loud during free play time, especially with older children.  Teachers must frequently remind them to use their inside voices.
  • Reminding the kids to wash their hands with soap and water after using the bathroom
  • The kids are sometimes scared by the toilet flushing loudly
  • The lock on the bathroom isn't easy to open.


A few ideas I am interested in are monitoring the noise level in the class, keeping the kids on their mats, and making sure the kids wash their hands after the bathroom.

Noise Level ideas

  • Creating some type of meter with red, yellow, and green
  • Using something that senses noise level or loudness
  • Need to make sure it doesn't make sound or excite children too much
Keeping Children on Mats
  • Touch sensor on mat
  • Light turns on when child is not on mat, turns off when child is on mat
  • Maybe have a tool for the teacher to know who is off their mat
Washing Hands
  • Sound of toilet flushes causes something to happen at sink, maybe a light or message reminder
  • Lights indicating steps of hand washing
  • Ultrasonic sensor to sense when child is at sink

Arduino Day 4 (Sciborg Part 2)

Today, we learned about and experimented with three new feedback mechanisms: motor encoders, touch switch sensor, and ultrasonic sensor.  Then, we will use these sensors with our sciborg to implement two types of control: bang-bang control and proportional control.

Motor Encoders

The following sample code for encoders measure the number of rotations of the motors.  The encoder reads the current position and these values are printed.  In the sample code, the wheel moves backward and forward, and the encoder reads the current position of the motor.  The starting value for the encoder should be zero because we reset the encoder to zero in the void setup when we have "m.set_pos(0)".  The end value is not zero because we don't reset the encoder to zero within the loop.




Touch Switch

There is a touch switch on the front of our sciborg.  This can detect when the touch switch is activated and when it is not (e.g. the sciborg runs into an obstacle).  The touch switch is wired to a digital pin on the Arduino and also to ground.

Wiring for Touch Switch and LED

The following sample code includes the LED and the touch switch. When the touch switch is pressed, the LED turns on, but stays on forever and will not turn off when we let go of the touch switch.  Our job was to fix this and make the LED change according to the touch switch. We wanted to modify the sample code to make the LED turn on when the touch switch is pressed down and turn off when the touch switch is not pressed down.  All we have to do is add an else statement to the if statement.




Touch Switch with LED

At first, the LED did the opposite of what we wanted.  It would turn off when the switch was activated and stay on when it was not activated.  We weren't really sure what was happening, but played around with the code and wiring to see what was going on.  The code below is what we had for our first attempt.

Then, we modified the code once we figured out what was wrong.  The code in the loop is identical from the previous picture, but we think it had to do with the mode of the touch switch in the setup.  The mode in the first attempt was just "Input" (we're not sure what happened there?) and in the following code for the second attempt, we changed the mode to back to "Input-Pullup".  This switches the input. Additionally, for some reason it would not work when we wired the touch sensor to the LED, so as you can see in the comments, we took that wire out from our first attempt.  In the video, we have the LED turning on and off with the touch switch.




Ultrasonic Sensor

The ultrasonic sensor measures the distance from objects surrounding around it.  For example, if nothing is in front of the sensor, the printed values are large, and then as the sensor approaches a wall, the values become smaller, indicating there is something close to the sensor.  As you might guess, this can be useful for helping our sciborg avoid obstacles.  The following is the sample code for the ultrasonic sensor.  The sample code here gives value in the serial monitor that corresponds to distances.  A low number indicates something is near to the sensor and a large number indicates the sensor does not sense anything near it.  The sensor can also pick up readings from the sides, not just straight in front of it.




Feedback and Control

A. Fixed Distance, bang-bang control

In Day 3 of Arduinos we made our sciborg travel 10 feet by determining the time it would take and setting out motors to stop after that given amount of time.  In this bang-bang control task, we were able to get our sciborg within a few centimeters of 10 feet.

**Explain testing of values

Now we are using our new sensors to have the sciborg stop in different ways.  We used the ultrasonic sensor to control the point at which our sciborg would stop in front of an obstacle.  In our testing, we found that using the ultrasonic sensor, our sciborg would stop about 10cm short.  We could lower the parameter of how far away it should stop, but the ultrasonic sensor also isn't very steady.  A very lower value doesn't the sciborg to stop in time.



This code is a combination of the ultrasonic sensor code and basic motor sciborg code.  We have the ultrasonic sensor reading values and the motors are controlled by those values.  If the sensor does not sense anything in front, meaning the sensor values are greater than 30, the motors are set to forward at full speed and if the sensor senses an obstacle, meaning the values are less than 30, the motors set the speed to zero.



B. Fixed distance, proportional control

First we had our sciborg travel 10 feet using bang-bang control, and now we want to use proportional control.  Proportional control means that, as the sciborg gets closer to its goal, its speed will be proportional to the remaining distance.  Thus, it slows down as it gets closer to 10 feet.

Using proportional control means we need to do some calculations.  Here in our code the equation we used was Speed = distance * gain, where distance is the distance remaining or error (goal - actual) and gain is a constant that we calculate.  We find the gain constant by taking the maximum speed of the motors 255 and dividing by the total distance.  In this case, we are using the distance 13000 because that is the number of rotations (measured by the encoder) needed to travel 10 feet.  We determined this value by testing different encoder values for the sciborg.  Our gain constant is 0.0196.  Our encoders count down from 13000 to 0, so we take the current reading from the encoder and multiply this by the gain constant. So when the sciborg is at the beginning, it's position is 13000 and this multiplied by 0.0196 is the maximum speed 255.  (This is because we divided 13000 by 255 to get the gain constant in the first place).  Then as the sciborg continues, the current encoder value is decreasing and multiplying by the gain results in a smaller number for the speed.  Therefore it slows down.

There is a typo in this code.  In the last if statement the gain constant should be 0.0196, not 0.02125.  Originally we had a higher gain constant, but later re-did our calculations.  The sciborg in the video is running the correct code.

You might notice there is a function in our code called nudge().  In proportional control, one issue is that around 9 feet, the speed has been getting smaller and smaller, so the sciborg is moving very slow and at some point can no longer move.  However, it hasn't reached 10 feet.  As we found earlier, the sciborg has a minimum speed where the motors are no longer able to move the car.  This value is around 50 for our sciborg.  To solve the problem, we created a function that nudges the sciborg to the end when it can no longer move under the proportional control.  If the speed of the sciborg gets lower than 70 and the sciborg has still not reached its goal, we call a function called  nudge.  This function turns the motors on and off and will continue to do so until 10 feet is reached.






C. Conga Line

Next implemented bang-bang control and proportional control in a different task.  This is the conga line, where we want the sciborg to follow something in front of it.

For bang-bang control, we decided to have the sciborg turn left or right.  Here, if the sensor doesn't sense anything the car turns left and if it senses something it turns right.  This way, when we moved our sheet of Delrin in front of it, it moves forward and slightly right, and then when we moved back with the Delrin it moved forward and slightly left.  This allows our sciborg to 'search' for objects in front of it to follow, while also (somewhat) traveling in a straight line.



At first, we didn't think about doing bang-bang by just having the sciborg move forward.  We could do this by having he motors turn on when nothing is in front of the sensor (meaning the Delrin is further in front of it)  and turn off when something is in front of the sensor (when it's really close to the Delrin).

When we coded for the the conga line with proportional control, we had our sciborg just traveling straight.  Proportional control for the conga line involves having the sciborg move faster when the Delrin sheet is far away and slower when the Delrin sheet is close.


Our next step is using bang-bang and proportional control to have our sciborg follow a white line on the floor.  We are going to use a new sensor that measures brightness!

Arduino Day 3 (Sciborg Part 1)

On Day 3, we started building and programming sciborgs, which are small cars run by 6-AA battery packs.  We attached the battery pack, the Arduino, and the protoboard to the sciborg, and then put a cover on top of the Ardunio that allows us to attach motors and sensors.



SOS Example

We used this example to learn about functions in Arduino.  In this example, there are two functions that are later used in the loop.  Using functions saves time and code writing.




Single Motor

Then, we attached the motors to the Arduino and ran the example program Single Motor. This program runs only one motor and results in the wheel moving backward and forward. We took this program as a starting point and modified it to create our next programs.



Double Motor

This program runs both motors at the same time and speed, so that the wheels of the sciborg move together and it will travel in a (hopefully straight) line.  We modified the original Single Motor program by adding the second motor and setting its speeds exactly the same as the first motor.



Minimum Speed

Next, we tested out different speeds on the sciborg.  We determined the lowest possible speed that made our sciborg still move was around 50.


Here is our sciborg moving incredibly slow!



Hard Turn

Now that we had our sciborg moving in a straight line, we had to figure out how to turn it.  First, we made the sciborg do a hard turn, essentially spinning it around in place.  To do this, we have each motor running at the same speed in opposite directions.





Gentle Turns

Since we don't want it to turn so abruptly, we needed to find how to implement some more gentle turns.  First, we had the sciborg go forward, turn a little, go forward, turn a little, and repeat.  This was successful, but resulted in a somewhat jerky turn.




The next gentle turn we tried out was smoother than the first.  One motor was set slightly faster than the other.  The result was the at the sciborg turned in a small circle.





10 feet

Next, we programmed our sciborg to travel exactly 10 feet.  We initially did this using the delay, finding just the right amount of time for the vehicle to move 10 feet.  After this determined time, which we found to be 9 seconds, we stopped the motor.  In our testing, the sciborg traveled the 10 feet exactly almost every time.  If it was off, it usually was short of 10 ft by about 2-3 cm.




Motor Button

After creating and testing some basic programs, Olivia and I started work on our biggest task of the day: when the sciborg hits an obstacles it backs up, turns, and continues on its way.

First, we needed learn how the Lego motor button worked, so we ran the example program Motor Button on our sciborg.  When the button is pressed, the motors stop, and when it is released, the motors start again.  In the following video, the motors have been set to opposite speeds, so the sciborg turns one way direction, then when the button is pressed and let go of, it turns the other direction.



Hitting a Wall

Now that we had played around with the motor button, we started on the code for hitting the wall.  This code makes the sciborg move straight, then when the button is pushed (it hits the "wall"), the sciborg backs up and turns.  Then the loop restarts and the sciborg continues straight until it hits something else.  For testing, we attached the motor button to the front of the sciborg.





Arduino Day 2

The second day of Arduino work introduced us to Servo motors and potentiometers.  We learned two new example programs called Sweep and Knob and modified them to control the motor and an LED.


Sweep program


The sweep program is used to control a Servo motor.  First we have to include the Servo "language" so that we able to use a Servo motor.  There is a variable that creates a Servo called myservo and then a variable called pos that we can use later to store the Servo position.  In the void setup(); we attach the Servo to pin 9 on our Arduino board.  The loop then tells the motor that when the position is is at 0, move to 180 (degrees) and when the motor is at 180, move back to 0, and do these motions in steps of 1 degree.  The delays waits 15 ms for the Servo to reach the designated position. We don't want the delay to be smaller than 15ms because the motor needs enough time to reach its final position.










































Modified Sweep Program

We next modified the Sweep program to have to have to motor do a different motion.  This helped us learn how the programing for the Servo motors works.  For our modification, Olivia and I made the motor move only 90 degrees.  We also changed the delay and the steps, and thus made it move differently on the second loop.  If we increase the delay (as we did here with 3000ms) for the second for loop, you can really see how changing the 'steps' affects the motor.  It will move, in this case, 15 degrees at a time until it reaches 90.  Our video was taken before we made the change though, so the 'steps' aren't seen here.








































Knob program with Servo Motor

Another example program for a Servo motor is the Knob program.  For this program, we use a potentiometer to control the movement of the motor, i.e. when we turn the knob on the potentiometer, the motor moves at the same time.  We connected the potentiometer to the analog pin A0 on our Arduino and ran the program.  The value is read from the potentiometer pin (potpin) and then that value uses map(); to change the scale of the potentiometer to the scale of the motor.  This makes the motor have the same motion as the potentiometer.
















Knob with LED


Our final task of the day was to use the potentiometer to control the blink rate of the LED, meaning it blinks slower when you turn the knob one way and blinks faster when you turn it the other way. We took our program for the servo and changed it to fit the LED. We again used map to scale the potentiometer reading to the LED rate.














Arduino Day 1

For this next unit, our class is working with Arduinos!  I'm working with Olivia Gada for these projects.  On our first day of Arduinos, we learned what Arduinos were, how to use the software, and how to write code to modify the Blink program, which makes one or more LEDs blink on and off.


The Arduino Uno

Here is an Arduino Uno board, the ones we use in class.  The digital pins at the top are the ones we use for LEDs.  It is important to note that one of the pins  - digital pin 13 - has an LED built into the board itself.  We use this pin to begin with because we don't need to connect an LED to the separate protoboard.
































Blink program

Arduino is an open source software company, meaning anyone can create, share, and change programs used for the hardware.  There are hundreds of example programs, so we use many of them to learn the basics and then modify them to create new programs.  We started by looking at the basic Blink program in the Arduino examples, so we could learn how to write code for our Arduino.  The Blink program makes an LED blink on and off.  It seems simple, but it was important for us to completely understand the code and syntax.

Arduino programming basics: The void setup() runs when the Arduino is connected.  This includes things that you want to happen once, like initializing pins on the Arduino, as we see here.  It's telling the Arudino that we're going to connect something to pin 13 and make it do something.  Then we have the next section void loop().  A loop, as its name suggests, goes through the code again and again and again until you stop it.  We use a loop here because we want the blinking to keep going, not just turn on and off and stop.  First, we set pin 13 to HIGH.  This tell the LED to turn on.  Then delay(); takes an amount of time in milliseconds.  Here we tell it to wait 1000ms (1sec).  Then we write to pin 13 and tell it to turn LOW, which turns the LED off.  And because of the loop, it now returns to the beginning where we tell pin 13 to turn to HIGH.  The final result is the LED blinks at 1 second intervals.








































Modifying Blink program to change blink rate


Next, we wanted to change the LED to blink differently to learn how the delays and times work.  All we need to do here is change the delay time. After we turn the LED to HIGH, we delay 2000ms, or 2 seconds, before turning it to LOW, and then delaying 500ms, or 1/2 of a second.  So now the LED is on for 2 seconds, off for 1/2 second, and keeps going   Again, it seems elementary, but seeing this code for the first time can be confusing and it's important we learn the basics.






























Modifying Blink to create a pattern with 2 LEDs

We now wanted to add a second LED using the protoboard.  In the code, we must initialize the second pin as an output and for this program we used digital pin 12.  Then, we just add some code to make a pattern.  In our program, pin 13 is on for 500ms. There is a short delay, then pin 12 is on for 500ms, then 50ms, 50ms, 50ms, with short delays between each. This creates the effect of a long blink(on 13) and then long, short, short, short (on 12).  And of course, because of the loop it keeps going.



Here is an image of our Arduino and protoboard.  The LED on the protoboard is connected to digital pin 12 and we used the pin already on the Arduino itself for pin 13.  The red wire goes from pin 13 to the same row as the LED, then we have a resistor after the LED, and the black wire connects back to the ground pin.






Modifying Blink to create a pattern with 4 LEDs

Next, we wanted to make a pattern using 4 LEDs. We connected 4 LEDs onto the protoboard and connected them to digital pins 2, 4, 7, and 12. Again, we must first initialize these 4 pins as outputs in the void setup(); Then, we created a pattern that goes up the row of LEDs and back down. The LED in pin 2 is on for 500ms, then LEDs 4, 7, 12, 7, 4, in that order, are on for 50ms each.



















































Here is our protoboard and Arudino with 4 LEDs connected.  Each LED has a wire from its pin on the Arduino and a resistor after it.  Then all of the black wires go to the negative column on the protoboard and a final black wire connects that back to ground on the Arduino.




Blink Without Delay

Next, we learned about the Blink Without Delay program.  With this program, we don't use delay(); like we have previously.  This means that other code can run at the same time without being interrupted by the LED.  We use millis(); and count the number of milliseconds to check if it is time to blink the LED, instead of using delay();.  This program is where we learn how to write if/else statements to control the LEDs.  This program will be important because we might want to use other things with the Arduino that won't be affected by code for the LEDs.















Modifying Blink Without Delay to create a pattern with 4 LEDs

Our final task for the day was to create pattern using 4 LEDs by modifying the Blink Without Delay program  We needed to create variables for each LED in each pin and also for each LED state.  In void setup(); we initialize those four pins as outputs.  Now we come to our loop:  here we used else if statements to tell the LEDs to create our pattern.   Else if statements specify a new condition if the first condition is false.   If LED 1 is off, then LED 1 turns on.  Then if LED 2 is off, it turns on and LED 1 turns off. This continues on so that one LED is off while the three others are on, and the one LED that is off appears to travel down the line.









Lego Racer

Our next project was to design a Lego vehicle with a single motor, powered by a PicoCricket, that can carry a 1.0 kg weight as fast as possible on a 4 meter course.  For our motors we had to use the old Lego rectangular motors that do not have internal gearing, so that we could learn how to make our own gear train.  For this project, my classmate Angel and I worked together! (Here's her blog: http://angelengr.blogspot.com/)

1. Motors and Gears
2. Our Lego Racer and Engineering Analysis
3. Reflection

Motors and Gears


Motors

We first learned about the different types of motors.  The one we had to use for our project was the 9V Lego Motor 2328c01 (which are the "old grey motors").  We compared this to the "new grey motors".  The old motor has a very high speed and low torque because there are no internal gears, and thus it is easier to stall the old one.  On the other hand the new motor is a little slower and has a bit more torque because it has internal gears, so it's harder to stall.

Torque is an important concept when working with motors and gears.   As you can see on the graph, torque and speed are inversely related.
 At one end, you get high torque, but a very slow speed.  And on the other end, you have high speed, but little torque.  So on either end, the vehicle will barely move. Thus, our goal for the project was to find the middle ground.

Also, consider the equation for power: Power = Torque * angular velocity.  We can see on the graph that this middle ground produces the maximum power.

Gears

We then learned about gears and gear trains, which is putting multiple gears together so they move and work together.  Adding gear trains increases the torque of the motor.  There are four types of Lego gears we use in this project:  40, 24, 16, and 8-tooth gears.  To start with a simple example, if we have an 8-tooth driving a 24-tooth gear, the 8-tooth will have to turn 3 times for the 24-tooth to turn 1 time.  These ratios can give us the gear ratio.  In our example, the gear ratio is 3:1 because of 3 turns:1 turn.

This brings up an important point:  Going from a small gear to a big gear lowers the speed and going from a big gear to a small gear increases the speed by a factor equal to the gear ratio.  Not only does the gear ratio affect speed, but it also affects torque.  Going from a small gear to a big gear increases the torque and from a big gear to a small gear decreases the torque.

We can also make longer gear trains, which is our goal for the project.  By starting with big gears and going to small gears, we can make the axle turn very fast.  But we have to think about torque at the same time.  Going from big to small gears will decrease the torque, and then our car wouldn't move!  This is why we need to find the right tradeoff of torque and speed.


Our Lego Car and Engineering Analysis


Angel and I started by experimenting with some different gear trains and measuring the speeds.  We made the body of the car with a simple gear train and the our iterations involved changing the gears to try to make it go as fast as possible.  Each time we changed the gear ratio, we timed the car to see how fast it went.  We went through 4 iterations. 


Gear Ratio:  2.5*3*5 = 37.5
Gear Ratio: 1.67*3*5 = 25

Gear Ratio: 1.67*3*3 = 15
 These gear trains gave us the following times:

      37.5:1     13.6 sec
         25:1     10.2 sec
         15:1     10.8 sec

We saw that as we got lower the time was going to go back up, so we wanted to make a gear train that was in between 25:1 and 15:1.



We took the 15:1 gear train and we changed the first gear to a 16-tooth.  This made the gear ratio 22.5:1.  When we timed the car it went significantly faster than our first tries, at 9.02 seconds.  We decided to keep this gear train for our final car.


Gear Ratio:  2.5*3*3 = 22.5    Time = 9.0 sec

Here is our final gear train on our finished Lego Racer.
We used two 24-tooth, one 40-tooth, one 16-tooth,
and two 8-tooth gears, for a total of six gears

A final change we made to our car was decreasing the amount of Legos we used as much as possible because wanted it to be light.  Angel and I tested it several more times and it finished the course in 9-10 seconds.  When we did a trial run with other students on Tuesday, it took 12 seconds which was longer than usual.  We think it was from testing it and the batteries were low, so we decided to change the batteries for our final race.

The final race took place on Friday.  We raced in pairs and Professor Banzaert recorded everyone's gear ratios and times.  Here is a video of our car:


Afterwards, the class looked at the results of all of our cars. The times are put in order from fastest to slowest.

          Gear Ratio  Time (sec)
              15:1            8.42
           22.5:1            8.92
           15.6:1            9.63
           20.8:1            9.68
           24.7:1          10.57
           20.8:1          10.93

So why isn't there a pattern to these times and gear ratios? We discussed several reasons in class why they is not, such as the size of the wheel, friction from gears and wheels, the number of wheels of the car, the distances of the wheels, and the weight of the car and the wheels.  Overall, it just the fact that we're doing this in real life, not as a computer simulation, and just like in all engineering, other factors come into play.





Reflection


We really enjoyed constructing our Lego racer for this project and are proud of our final car, which was the second fastest in the class!  There were a few interesting things I noticed when looking at the other team's times.  One was that the fastest car had a gear ratio of 15:1 and when we tested our car with a 15:1 ratio it was 2.5 seconds slower!  This really shows how the design of the car matters, like the wheels, the weight, and other aspects.  I think some improvements to our car could be using a larger third wheel instead of a small one.  We talked in class about how using larger wheels increases the angular velocity and this would probably make our car finish faster.  Another improvement would be trying to use the same gear train, but make the rest of the car as light as possible, by using less Legos, or lighter wheels. 

Our next project is very different than what we've been doing so far this semester.  We got out the Arduinos and will be doing some cool projects with them!