Thursday, February 17, 2011

2/16/2011













So Rangi and i met up infront of the class room 2 hours before we had to present to the entire class. We split up the slides to about 5 to 5 and then we would decied who would present the conclusion and Recomendations slides. In the end we were able to finish putting our slide show together and i had to practice with rangi a lot. it was quite intersting watching him and how he reacted to just a hand full of people while trying to demonstrate. Good thing i am not really afaraid of public speaking other wise him and i woudl have not gotten a 90. Rangi did a great job and i'm glad i had him as a partneer who is level headed.

4/15/2011

We were told by mason that we have to get a presentation put together of our robot at the competition. The only thing Rangi and i were able to come up with was a simple 3 slides during that day. We have to finish the rest tomorrow, practice, and get a good grade. It was funny because Rangi does not seem like the PUBLIC speaking type, which means i'm going to have to talk loud.



Day of the can collection comptition

I was the first one from our school to get to fullerton before anyone else. I tested the color sensor and saw that it was working great and demonstrated to many of the RSCC members.

When mason came with his daughter i was instructed to law the competition field out side in the hall near the elevator with the help of Edgar. when i begain to upload the code i had edited last night the robot was acting weird and would only want to go into the "if i'm on a black line " mode. it was so fraustrating and with the little time i had i could not fix the problem.

when it was our turn participate in the compotition our robot was still stuck in that loop. i figured it was the line sensor which i thought was working perfectly. during the compotitoin i uploaded the old "FAIL SAFE" code that i gave to Rangi which was code i knew worked. when i uploaded the code it was still going into the same phase. In a sence that day was a huge bust.

2/11/2011

As one can see the range sensor is not working still not as well. however i noticed that when i worked only with line sensor i had a high chance of getting a can. Rangi wanted me to really start working on the line sensor and the color sensor today instad of the range sensor. His line sensor was working great on the first try with no problems. when we worked on the color sensor though we noticed that it had a hard time find out the difference between blue and white. it was not until that he and i looked at the code that we found the problem.

INSERT CODE HERE

when we finished with that our color sensor was working great. we were able to distinguish between different colors from about 2 inches away which was  a nice advantage compared to other teams.

we also latter found that we had to adjust the color sensor in the ENDGAME phase because the color sesnor had to be at certian positoons to detected the different values of the target color floor. if it had to detect a green value it had to be about 20 degrees up. if it was red it had to be about -10 degress.

#pragma config(Sensor, in1,    LineDetector,        sensorLineFollower)
#pragma config(Sensor, in2,    colorSensor,         sensorReflection)
#pragma config(Sensor, in5,    SonarSensor,         sensorSONAR, int1)
#pragma config(Sensor, in7,    LeftEncoder,         sensorRotation)
#pragma config(Sensor, in8,    RightEncoder,        sensorRotation)
#pragma config(Motor,  port1,           LeftMotor,     tmotorNormal, openLoop)
#pragma config(Motor,  port2,           RightMotor,    tmotorNormal, openLoop)
#pragma config(Motor,  port3,           hand,          tmotorNormal, openLoop)
#pragma config(Motor,  port4,           colorMotor,    tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//



/*  THIS IS THE SIMPLE TRACKER PROGRAM THAT USES THE LINE TRACKER MAINLY TO FIND THE CANS. IF THE CAN IS
IS WITHIN THE CERTIAN DISNCE OF OUR SENSOR(FOUR INCHES) THEN THE COLOR SENSOR WILL CHECK THAT
VALE TO MAKE SURE IT WAS THE ONE THAT IT WENT FOR IN THE TARGETING PHASE. AFTER ITS FOUND ITS
CAN IT WILL LOOK ON THE GROUND AND TRY TO FIND ITS CORRECT COLOR THEN STOP.
*/

