Tuesday, February 14, 2012

Project 2

In our final project we attempted to search four rooms and extinguish a lit candle. To extinguish the candle we used a smacking type device which was controlled by two motors.





#pragma config(Sensor, in1,    firesensor,          sensorPotentiometer)
#pragma config(Sensor, in5,    Ultrasonic,          sensorSONAR, int1)
#pragma config(Sensor, in3,    leftEncoder,         sensorRotation)
#pragma config(Sensor, in2,    rightEncoder,        sensorRotation)
#pragma config(Motor,  port2,  rightMotor,    tmotorNormal, openLoop,reversed)
#pragma config(Motor,  port3,  leftMotor,     tmotorNormal, openLoop)
#pragma config(Motor, port7,   rightarm,      tmotorNormal, openLoop)
#pragma config(Motor, port8,   leftarm,       tmotorNormal, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

  //turn left
  //Look for the fire
  //If you find the fire gofoward
  //If you don't find the fire turn left more (repeat)
//to get out of the room use ultrasonic to find the empty wall

void goforward(int distance)
{
  SensorValue(leftEncoder)=0;
  SensorValue(rightEncoder)=0;
  while(SensorValue[leftEncoder]<distance && SensorValue(rightEncoder)<distance)
    {
      if (SensorValue(Ultrasonic)>2)
        {
          motor[port3]=60;
          motor[port2]=60;
         }
      }
   motor[port3]=0;
   motor[port2]=0;
}
void raisearm(int time10)
{
  motor[port7]=-34;
  motor[port8]=34;
  wait10Msec(15);
}


void findflame2(int time10)
{
  SensorValue[leftEncoder] = 0;
  bool flamenotfound2 = true;
  while(flamenotfound2)  //Play with number 180
      {
        if (SensorValue(firesensor)<100 && SensorValue[leftEncoder]<520)//search
          {
            motor[port2]=-60;
            motor[port3]=60;
            wait10Msec(5);
            motor[port2]=0;
            motor[port3]=0;
            wait10Msec(1);
          }

        if (SensorValue(firesensor)>100 && SensorValue(firesensor)<200)// first go find it
          {
            motor[port2]=60;
            motor[port3]=60;
            wait10Msec(10);
            motor[port2]=0;
            motor[port3]=0;
            wait10Msec(1);
          }
        if (SensorValue(firesensor)>200 && SensorValue(firesensor)<450)
          {
            motor[port2]=-60;
            motor[port3]=60;
            wait10Msec(5);
            motor[port2]=0;
            motor[port3]=0;
            wait10Msec(1);
           }
        if (SensorValue(firesensor)>450 && SensorValue(Ultrasonic)>6)
          {
            motor[port2]=60;
            motor[port3]=60;
            wait10Msec(5);
            motor[port2]=0;
            motor[port3]=0;
            wait10Msec(1);
          }

        if (SensorValue(firesensor)>850 && SensorValue(Ultrasonic)<6)
          {
            SensorValue(leftEncoder)=0;
            SensorValue(rightEncoder)=0;
            while(SensorValue(leftEncoder)<200 && SensorValue(rightEncoder)<200)
            {
              motor[port2]=0; //Stop
              motor[port3]=0;
              wait10Msec(5);
              motor[port7]=127;  //commence wacking
              motor[port8]=-127;
              wait10Msec(50);
              motor[port7]=-127; //return wacker
              motor[port8]=127;
              wait10Msec(50);
              motor[port2]=-60; // Spin by time !Not Good!
              motor[port3]=60;
              wait10Msec(7);
              motor[port2]=0; //Stop
              motor[port3]=0;
              wait10Msec(5);
              motor[port7]=127;  //commence wacking
              motor[port8]=-127;
              wait10Msec(50);
              motor[port7]=-127; //return wacker
              motor[port8]=127;
              wait10Msec(50);
              motor[port2]=60; //  Good!
              motor[port3]=-60;
              wait10Msec(7);
            }
          }
            // Signal that the flame is found
        if (SensorValue(firesensor)<=60 && SensorValue(leftEncoder)>=520)
          {
            flamenotfound2 = false;
          }
        }
      }


void goleft(int distance)
{
  SensorValue(leftEncoder)=0;
  SensorValue(rightEncoder)=0;
  while(SensorValue[leftEncoder]<distance && SensorValue(rightEncoder)<distance)
    {
      motor[port3]=-60;
      motor[port2]=60;
    }
   motor[port3]=0;
   motor[port2]=0;
}

