Thursday, February 14, 2013

Day 18 Presentation Day

02/14/2012

           Every team (the whole class) who had participated in the firebot contest were presenting their own robot today.

Presentation by other teams:








 
 
 
Our Team's presentation:

 
Somehow, we got excited in talking about our firebot and we went overtime...
 
 
 
The most common recommandations from all teams was time management. It seemed like every team was having trouble with preparation period being too short.
 
On the last day of class, it was very interesting to hear about other teams' strategies and designs as everyone was trying to keep their own secrets. A lot could be learned from other teams' design and I wished i would have thought of those when our team was designing our robot. It would have greatly improved our robot performance.

Project 2 "FireBot"

Tools and materials:   2 VEX robot kits

Sensors:  flame sensor, line sensor, 2 ultra sonic sensors

Preparation time: approximate 2 weeks

Persons per team: 2

Name of the robot: Theseus





              At the beginning of the project, our team started out with modifying the VEX RC robot that we had built during the second week.

The first modification was simple. The antenna was removed and the encoders, sensors, and sonars were added onto the robot.

Flame sensor

Line sensor

Ultra sonic sonar
 
The robot then went through a simple test run to test the sensors and sonars, ensuring that they can detect black lines, objects, and flame.
 
After installing all the vital components, it was time to think about strategy.
 
The team's strategy started out simple, hit no wall. The strategy was to use two sonars to align the robot perpendicular to the wall. Then the robot will nevigate through the maze moving in straight line and turning with right angle. After enter each room sequentially, the robot will detect the flame and blow it out.
 
 
After the team decided to use two sonars, the robot was once again being modified. A longer bar is installed at the front of the robot and the sonars were spreaded out as far as possible for a better alignment with the wall.
 
However, the plan didn't work out well. The robot had a more difficult time going into the rooms because of the extended beam. If the turns or moves were not precision, the robot often ended up hitting the wall.
 

Meanwhile, the fan was built, and the team decided to put the fan on a rotatable platform for an easier aim at the flame instead of moving the whole robot.




          A fourth modification was implemented to the robot to install the fan turret, to shrink the firebot's size, and put on a start button.
After some successful trials, the team decided upon using this configuration for the firebot. A finalized version of the robot has been made, in which some compnents had been changed for easier repairs.


 
 
From now on, instead of doing hardware improvements, we focus much more on improveing the code for the program.
 
Occasionally, the robot still bumped into the wall because of the limitation of the sonars and the design of the maze for which they would then create a lot of traps for the robot ..
 

Though the robot did manage to nevigate throught the maze and find the flame for most of the time.
Now, with the program finished and the hardware installed, it was up to the day of contest to do more field testing.
 
 
Some field tests that had been done on the day of the contest:

Fortunately, the field testing did show 1 of the weakened joint, so that the team was able to finish the repair before competition started.



Actual contest footage:
First attempt.
 

Replica of the second attempt.
 
 
Although the robot failed to blow out the candle in its first attempt, it did blow out the candle in its second attempt. Victory!
 
As the conclusion to this project, the team's robot was a great success. Two weeks of non-stop testing and hard works had paid off. Althought there are still room for improvements, for a robot that needed to be completed within two weeks, the robot had the best that it could give.
 

Wednesday, February 13, 2013

Day 16 Competition Day!!!

02/09/2013


Competition's location: California State University, Long Beach, Vivian Engineering Technology
                                      Center

All preparation had been completed on Friday. The only thing left to be complete was field testing and manual calibration.

We had named our robot as Theses, the great hero who defeated the minotaur in a maze according to greek's legend. Good Luck Theses!
Hmm... No good, the distance is forshortened and the robot is stuck at the intersection.

OH MY! the stabilizer of the turret fell off after trials of trials with collision calibration. Luckly, this happened before the competition instead of during the competition.

A successful nevigation! Nevigated through 3 rooms and found the candle. Unfortunately it was too far for the fan to blow it out, and the flame was too weak to be detected by our sensor after the first attempt.

Success!!
 
Two weeks of hard works finally paid off!

Day 15 & Day 15.5 Final Test with modified strategy

