Thursday, May 7, 2015

Matlab Introduction

This is my first experience with MATLAB!

To familiarize our selves, we read through the first four chapters Allen Downey's Physical Modeling in MATLAB and did some assigned exercises.



Here, n represents the nth element of the fibonacci sequence.





We first simplified the problem for ourselves like this:








The textbook knew we would think in this way!  It informed us that we did not account for all the cars being transferred. Below is the correct code:



This problem taught us how to use a for loop.  The loop runs 52 times to show the number of cars in each location at the end of the year.




Here, we learned how to make plots.  We added three new lines to our loop:












Wednesday, May 6, 2015

Frank the Sciborg follows the brighter path!

This was by far the most difficult project in class.  Our goal was to get cyborg to follow a path made of white tape.  A brightness sensor is attached to the cyborg that outputs readings based on the brightness it detects.

Bang-Bang:

Our first thought was to make the sciborg follow a straight line when it detected the brightest part of the tape.  When it detected darkness, it would rotate to find the bright path again and continue on it.

Several frustrating iterations for this method proved fruitless and Professor Banzaert advised us to allow the sciborg to follow the edge of the tape rather than the center.  We found the brightness sensor to read the edge as 535. The following code moves the sciborg forward when it it detects the edge and turns left to search for the edge when it no longer detects it.

 

Proportional:

This was the most difficult part of the most difficult project!  Our goal was now to implement proportional control.  This meant that our sciborg will be constantly moving instead of stopping and searching for the edge.  

We first calculated our error = current brightness detected - desired brightness = 475
Then we calulated our gain = largest error/total brightness = 1.1

We coded our sciborg so that when it detects a brightness greater than 475 it would search left and search right when it detected the white tape.

The numbers in this code are the result of over 30 iterations and changes in our gains, error, speed, parameters etc, to reach this final stage.  Although it isn't perfect, it was close!  Allowed more time and patience, we would continue to play with the numbers to make it perfect.







Notes:


  1. And interesting observation we made was that when we used a code that worked on a another groups sciborg, it would not work for our sciborg.  Till this day we are not sure why.
  2. This was hard.  
  3. I will forever be afraid of the combination of motors and brightness sensors.





Tuesday, May 5, 2015

Arduino Day 4 - Encoder, Touch Switch, and Ultrasonic Sensor with Frank!

1.  Run encoder code:



With readings:





2.  Have the touch switch turn on an LED and then turn it off.






3.  Connect an ultrasonic sensor and have it read values.



4.  Use encoder information to travel 10 feet.





5.  Have sciborg go forward until touch sensor is pressed and then go backwards.




6.  Have the sciborg go forward if the ultrasonic sensor detects nothing in front of it and stop when it does.






7.  Have the Sciborg use the encoder again to go 10 feet but with proportional control this time.




8.  Create a "nudge" function for the proportional 10 feet code to push the sciborg to the finish line!



10.  Give Frank the capability to follow a CONGA LINE (Bang bang w/ultrasonic sesnor)





11.  Let Frank follow the conga line using proportional control!





Monday, May 4, 2015

Arduino Day 3 - Introducing Frank the Sciborg




  1. Have an LED blink an SOS message.





2. Download Bricktronics application.  Run "Single Motor" example.




3.  Modify the code to include both motors.





4.  Find the minimum speed.  For our sciborg, we found the speed at which the wheels do not move to be 58.



5.  Have the sciborg make a hard turn.  This is achieved by making the speed of one motor 0 while the other one was at 150.


6.  Have your sciborg make a gentle turn.  This was achieved by making one motor slightly faster than the other.





7.  Have the sciborg travel 10 feet and then stop.






8.  Try to make the sciborg go straight.  This code made the sciborg move slightly to the right.




We changed the speeds to correct for this slight turn to the right.  Now it moves slightly to the left!



9.  Have the sciborg move forward, hit a wall, then back up, turn and go.





We encountered much difficulty in trying to make Frank go straight, but it was impossible to perfect.  It could be due to the wheel in the front that swivels in all directions.



Sunday, May 3, 2015

Arduino Day 2 - Servo, Potentiometer, and Photocell!


We continued using the arduino to control LEDs and servos using input from a potentiometer and a photocell.
  1. Connect Servo to Arduino and run "Sweep" example.                                                                                  




  2. Modify "sweep" program to make the servo move faster.  (increments of 10 degrees)




  3. Connect Potentiometer and run "Knob" example.  We noticed that the servo moves as we turn the knob.



  4. Modify "knob."  We change the values of the potentiometer to go from 0 to 500, making the servo move 180 degrees when the knob is turned halfway.







  5. Control blink rate of LED using a potentiometer.






  6. Connect a photocell and use it to control the LED and servo.  When the photocell senses dark or dim, the LED turns on and moves the servo to one position.  When the photocell senses bright or very bright, it turns the LED off and moves the servo to the other posion.







  7. Change the blink rate of the LED based on readings from the photocell.









Saturday, May 2, 2015

Arduino Day 1 - LEDs!

Arduino is a tool used for feed back and control systems.  Our first project with Arduino involves LEDs!

  1. Make sure the Arduino is functioning by plugging it in and run "Blink with Delay" program in examples.



  2. Remove delay.  This makes the light blink so fast, we do not see the change from on and off and it is as if it is on the entire time.





  3. Change blink pattern to on for 2 seconds and off for 1/2 second.





  4. Connect an LED to pin 13 and create a cool pattern with the LED and pin 12. Our first step was the visualize the pattern we desired.  Each light is on or off for 250 miliseconds. It starts with both pins on, then both off, then one on and the other off, then both off and then one one and the other off and then both off.








  5. Add more LEDS into the other pins and make cool patterns!





    Since we had time, we made another one!







  6. Blinking without delay command using current millis.




  7. Make a cool pattern without the delay command and with current millis.



     


     We did another one! 

Playing with the Arduino and LEDs was so much fun!




Friday, April 3, 2015

CSC Visit and Project Ideas

We visited the CSC on campus to observe children and listen to the concerns of the teachers.  Our hope is to create a product that will somehow aid or benefit the children and their teachers.

A list of issues we encountered in at the CSC:


  1. Children have trouble staying on their mats.
  • For this issue, we can design a mat where the children feel engaged and excited to sit down.  This can incorporate LEDs that play a certain pattern as soon as the child sits.
  1. Children become very loud.
  • For this issue, we can design a meter that detects a certain threshold of noise and alerts them using LEDS, faces, and messages.
  1. Children splash water onto the ground, making the floor wet and hazardous.
  • For this issue, we can place sensors on the edges of the box that detect drastic movement that may splash water onto the ground.  Children can be alerted by a flashing LED or a message.
  1. Children are scared to or have difficulty flushing the toilet
  • For this issue we can have a string that the children pull or a button they press to flush the toilet.  The toilet will then sense the children leaving and proceed to flush.
  1. Children need to remember to wash their hands and wash them properly.
  • For this issue we can add a sensor to the water that detects a flush and a child close in order to turn on an LED that will draw the child's attention and remind them to wash their hands.  And LED can also be connected to the soap to remind them to use it.  The light will not turn off until the child washes their hand for at least 10 seconds.