void goright(int distance)
{
  SensorValue(leftEncoder)=0;
  SensorValue(rightEncoder)=0;
  while(SensorValue[leftEncoder]<distance && SensorValue(rightEncoder)<distance)
    {
      motor[port3]=60;
      motor[port2]=-60;

    }
   motor[port3]=0;
   motor[port2]=0;
}

void findflame1(int time10)
{
  SensorValue[leftEncoder] = 0;
  bool flamenotfound1 = true;
  while(flamenotfound1)  //Play with number 180
      {
        if (SensorValue(firesensor)<100 && SensorValue[leftEncoder]<507)//search
          {
            motor[port2]=-60;
            motor[port3]=60;
            wait10Msec(5);
            motor[port2]=0;
            motor[port3]=0;
            wait10Msec(1);
          }

        if (SensorValue(firesensor)>100 && SensorValue(firesensor)<200)// first go find it
          {
            motor[port2]=60;
            motor[port3]=60;
            wait10Msec(10);
            motor[port2]=0;
            motor[port3]=0;
            wait10Msec(1);
          }
        if (SensorValue(firesensor)>200 && SensorValue(firesensor)<450)
          {
            motor[port2]=-60;
            motor[port3]=60;
            wait10Msec(5);
            motor[port2]=0;
            motor[port3]=0;
            wait10Msec(1);
           }
        if (SensorValue(firesensor)>450 && SensorValue(Ultrasonic)>6)
          {
            motor[port2]=60;
            motor[port3]=60;
            wait10Msec(5);
            motor[port2]=0;
            motor[port3]=0;
            wait10Msec(1);
          }

        if (SensorValue(firesensor)>850 && SensorValue(Ultrasonic)<5)
          {
            SensorValue(leftEncoder)=0;
            SensorValue(rightEncoder)=0;
            while(SensorValue(leftEncoder)<200 && SensorValue(rightEncoder)<200)
            {
              motor[port2]=0; //Stop
              motor[port3]=0;
              wait10Msec(5);
              motor[port7]=127;  //commence wacking
              motor[port8]=-127;
              wait10Msec(50);
              motor[port7]=-127; //return wacker
              motor[port8]=127;
              wait10Msec(50);
              motor[port2]=-60; // Spin by time !Not Good!
              motor[port3]=60;
              wait10Msec(10);
              motor[port2]=0; //Stop
              motor[port3]=0;
              wait10Msec(5);
              motor[port7]=127;  //commence wacking
              motor[port8]=-127;
              wait10Msec(50);
              motor[port7]=-127; //return wacker
              motor[port8]=127;
              wait10Msec(50);
              motor[port2]=60; //  Good!
              motor[port3]=-60;
              wait10Msec(10);
            }
          }
            // Signal that the flame is found
        if (SensorValue(firesensor)<=60 && SensorValue(leftEncoder)>=507)
          {
            flamenotfound1 = false;
          }
        }
      }

task main()
{
   while(true)
   {
    wait10Msec(200);//searches first room
    raisearm(10);
    wait10Msec(100);
    goforward(373);
    wait10Msec(10);
    goright(97);
    wait10Msec(10);
    goforward(320);
    wait10Msec(10);
    goright(96);
    wait10Msec(10);
    goforward(135);
    wait10Msec(10);
    findflame1(150);//looks for flame ans if found puts it out
    wait10Msec(10);
    goforward(135);//gets out of the room
    wait10Msec(10);
    goleft(93);
    wait10Msec(10);//goes to the next room
    goforward(301);
    wait10Msec(10);
    goright(100);
    wait10Msec(10);
    goforward(415);
    wait10Msec(10);
    goright(95);
    wait10Msec(10);
    goforward(220);//enters room in front
    wait10Msec(10);
    findflame2(150);
    wait10Msec(10);
    goforward(215);
    wait10Msec(10);
    goleft(91);
    wait10Msec(10);
    goforward(170);
    wait10Msec(10);
    goright(90);
    wait10Msec(10);
    goforward(240);
    wait10Msec(10);
    findflame1(150);
    wait1Msec(10);
    goforward(120);
    wait10Msec(10);
    goright(90);
    wait10Msec(10);
    goforward(200);
    wait10Msec(10);
    goright(90);
    wait10Msec(10);
    goforward(200);
    wait10Msec(10);
    goleft(90);
    wait10Msec(10);
    goforward(120);
    wait10Msec(10);
    findflame1(150);
    wait10Msec(10);
   }
}