02/07/2013   &   02/08/2013

            The team's greatest challenge at this point was to refine the strategy so that the robot could move on the intended course ( straight and perpendicular to the wall if not turning).


            A new strategy was made to command the robot to recalibrate itself after moving a certain distance closeer to the wall so that the calibration error could be further minimized. The reasoning behind the reiterative calibration was that as the sonar is closer to the object, the reading becomes more sensitive.
 
 
Most of the nevigation traps and sonar blind spots were at the middle of the maze where the room's entrance and the corners would have a devastating effect.


           Furthermore, the team borrowed another strategy of calibrating with collusion with the wall as the back up if sonar calibration failed.

          As you may have noticed, the wheels were taped with electric tap to increase traction with the ground.



         And finally, the team was able to nevigate through room 3 and 4 using improved strategy.

Day 14 Combo Testing with nevigation and extinguishing flame.

02/06/2013

          Today's goal was to complete a successful nevigation run through all four room with a success rate of at least 80%, being able to detect the candle and going close to it. (If the flame got put out, it would be much much better than our expectation.)

 
Unlike what we had expected, the fan turret and the flame detection went expectional good. However, the nevigation success rate was still below 80%.
 
As shown in the video, the robot managed to nevigate through the first two room, but the path was not straight or perpendicular to the wall as we had expected.
 
After nevigating through the second room, the path which the robot was taking had been greatly deviated from the original course. The robot continously hit the walls on the side and failed to recover from the mistake.

Day 13 Testing fire extinguish mechanism; more nevigation testing

02/05/2013

          Over the weekend, a fan had been built by the team to extinguish the candle in the competition. The fan blades and the motor was taken from an old portable fan while the wind tunnet was made of chips container.
 
The fan was mounted on a turret as prototype for testing.
 
 
 
During the class, the fan turret was installed onto the chassis and a minor modification was done to the rest of the upper compartment to make room for the turret.
A button is also added to the robot for easier press-start.
 
 
The fan's turret would scan close to 160 degrees in front of it.
 
***Front view***

***Rear view***

***Side view***
 
The nevigation test for the day was not successful. Although the robot had been able to navigate all 4 rooms individually on saturday when the team was testing the robot in a classmate house,  the test to nevigate all 4 rooms in one try was filled with flaws such as foreshortened moves and turns.
 
Hopefully by next day, most of the problems will be debugged.
 
 
 

 
 
 
 

Day 12 Firebot strategy planning and hardware modifications

01/31/2013

          Today's goal was to come up with a strategy to reduce the chance for the robot to hit the wall, so that the it could nevigate through the maze smoothly.

         After a few discussions and exchanging ideas, the group agreed to use two ultra sonic sensor to perpendicularly line-up the robot with a wall so that it will always start moving in a straight line normal to the wall after it make a 90 degree turn.

          Since this type of calibration required at least two ultra sonic sonar, the group perchased another sonar from the robotic team and installed it onto the robot.

The twin-sonar scheme worked fine when the sonars are installed at the left and right front end of the forward bumper. Yet the reading unit for the sonar are in inches,  There exist an error in the sonar that the robot would not always be straightened.
 
Therefore, the forward bumperer is added with a longer beam that will extend the sonar even further apart to minimaze the tolerace.
 
When the robot is tested after modication, the result from using the same code poofed that extending the sonar further apart will increase the accuracy.

Tuesday, February 12, 2013

Day 11 Autonomous driving using sensors and ultra sonic sensor

01/30/2013

          Today's challenge was use all the sensors and sonars installed on the robot to do an autonomous driving test, in which the robot would turn right after it sensed the wall, then drive straight and stop upon reaching a blackline. After, it would detect a lit candle, and finally driving straight toward the candle until it reached the marked circle surrounding the candle.

The team's robot has a ultra sonic sonar at the front to detect the wall; a line sensor at the back of the sonar to detect the black line, and the flame sensor is on the toppest compartment in the middle, protected from crashing into the wall.
 
The team's strategy was to use the flame sensor's value to determine the robot's distance from the flame. If the value was over a certain limit, the robot will stop as it knew that it was close to the fire.
 
The team's strategy functions as anticipated. The robot reach it final destination at the outter rim of the candle.