void goForward(int distance);
void goForward();
void goLeft(int distance);
void goRight(int distance);
void goStop(int distance);
void goback (int distance);
void grab();
void letGo();
void colorReject();
int colorPositionServo(int targetColor);
int colorCheckVal(int targetColor);



task main
{
  bMotorReflected[port2] = 1;            //Reflects the direction of the motor on port2
  SensorValue[RightEncoder] = 0;      //Set the encoder so that it starts counting at 0
  SensorValue[LeftEncoder]  = 0;
  int lineCheck = 0;                //Line Sensor values
  int targetColor = 0;              //Target color
  int colorCheck=0;                 //Color indicator for collecting cans
  int colorCheck2 = 0;
  int colorPosition = 0;            //FOR THE MOTORS OF THE SEARCH LINGHT WHEN WE ARE TRYING TO FIND THE END GAME IT IS
                                    //(-50) = GREEN (50) = RED (ANY) = BLUE

  int range = 0;                    //Used to hold sonar values
  int groundColor = 0;
  int colorNumber = 0;              //1 = red 2 = blue 3 = green
  bool go = true;                   //While true the loop to find the cans will be true
  bool endGame = true;
  int count =0;                     //count is used to simply check if we have crossed the line 5 times
                                    //if count has more than five it will go forward

  //*!!ALL CODE ABOVE WILL BE DECLARTIONS AND BELOW CODE WILL BE START OF GAME               !!*//

  wait10Msec(200);                  //Waits 2 seconds to be placed down

  motor[port4] = 50;                //Raises the color sensor to find target color.
  wait10Msec(500);                  //waits 5 seconds so the color will be clearly indicated
  motor[port4] = 0;
  targetColor = SensorValue(colorSensor);
  colorNumber = colorCheckVal(targetColor);//COLOR indicates what can it is
  if (colorNumber ==4)              //DOUBLE CHECK if out of range
  {
    motor[port4] = 50;              //Raises the color sensor to find target color.
    colorNumber = 0;
    wait10Msec(500);                //waits 5 seconds so the color will be clearly indicated
    targetColor = SensorValue(colorSensor);
    motor[port4] = 0;
    colorNumber = colorCheckVal(targetColor);
  }


  colorPosition = colorPositionServo(targetColor);  //we pass in the value of the target sensor and now the color position is
                                                    //going to hold whatever value

  //Now going into SEARCH and END GAME MODE
  while (endGame)
  {
    while(go)                                      //GO keeps going until we find the can
    {
      lineCheck = SensorValue(LineDetector);       //set lineCheker to the line detector value during the search loop
      range = SensorValue(SonarSensor);            //set Range as what the sonar will see
      if (lineCheck < 400)                          //If the line is 450 or less we keep moving
      {
        goForward();
        if (range < 4 && range>0)                 //if the range is less than 4 or greater than zero will stop and grab the can
        {
          goStop(200);                               //STOPPP!!!! we are in range!!!
          grab();
          wait10Msec(200);                        //Wait 2 seconds to get a good reading
          colorCheck = SensorValue(colorSensor);  //CAN COLOLR THAT YOU HAVE!!!!
          colorCheck2 = colorCheckVal(colorCheck);//COLOR indicates what can it is
          if (colorNumber == 4)                   //DOUBLE CHECK if out of setRange
          {
            colorNumber = 0;
            colorCheck2 = 0;
            motor[port4] = 50;                    //Raises the color sensor to find target color.
            wait10Msec(500);                      //waits 5 seconds so the color will be clearly indicated
            colorCheck = SensorValue(colorSensor);
            colorCheck2 = colorCheckVal(colorCheck);
          }//end of doubleChecking if statement (still inside the range else and not outside the line
          wait10Msec(200);

          motor[port4] = 0;                         //go to default location for the color sensor
          count = 0;                                //reset count if used before like all other instance of count == 0
          if (colorCheck2 == colorCheck)
          {
            go = false;
          }//second if end and also end of tracking if statement (still inside the range if)
          else
          {
            goback(20);
            colorReject();
            letGo();
            count = 0;
          }
        }//end of range if
        else
        {
          goForward();
        }
      }//END OF IF LINE IS LESS THATN 950
      else
      {

        if(count == 5)
        {
          goForward(200);
        }
        else                                      //THIS IS THE MOVEMENT WHEN WE HIT A LINE
        {
          goStop(20);
          goback(50);
          goStop(20);
          goLeft(200);
          goStop(20);
          count++;
        }
      }
    }//END OF SEARCH(SINGLE TARGET)


    lineCheck = SensorValue(LineDetector);    //Checking if we don't go out of line
    motor[port4] = colorPosition;             //move the motor to the position for the desiered target
    groundColor = SensorValue(colorSensor);   //search whatever our ground color is
    goForward();
    if(lineCheck <350)
    {
      goForward();
      count = 0;
    }
    if(lineCheck>350 &&  groundColor == targetColor)
    {
      goForward(30);
      letGo();
      goForward(20);
      endGame = false;
      count = 0;
    }
    if(lineCheck>350 &&  groundColor <1000)
    {
      goback(20);
      goLeft(200);
      count = 0;
    }
    else                                      //THIS IS THE MOVEMENT WHEN WE HIT A LINE
    {
      goStop(20);
      goback(50);
      goStop(20);
      goLeft(200);
      goStop(20);
      count++;
    }
  }//end of ENDGAME

}//END OF MAIN