Wednesday, February 8, 2012

Find the Flame/Robot moving into room one

Here is a video demonstrating how our robot moves from the starting point into room one as it detects and extinguishes the flame.



Monday, February 6, 2012

Ultrasonic Rangefinder and other Sensors

In this experiment we were able to demonstrate how our robot implements the flame, and ultrasonic sensors work. We did this by programming the ROBOTC software and affixing the sensors to our bot. The video shows how the flame sensor detects the heat of the flame while the ultrasonic sensor detects the range of the box.









Thursday, February 2, 2012

Building a Sensor for your Robot

For the Building a Sensor experiment, we used a phototransistor to detect the heat, via infrared, a candle emitted. Once the circuit was made using a bread board, wires, and resistor we lit up a candle and placed it in front of the sensor moving it back and forth.








Wednesday, February 1, 2012

Vex Programming

In the Vex Programming experiment, my partner and I had two objectives: 1) program the vex bot to operate properly in the labyrinth using time, and 2) program the vex bot using encoders. We used the ROBOTC program for both parts. In the first objective, we used time as the main source to control the bot, such as 3000ms = 3 seconds. In the second part we had to control the bot using the encoder which counts rotation instead of time.

                                                                   timing program



                                                                 encoder program







Thursday, January 26, 2012

Project 1

In project number one I had to manipulate  a toys motor, and sound functions by using picaxe software. Initially, I had to locate the wires that were connected to the motor, and to the speaker. Once the wires were located I then provided it with power to be certain the motor was functioning properly. Next, I started to program the software that would control the motor and speaker by using picaxe. After spending some time tweaking with the program I decided on using the pwmout for the motors and the tune command for the sound. After the program was completed and downloaded to the microcontroller I then connected my toy to the circuit board. The circuit board used was from the previous experiment; however, a piezo sounder was added to the circuit to establish the sound of the tones. Both the motor control and sound worked after the power was plugged in.













Wednesday, January 25, 2012

Interfacing to a microcontroller

In this experiment I worked on a lamp circuit controlled by a microcontroller. After completing the circuit and programming the apex software I was able to get the lamp bulb to flash off and on with a pause





Sunday, January 22, 2012

Hacking a Toy

In the hacking a toy experiment I needed to find the power supply wires that were connected to the circuit board. I found the wires by locating an M+ and M- that was displayed on the circuit board which I then cut with the wire cutters. I also found the wires that controlled the microswitch. I found these wires by taking the right foot apart and then tracing it back to the circuit board.



Friday, January 20, 2012

Introduction to Microcontrollers

In this experiment I installed some software into the picaxe microcontroller which would control the frequency and brightness of an LED. This software would make the LED flash on and off continuously. It  was constructed using a simple circuit with wires, resistors, an LED, breadboard, and a serial port.




In this step the software was programmed so that the LED would blink at a faster pace.








The next step I used the same circuit; however, I reconfigured the program so that the LED would wait a little longer when lit than turn off.







In this step I used the same set up but reprogrammed the software to count/blink to 15 then shut off.



A push button and two resistors were added to the circuit. After reprogramming the software, once the button is pushed the LED shuts off.








Finally, I added an LDR, an LED  and two additional resistor to the previous circuit. With this new circuit and after reprogramming the software, one of the LEDs would stay on until light is completely blocked from the LED.




Thursday, January 19, 2012

Transistor Switching

In the transistor switching I constructed a circuit on a breadboard using several different resistors, a transistor, a micro switch, an LED, and some wires. Once the power was connected the Led would turn on and after the micro switch was pushed the LED would turn off.



In this step I removed the micro switch and the R2 resistor and replaced it with one of my fingers which would close the circuit making the LED turn on.



Demonstrating a Logic Probe

In this experiment all I was doing was demonstrating that my logic probed worked. After cutting away the connectors from each pin of the circuit board that wasn't needed I was able to get the LED to light up. Just like on the breadboard when it is open it is dim, and when it is plugged into the positive power then supply it is at its brightest, and when it is a closed circuit it is off.










Wednesday, January 18, 2012

Build a Logic Probe

In building a probe, I built a simple circuit using a breadboard, an LED, and a couple resistors. The LED, when giving a power supply, lights up when the probe is connected to the positive source, and turns off when unplug.




In the next step I added a third resistor and when power is supplied the LED is at its brightest. When the LED is open it is dim and when closed it is the LED is off.