Day 10 Project 1 due; Ultra sonic sonar

01/29/2013

          An ultra sonic sonar is a device that a robot uses to measure the distance between it and an object.

The ultra sonic sonar has two speaker-like cyclinders. One of them produces an ultra sonic sound wave; another one recvieves the returning wave. The sonar measure the distance by measuring how long does it take for the wave to bounce back.
 
The sonar is usually installed at the front of the viechle.
 
The red-looking devices at the back of the viechles are call encoders. They are used to keep tracks how many rotations the wheels have turn. The encode can be used to meansure the amount of rotation needed for the viechle to move for a certain distance.
 
 
 

Day 9 Starting "Fire Fighting Robot" Project; Finishing "Toy Hacking" Project

02/24/2013

         "Fire Fighting Robot", Our new project as well as the final project. The goal for this project is to build an autonomous viechle using 2 VEX robot kits that search for a candle in a predetermined maze and using a fire-extinguishing mechanism to put out the candle without disrupting the base which the candle is placed on.

           The goal for today is to build a functional line sensor and flame sensor and install both sensors onto the VEX rebot that have been built week ago.

 
The flame sensor is composes of a phototransistor and a 10k ohm resistor. The phototransistor is connected to the power and the signal calble while the resistor is connected to the signal cable and ground.
 
The line sensor is composes of a detector (phototransistor) as well as an Infrared emitter. The infrared emitter is connected with a 220 ohm resistor in series and connected between power and gound. The dectector is at the same set up at the flame sensor.
 
Black tapes are used to wrap around the frontend of the emitter so that the IR light will not go stright into the detector. The emitter and the detector is then leveled and taped together with another layer of electric tape. 
 
After installing the hardware and properly programmed, the robot is ready for line and flame detection test.

The robot should be able to stop as soon at it reach the black tap and rotate to search for the flame.
If it find the flame it should stop with the flame sensor pointing at it.

The flame sensor should be at the same level as the flame for best reading.
 
--------------------------------------------------------------------------------
 
Completeing the Toy
 
Some minor modification on the circuit and the programming code has been made.
Since the breadboard and the launchPad was too big to be fitted inside the toy, they are left outside for convenience.

The toy is now ready for final testing.

The final tests are successful, and the toy is ready for presentation on next Tuesday.
 

Day 8 Music; Continue on "Toy Hacking" Project

02/23/2013

                       As we have already discussed, there are many output devices that can be controlled by the microprocessor. The microcontroller has pins for digital output that can control frequency for sound output from a speaker. The program's coding that required to control speaker is simply. The only variables needed are pin_numbers, frequency, and play_time.

here is a sample for the code:

void loop( )
{
     noTone(8);                             // turn off the tone function for pin #8
     tone(8, 440, 200);                  // play sound at 440hz for 200ms on pin#8
     delay(200);                            // silent for 200ms
}

Unfortunately, the videos related to music and sound output was lost, so there will not be any videos for examples.

              ------------------------------------------------------------------------------------------

Since there is no time to work on the project during class time, the project has to be done at home.

The circuit for the project is finally completed and the basic programming is finish.
 
A successful test run after hour of debugging the code.
 The music playing through the toy's speaker is controlled by the launchPad
 
The code for the music is exactly the same style as shown above on the top of the page. However, if you find entering every tone is annoying, you can use an array to store all the tones and let the microcontroller plays them according to their position in the array.

Day 7: Controlling motors with microcontroller; Continue with "Toy Hacking" Project

01/22/2013


                           Last week, we have successfully using microcontroller with input devices such as LDR sensor and button to switch on and off LED lights. This time, we will be using other output devices such as a motor.

                Before we start, we have to know that the maximum current output from the launchPad is very small. Therefore we cannot connect the motor directly at the launchPad, we have to use transistors.

                Some transistors that can handle greater current are TIP120, and MPSA13. One can also use Darlington transistors to handle greater current.

Because motors are quite expansive and of limited supply in the class, it is always safer to test out the circuit with a cheaper output device.
 