void goForward(int distance)
{
  motor[port1] = 35;//rightSide
  motor[port2] = 30;//LeftSide
  wait10Msec(distance);
}
void goForward()
{
  motor[port1] = 35;//rightSide
  motor[port2] = 30;//LeftSide
}

void goLeft(int distance)
{
  motor[port1] = 30;
  motor[port2] = -40;
  wait10Msec(distance);
}
void goRight(int distance)
{
  motor[port1] = 40;
  motor[port2] = -30;
  wait10Msec(distance);

}
void goStop(int distance)
{
  motor[port1] = 0;
  motor[port2] = 0;
  wait10Msec(distance);
}
void goback (int distance)
{
  motor [port1]=-50;
  motor [port2]=-53;
  wait10Msec(distance);
}
void grab()
{
  motor [port3]= -80;     //close the hand to a tight fit (for our servo it was -80)
  wait10Msec(50);
  motor[port4] = 50;      //raise the hand to check the value
  wait10Msec(50);
}
void letGo()
{
  motor [port3]= 0;
  wait10Msec(50);
}
void colorReject()
{
  goLeft(200);
  goForward(20);
  letGo();
  goback(20);
  goRight(200);
}
int colorPositionServo(int targetColor)
{
  int colorPos;
  if(targetColor < 100)
    //If the color sensor reads less than 100 (red) it will set the position
  //else it will go to blue
  {
    colorPos = 50;
  }
  else
  {
    colorPos = -50;
  }
  return colorPos;
}
int colorCheckVal(int targetColor)
{
  int colorNum=0;
  if(targetColor<100)//RED
  {
    colorNum = 1;
  }
  if(targetColor<400 && targetColor>200)//GREEN
  {
    colorNum = 2;
  }
  if(targetColor<900 && targetColor>500)//BLUE
  {
    colorNum = 3;
  }
  if(targetColor>900) //out of range
  {
    colorNum = 4;
  }
  return colorNum;
}
This is the final code that we will use at the compotition

2/10/2011

So we had some mild success today with the detection of finding cans. it was able to at least see something and go and pick it up
 

As one can see from the video our robot is able to see a can but the range is quite weird. it will see it at a certain distance but when it does see it, the values are quite odd. I have spent about 2 days trying to get this to work. and i have only progressed this far. I had to not working on the rotation sensors because they would have taken to much time and not enough worth would come out of using them. Code is not as different as yesterdays because all i was doing was testing the values. Mason said this is really bad practice and i should continue on with the gannt Chart but luckly we are able to go into the class room on a Friday before the day of the competition.