In the final parts I constructed the bread board simple circuit onto a circuit board, and also made a serial connector. Basically transferred all components onto a circuit board, and soldered each point along with two alligator clips. I also soldered three wires to the serial connector each wire is about 2 feet in length.






Switches and Relays part 2

In this part of the switches and relays experiment I constructed a square bot. I constructed it by using the kit that was handed out in class. After building the square bot and finding two batteries, I downloaded several programs in order for the square bot to function properly. The square bot was able to move forward, reverse, and in circles.



Monday, January 16, 2012

Switches and Relays

In this exercise I built a simple circuit following an example diagram using two toggle switches, an LED, a 220 Ohm resistor, bread board, and wires.



In the next exercise I followed a schematic in building my own circuit on a bread board. I used my 5.3V power supply, wires, two LEDs, a resistor, a relay, and a push button switch. I was able to construct the circuit so that when the button was pushed one of the LEDs would turn on while the other would turn off.



Friday, January 13, 2012

schematics, Ohm's Law, and Potentiometes part 2

Ohms Law and Potentiometer


In Ohms Law I determined the amount of resistance that was needed to produce the brightest amount of light emitted by the LED giving the amount of power from my power supply. I did this by using Ohms Law I=V/R. After performing the calculation I obtained a value of 155.0 Ohms or 150 Ohms.

In the next step I assembled the circuit with a breadboard, 150 Ohm resistor, LED, jumper wire, potentiometer, and power supply.


Thursday, January 12, 2012

Schematics, Ohm's Law, and Potentiometers

Changing brightness with resistors

In this experiment I connected my power supply to a bread board. I then placed three LEDs each one connected to a resistor of 100 ohms, 1.0 Kohms, and the last connected to 10Kohms. I also connected three jumper wires to each LED/resistor. The LED with the least amount of resistance, the brightest, was the  LED connected to the 100ohm resistor. The LED that was dimmest was connected to the 10K resistor.
A 5Kohm resistor would be brighter than the 10Kohm and dimmer than the 100ohm, and 1.0Kohm resistor.



Ohm's Law

did not have enough time to complete this part

Intro to using a breadboard, multimeter

Using a Breadboard

Here is the breadboard that i used to connect a power supply , a 1.0K ohm resistor, and a LED.




Using a Multimeter

In this experiment I used a multimeter , set to DC, to determine the voltage of a D-cell, and 9.6V battery. I did this by placing one probe on the positive and the other probe at the negative end of the battery. The reading of the D-cell battery was 1.608V, and the 9.6V battery was 7.87V








In this step I used the multimeter to find the voltage of a unregulated adapter, and also when a 100 ohm resistor runs across the two terminals. The values for the adapter were 0.115V and with the resistor connected it was 4mV




I also used a multimeter to test the power supply I made during first class meeting. Unfortunately I have no data or pics for this step I guess I skipped passed it.




In the final multimeter step I tested a 9V AC adapter. Again i did this by placing the positive probe on the positive part and the negative probe on the negative part of the adapter. The values I obtained were 9.48V while it stated 9V. In this step I also forgot to take a photo of the experiment. 



Resistance testing

 In this experiment I  tested numerous types of resistors. I set the multimeter to ohms and took the probes and placed them at opposite ends of the resistor. Here is a picture of the the process that took place. The recorded values are in the handout. 



Testing a potentiometer

In the potentiometer experiment I found the max and lowest resistance of the potentiometer.
By placing the probes onto the pins of the device I was able to obtain a low reading of 10.3ohms and a max reading of 8.25Kohms. When switching to the adjacent pins the readings would exchange with one another. My potentiometer tested linear.



Wednesday, January 11, 2012

introduction to soldering and making a 5v power supply

Soldering a PCB

I used a soldering iron to solder 20 points of various components onto a PCB. When soldering I made sure to over the entire pad without touching any other pads, and also making the solder cone shaped and shiny.





Splicing and Soldering wires

In this exercise I used a wire cutter to cut and strip about 3/8 of an inch off the insulation from each end of four equal size wires. Once the insulation was off I soldered each of the pieces together then used the soldering iron to heat up and shrink the heat shrink.





Power Supply

Finally, I assembled a 5V power supply. First, i cut off and discarded the plug and then stripped off about 3/8 of an inch of insulation. I then soldered the wires onto a two pin plug, and added heat shrink to cover up the exposed wires.