In this case, a christmas light tree!  
On the side, the circuit using a MPSA13 transistor is shown.
 
 
Voltage across the light when the base pin is connected to a ~2.2k ohm resistor.

 Voltage across the light when the base pin is connected to a ~330 ohm resistor.
 
As you can notice, the smaller the current going to the base pin will decrease the voltage across the output device. Therefore, we can control the output device by changing the current going to the base pin.
 
 
In case you do not have any TIP120 or MPSA13, you can always use a 2N3904 and a MPSA42 transistor to build the darlington transistors.
 
 
After confirming that the circuit is correctly built, hook the extended wires from the toy's motor to the circuit as the output device. As expected, the motor is activated as expected.
 
Aftering completing all the activities involve driving motors, there is no more time to work on the project. The only project-related complishment for today is to get the motors to work under control.

Day 6 More Microcontroller And Begining the "Hack a toy" Project

01/17/2013

          Other than using the button as the input device, other input devices can also be connected to the microcontrollers as long as the microcontroller is programed to recieve the input data.

 
Using LDR sensor (connecting to digital pin) to signal the launchPad (microprocessor) to turn on or off the LED light.

The LDR will gives a different reading of brightness to the launchPad while the launchPad evaluate the LDR reading to turn on or off one of the two LED light, or both.
 
 
Other than switching light on and off, a microprocessor can also output signal to different output devices. Demostration with other output devices will be left to next week.
 
-----------------------------------------------------------------------------
 
Beginning the "Toy Hacking" project. . .
 
They toy has to be skinned and the hardware are taken out for remodification.
 
All the mechanical parts, and other output devices (motors, speakers) are disconnected from the toy's original circuit board. The wires are then lengthened by soldering to extension wires.
 
The purpose for soldering extension wire was to make connection to the breadboard (if used) or microcontroller easier since they may not be able to fit into the toy.
 
 
 

Tuesday, January 29, 2013

Project 1: Hack a Toy!

          The toy is an "ear flapping toy" which would make a sound, flap its ear and swing it's body when the button at its feet is pushed.

          The idea for the hacked toy is to let people understand how much time they will need to spend on taking care puppies (You can pet the toy by covering the LDR at the back of the toy). So that they will think twice before having a puppy.
 
The toy has 3 output devices: 2 motors, 1 speaker,
and 1 input device: button.
 
One of the motor is for controlling the ears to flap, while another motor is respnsible for swinging the body left and right.
 
-------------------------------------------------------------------------------------------------------------
 
During the  Trails...
 
          The first plan is to use a LDR as an input device to the microporcessor. The toy will keeping swinging its body and flap its ears twice every 5 seconds as long as the LDR is not covered by anything. It will repeat the action for three times.

           Before starting the third time, if the LDR is not blocked from a light source, the toy will enter a "happy mode" in which it will flap its ear 4 times. Afterward, it will wait for another 5 second to repeat the whole process again.

          If not, it will then flash the LED light to indicate it enter the "sad mode". Afterward, it will ignore you for 10 second before it repeat the whole process again.

           Here is a example vedio for the action:

 
The circuit includes a Tip 120 transistor to control the current flow to the ear motor. A MPSA13 transistor controls the current flow to the body's motor. They relay controls the direction of the ears.Fially, there are few resistors of different values and a LED light.
 
 