2/9/2011

Today i was working on the range sensor that took forever to understand. i was very frustrated trying to get the code to work. and just getting the robot to move.

#pragma config(Sensor, in1,    LineDetector,        sensorLineFollower)
#pragma config(Sensor, in2,    colorSensor,         sensorReflection)
#pragma config(Sensor, in5,    SonarSensor,         sensorSONAR, int1)
#pragma config(Sensor, in7,    LeftEncoder,         sensorRotation)
#pragma config(Sensor, in8,    RightEncoder,        sensorRotation)
#pragma config(Motor,  port1,           LeftMotor,     tmotorNormal, openLoop)
#pragma config(Motor,  port2,           RightMotor,    tmotorNormal, openLoop)
#pragma config(Motor,  port3,           hand,          tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

void goForward(int distance)
{
  motor[port1] = 40;
  motor[port2] = 30;
  wait10Msec(distance);
}

void goLeft(int distance)
{
  motor[port1] = 60;
  motor[port2] = -40;
  wait10Msec(distance);
}

void goRight(int distance)
{
  motor[port1] = -60;
  motor[port2] =40;
  wait10Msec(distance);
}


void goStop(int distance)
{
    motor[port1] = 0;
    motor[port2] = 0;
    wait10Msec(distance);
}

void goback (int distance)
{
  motor [port1]=-50;
  motor [port2]=-53;
  wait10Msec(distance);

}

void grab()
{
  motor [hand]= -60;
  wait10Msec(50);

}

void letGo()
{
  motor [hand]= 0;
  wait10Msec(50);
}

void grabCan()
{
     goStop(100);
     goForward(100);
     grab();
     goback(100);
     goStop(100);
     letGo();
     goback(100);
}


task main
{
    wait1Msec(2000);                            //Robot waits for 2000 milliseconds before executing program
      bMotorReflected[port2] = 1;        //Reflects the direction of the motor on port2

      SensorValue[RightEncoder] = 0;    //Set the encoder so that it starts counting at 0
      SensorValue[LeftEncoder]  = 0;
      int test = SensorValue(colorSensor);

      bool go = true;
      int oddCheck = 1; //used for remainders to check if odd or left
      bool checkOdd = true;
      int remainder;    //if remainder is odd it goes left if even then right
      int turnCheck = 0;   //Used to check if the robot has gone around in a circle to much
                        //if the turnCheck is more than 10 it will go straight
      goForward(40);
while(go)
 {

   int range = SensorValue(SonarSensor);
   if (range > 8 && range < 35)
   {
     goForward(30);
     if (checkOdd == true)
     {
        oddCheck++;
        remainder = oddCheck%2;
        checkOdd = false;
     }
   }
   if ( range < 0 || range > 35)
   {
     if (remainder==0)
    {
     checkOdd = true;
     goLeft(1);
     turnCheck++;
     if(turnCheck >500)
     {
       goStop(20);
       goForward(20);
       turnCheck = 0;
     }
    }
    if (remainder!=0)
    {
      checkOdd = true;
      goRight(1);
      turnCheck++;
      if(turnCheck>500)
      {
        goForward(20);
        goStop(20);
        turnCheck = 0;
      }
    }
   }
   if (range < 8 && range>0)
   {
      grabCan();
      go = false;
   }
 }
}


By the end of the day i relized that this code is not as great. it still can not find the can's. Also from talking to a lot of the groups i have my max range of good vales (range < 0 || range > 35) set much higher than a lot of groups. but i find it that it helps to search for at least something. but i can see that it detects the walls to much or peoples feet.

Tuesday, February 8, 2011

update color sensor

So i finished the modifications that i had to do. i was behind schedule until saturday where i was able to work out the kinks and now the sensor is able to dected different colors with values of 1000 to about 50.
Today i have to finish the shaft encoders to have the robot turn to the right so we are able know which way we are supposed to go. not sure how this will come into play but i can worry about that on wensday when i have to think about other things

Thursday, February 3, 2011

Color Sensor

This is the color sensor that was on the bread board with electical tape on it

This is the finished product with all the connections



This is the sensor part of the light and also ldr



This is my parners finshed line follower already attached to the robot

Tuesday, February 1, 2011

Using Square bot


Today we used the Square bots that we had built and used RobotC to program. Using Robot C is just like using a C based language. Using robot c is a lot more memory compared to the picaxe program wich is basic based.
Our first task was to run the robot though a maze so that it could navagate though the course only using distance that we inputed.

After seeing that it is very hard to only use distance and no sensors to run our robot professor mason put us in teams of two. in our teams we were given two quad encordrs to make it easer for the robot to manuaver.


after the event it is event that we need to use more sensors to make our robot more efficent.

Thursday, January 27, 2011

Wednesday, January 26, 2011


 
 This is a video of our little robot working with the demonstration of the LDR sensor.

 This is our connection from the brain to the motor control chip
This is our motor control chip which the red wire and black wire from the mouse will go inbetween the yellow wire

Thursday, January 20, 2011

Wednesday, January 19, 2011

1/19/11 Transistors

This is with our logic probe grounded. Note the led is off showign that there is no current even though our other led is still on showing that there is current though that part of the circuit.

Here we have the light working with out bligging in our probe. note how bright the led is.


This is just the back part showing our connections for the comonents.


This is the final product of our test probe with all our parts intirgrated.

Here we are grounded and thus no current flows though the circuit.

Here we see tht when inserting the probe(green wire) we have the light bulb illuminate brightly when the amount current goes though the resistors.

This is the prototype for our logic probe that will test if there is connectivity between parts.

Here we are using a potnetimator (1M ohm) along with other reisisotrs to demonstrante the amount of current needed to light the light bulb.


This picture is very blurry but we can see that when the button is pushed the light goes on thus allowing current to flow though/

Here we are  demonstrating that when using a transistors (NPC) that the base takes in a low current to allow flow from though the circuit.

Thursday, January 13, 2011

January 12 2011

After building our ac power supplies for our breadboards, we were instructed to test if they had continuity . To do this Professor Mason handed us a Packet that demonstrated how to use a multimeter. After taking a crash course on how to use a multimeter we test what the voltage was reading from the power supply (which was 5.15V). Then we were instructed to build varies breadboards under certain conditions. The only frustrating part of this exercise was finding the right resistors. Many times i was forced to use a parallel connection to get the right resistance. Normally this would be an easy task since finding Equivalent resistance is a breeze, however finding the correct resistance from a supply that is very assorted can prove to be frustrating. After finding the correct components I was back on track and competed the three LED exercise by demonstrating if there is more resistance then you will get a dimmer light showing Ohms law of V=IR. After that professor mason showed a supply list of the LED's we had in our kits. He showed that not only does the light bulb need a certain amount of current to flow though it. but also it eats a certain amount of voltage from the power source. This is useful to know if one is going to build a circuit that will have the brightest light. In this exercise we had to demonstrate our knowledge in using Kirchhoff's laws and also Ohms laws to find what the correct resistor to use to achieve the brightest light.

Tuesday, January 11, 2011

January 11 2011 (first Meeting)

Today we in class we went over the labsafty manual which showed us what to do in case of an emergency. also it has many guied lines that go over why many of the rules are implimted for our safty. After the lecture of the safty manual we all took a quiz which showed we all understood the percautions, safty, and procdures during the labs. After we all watched a video which showed good and bad soddering jobs.
After we alll went to the faberication room and we went to work on soddering. first we were given compoents that we had to mount on a  board. After we had to sodder many wires together showing that we are able to fabericate many wires together. after we were told to strip a power sources and fabericate it so we have pins running from the sources.