--------------------------------------------------------------------------------------------------------------------------

                                                                 The Final Product
          The final product was modified with few more outputs and refined motions. Instead of giving only 2 chance to interact with the toy to make it happy, it now has 3 chances. Which mean the attention gathering moving is increased to 4 times instead of the original 3. After entering the "happy mode", it will also play a music. As for the "sad mode", it will play another music (a section from the song "さよならの夏” (The Summer we said goodbye) to show its loneliness.

             A potentiometer and a speaker is  added to the circuit for the sound effect.

Here is a sample for the "happy mode":
 (the music may not be heard clearly)
 

Here is a sample for the "sad mode":
(the music may not be heard clearly)
 
The Source-code for the project:
#define sensorPin A0
#define earPin 8
#define directPin 9
#define ledPin 3
#define bodyPin 7
#include "pitches.h"
int sensorValue;
void setup()
{
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(7, OUTPUT);
}
void loop()
{
  int sensorValue;
  sensorValue = analogRead(sensorPin);
  if (sensorValue >= 100)
  {
    int counter;
    counter = 1;
    digitalWrite(ledPin, LOW);
    digitalWrite(earPin, LOW);
    digitalWrite(bodyPin, HIGH);
    while (sensorValue >= 400 && counter < 4) // Automatically activate under day light.
    {
      digitalWrite(earPin, HIGH);
      digitalWrite(directPin, HIGH);
      delay(200);
      digitalWrite(directPin, LOW);
      delay(200);
      digitalWrite(directPin, HIGH);
      delay(200);
      digitalWrite(directPin, LOW);
      delay(200);
      digitalWrite(earPin, LOW);      // Flap the ears twice to attraction attention & wait for interaction.
      counter = counter + 1;
      delay(5000);
      sensorValue = analogRead(sensorPin);
    }
    if (counter < 4 && sensorValue < 400)    // Cover the toy's rear LDR sensor at the back before 3     attempted attractions by the toy to enter friendly
      {                                      // & happy mode.
      digitalWrite(bodyPin, LOW);
      digitalWrite(earPin, HIGH);
      digitalWrite(directPin, HIGH);
      delay(200);
      digitalWrite(directPin, LOW);
      delay(200);
      digitalWrite(directPin, HIGH);
      delay(200);
      digitalWrite(directPin, LOW);
      delay(200);
      digitalWrite(directPin, HIGH);
      delay(200);
      digitalWrite(directPin, LOW);
      delay(200);
      digitalWrite(directPin, HIGH);
      delay(200);
      digitalWrite(directPin, LOW);
      delay(200);
      digitalWrite(earPin, LOW);
      tone(5, NOTE_A3, 200);
      delay(500);
      tone(5, NOTE_A3, 200);
      delay(500);
      tone(5, NOTE_A3, 200);
      delay(200);
      tone(5, NOTE_B2, 200);
      delay(200);
      tone(5, NOTE_E5, 600);
      delay(200);   
      counter = 0;
      delay(5000);
    }
    if (counter >= 4)                      // Leave the toy alone to let it enter the lonely mode &
    {                                      // play the song "The Summer We Said Goodbye".
      digitalWrite(earPin, LOW);
      digitalWrite(bodyPin, LOW);
      digitalWrite(ledPin, HIGH);
      delay(1000);
      digitalWrite(ledPin, LOW);
      delay(500);
      digitalWrite(ledPin, HIGH);
      delay(1000);
      digitalWrite(ledPin, LOW);
     
      // Flash the LED, then play the music.
      // Refer music to sayonara_No_Natsu.ino
     
      tone(5, NOTE_B2, 800);
      delay(400);
     
      tone(5, NOTE_G3, 2000);
      delay(800);
      tone(5, NOTE_B3, 800);
      delay(400);
     
      tone(5, NOTE_F3, 2000);
      delay(800);
      tone(5, NOTE_B3, 800);
      delay(400);
     
      tone(5, NOTE_E3, 2000);
      delay(800);
      tone(5, NOTE_D3, 400);
      delay(400);
      tone(5, NOTE_C3, 400);
      delay(400);
     
      tone(5, NOTE_D3, 2000);
      delay(900);
      tone(5, NOTE_G2, 800);
      delay(400);
     
      tone(5, NOTE_C3, 800);
      delay(400);
      tone(5, NOTE_D3, 800);
      delay(400);
      tone(5, NOTE_E3, 800);
      delay(400);
     
      tone(5, NOTE_B2, 800);
      delay(400);
      tone(5, NOTE_E3, 800);
      delay(400);
      tone(5, NOTE_G3, 800);
      delay(400);
     
      tone(5, NOTE_F3, 200);
      delay(100);
      tone(5, NOTE_G3, 200);
      delay(100);
      tone(5, NOTE_F3, 2000);
      delay(800);
      tone(5, NOTE_CS3, 800);
      delay(400);
     
      tone(5, NOTE_DS3, 2000);
      delay(800);
      tone(5, NOTE_E3, 400);
      delay(400);
     
      tone(5, NOTE_E3, 6000);
      delay(10000);
    }
  }