Thursday, 15 November 2012

Final Post

The Final Year Project was a success. i would like to thank to my Advisor Sir Razak, and my friend, Shahnizam, Alif, Zuhaili, Kamarul,Fazreen and to my senior. i hope this project can help others in anyway it would. The FYP demonstration is coming near. i hope everything will go well and hope the assessor go easy on me. it was a great journey in doing this project. thanks to all the reader who read this, chireo! :)

Final Year Project Poster 25


video 24

Assembling and attaching the components with the hardware. 23

there are only a few photos here. sorry for the inconvenience. Im just too excited in finishing this project that i forgot to takes pictures. luckily i still manage to capture few of them!

attaching the motor with the prospect.
Almost done with the Robot part.
attaching the GP2D12 
the controller part. the transmitter is being attached to the controller
full view of the controller when it finished.

Making hardware for the robot 22

After finish making the circuit, it is time to make the hardware or the body of the robot. here are some photo in making the body of the robot.

The cutting of prospect process.
the desired size of prospect
making holes for the prospect to fit the push button,LED, or bolts and nuts.

Source Code for Mobile Robot Tracking System (Receiver) 21

**Coding for Receiver(Robot)**


#include <16f877A.h> //use pic16f877a
#device adc=10    //set 10-bit adc
#use delay(clock = 20000000)  //clock=20mhz
#fuses hs, noprotect, nowdt  //default setting

#byte PORTA=5  //port a address
#byte PORTB=6  //port b address
#byte PORTC=7  //port c address
#byte PORTD=8  //port d address
#byte PORTE=9  //port e address

//system variables
long int mymax;
long int rxir;
long int rxir_org;
int speed1=100;
int speed2=100;
int turn_en=0;
int run=0;
int on_timer=0;      
int en_robot=0;

//modules to drive motor1
void motor1_fwd();
void motor1_rev();
void motor1_stop();

//modules to drive motor2
void motor2_fwd();
void motor2_rev();
void motor2_stop();

void main()
{
   //setup io for each pic pin
   set_tris_a(0b00000101);
   set_tris_b(0b11000000);
   set_tris_c(0b00000000);
   set_tris_d(0b00000000);
   set_tris_e(0b00000000);
   setup_ccp1(CCP_PWM);
   setup_ccp2(CCP_PWM);
   setup_timer_2(T2_DIV_BY_16, 100, 1);
   setup_port_a(ALL_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_pwm1_duty(speed1);
   set_pwm2_duty(speed1);

   //stop robot
   motor1_stop();
   motor2_stop();

   output_high(pin_d7);  //on red led
   output_high(pin_d6);  //on green led
   output_high(pin_d5);  //on blue led
   delay_ms(1000);
   output_low(pin_d7);  //off red led
   output_low(pin_d6);  //off green led
   output_low(pin_d5);  //off blue led
   delay_ms(1000);

   set_adc_channel(2);
   delay_ms(10);
   rxir_org=read_adc();
   rxir_org=rxir_org+10;

   do
   {    
      set_adc_channel(0);
      delay_ms(10);
      mymax=read_adc();

      set_adc_channel(2);
      delay_ms(10);
      rxir=read_adc();
 
      if(rxir>rxir_org) //if transmitter signal detected
      {
         output_high(pin_d5);  //on blue led
         on_timer=20;      
         en_robot=1;
      }
      else  //if transmitter data not detected
      {
         if(on_timer>0) //if timer >0
         {
            on_timer=on_timer-1; //count down
         }
         else  //if timer =0
         {
            output_low(pin_d5);  //off blue led            
            en_robot=0;
         }
      }

      if(input(pin_b7)==0) //if green button pressed
      {
         set_adc_channel(2);
         delay_ms(10);
         rxir_org=read_adc();
         rxir_org=rxir_org+20;
         delay_ms(10);
         run=1;    
      }

      if(input(pin_b6)==0) //if red button pressed
      {
         run=0;    
      }

      if(run==1)  //under run mode
      {
         output_low(pin_d7);   //off red led
         output_high(pin_d6);  //on green led

         if(en_robot==1)   //if robot enabled
         {
            //start robot
            set_pwm1_duty(speed1);
            set_pwm2_duty(speed1);

            if(mymax<=240)   //if no obstacle in range
            {
               //forward robot
               motor1_fwd();
               motor2_fwd();      

               if(turn_en==1)
               {
                  turn_en=0;
               }
               else
               {
                  turn_en=1;
               }
            }
            else if(mymax>240 && mymax<320)   //if obstacle just in range
            {
               //stop robot
               motor1_stop();
               motor2_stop();                
            }      
            else if(mymax>=320)   //if obstacle too close
            {
               //reverse robot
               motor1_rev();
               motor2_rev();                
            }      
         }
         else
         {
            set_pwm1_duty(speed2);
            set_pwm2_duty(speed2);

            if(turn_en==1)
            {
               //turn to left
               motor1_fwd();
               motor2_rev();                
            }
            else
            {
               //turn to right
               motor1_rev();
               motor2_fwd();                            
            }
         }
      }
      else  //under stop mode
      {
         output_high(pin_d7);  //on red led
         output_low(pin_d6);  //off green led
   
         //stop robot
         motor1_stop();
         motor2_stop();
      }

      delay_ms(250);

   }while(1);
}

void motor1_fwd() //module to forward motor1
{
   output_high(PIN_C3);
   output_low(PIN_C0);
}

void motor1_rev() //module to reverse motor1
{
   output_low(PIN_C3);
   output_high(PIN_C0);
}

void motor1_stop()   //module to stop motor1
{
   output_low(PIN_C3);
   output_low(PIN_C0);
}
void motor2_fwd() //module to forward motor2
{
   output_high(PIN_D0);
   output_low(PIN_D1);
}

void motor2_rev() //module to reverse motor2
{
   output_low(PIN_D0);
   output_high(PIN_D1);
}

void motor2_stop()   //module to stop motor2
{
   output_low(PIN_D0);
   output_low(PIN_D1);
}

Source code for Mobile Robot Tracking System Controller 20

**Coding for Controller ( Transmitter **


#include <16f877A.h> //use pic16f877a
#use delay(clock = 20000000)  //clock=20mhz
#fuses hs, noprotect, nowdt  //default setting

#byte PORTA=5  //port a address
#byte PORTB=6  //port b address
#byte PORTC=7  //port c address
#byte PORTD=8  //port d address
#byte PORTE=9  //port e address

void main()
{
   int entx=0;

   //setup io for each pic pin
   set_tris_a(0b00000000);
   set_tris_b(0b11000000);
   set_tris_c(0b10000000);
   set_tris_d(0b00000000);
   set_tris_e(0b00000000);
   output_low(pin_c6);  //off ir transmitter    

   output_high(pin_c1);  //on blue led
   delay_ms(1000);
   output_low(pin_c1);  //off blue led
   delay_ms(1000);

   do
   {
      if(input(pin_b7)==0) //if green button pressed
      {
         entx=1;    
      }

      if(input(pin_b6)==0) //if red button pressed
      {
         entx=0;    
      }

      if(entx==1)  //under run
      {
         output_high(pin_c6);  //on ir transmitter
         output_high(pin_c1);  //on blue led
         delay_ms(50);
         output_low(pin_c1);  //off blue led
         delay_ms(50);      
      }
      else  //under stop mode
      {
         output_low(pin_c1);  //off blue led    
         output_low(pin_c6);  //off ir transmitter    
      }

   }while(1);
}

Procedure for making a circuit. 19

in this post i will include both circuit. since the process are the same i will be only explaining it once.

STEP 1

STEP 2
STEP 3

STEP 4
STEP 5

STEP 6

STEP 7
STEP 8
STEP 9
STEP 10
STEP 11
STEP 12 
STEP 13

STEP 14
STEP 15

PCB Layout Transmitter (ROBOT) 18

this is the PCB layout for the transmitter.
PCB 1
PCB 2
PCB 3

PCB Layout controller 17

this is for the PCB layout of the controller

PCB 1
PCB 2

PCB 3

Starting the project. 16

From here on i will start on developing the project. i hope everything will go well as planned. lets hope for the best and see what we have in the end of the project.

Interfacing GP2D12 with PIC 15


The GP2D12 is an analog infrared proximity sensor. It can be used to detect obstacles. This sensor has a LED that emits infrared light. Infrared light has the interesting property that it bounces on obstacles. On the front of the sensor, beside the LED that emits the infrareds, there is a photodiode that is sensible to infrared light. It will vary the output voltage based on the amount of infrared light that bounces back to the sensor. Roughly speaking, the more infrared light it sees, the closer is the object and the higher the output voltage generated by the photodiode.

If the voltage output is connected to a microcontroller with analog to digital conversion capability (such as a PIC16F877 microcontroller), it is possible to translate this voltage to a numerical value. This value can be used to determine whether or not there are obstacles close to the sensor and how far these obstacles are.

The GP2D12 circuit shows how to interface a PIC16F877 microcontroller to a Sharp GP2D12 sensor.

Note that in this example, it is assumed that the sensor is tucked in ten centimeters within the robot. This is necessary because the voltage output curve climbs for the first ten centimeters and then drops (see chart below), which means that there is a range of voltage values that account for two different distances. By placing the sensor inside the robot, we avoid this ambiguity in sensor reading.

Analog Output Voltage vs Detection Distance

The GP2D12 outputs a non-linear analog voltage corresponding to the distance of the reflective object. The sensor can measure in the range from 10-80 cm. The voltage is approximately 2.4V at 10cm and at 0.52 at 60cm. The sensor draws about 34mA. The maximum is stated to be 50mA.

Sharp GP2D12 14

Sharp GP2D12
.With the introduction of the GP2D12 line of Sharp detectors, a new approach was developed that not only gives object detection at a longer range than the previous method, but also offers range information.This new rangers offer much better immunity to ambient lighting conditions because of the new method of ranging.

This sensor use triangulation and a small linear CCD array to compute the distance and/or presence of objects in the field of view.  The basic idea is this: a pulse of IR light is emitted by the emitter.  This light travels out in the field of view and either hits an object or just keeps on going.  In the case of no object, the light is never reflected and the reading shows no object.  If the light reflects off an object, it returns to the detector and creates a triangle between the point of reflection, the emitter, and the detector.


General Description
The Sharp GP2D12 is an analog distance sensor that uses infrared to detect an object between 10 cm
and 80 cm away. The GP2D12 provides a non-linear voltage output in relation to the distance an object
is from the sensor and interfaces easily using any analog to digital converter.
Features
• High immunity to ambient light and color of object
• No external control circuitry required
• Sensor includes convenient mounting holes
• Compatible with all BASIC Stamp® and SX microcontrollers.



The Motor Drivers (L293D) 13

The Motor Drivers
Motor are high-powered devices in the world of digital electronics. A typical digital output can supply about 10 to 20 mA of current. A small magnet motor requires anywhere from 500 to 4000 mA of current. Special circuits are therefore required to drive motors

The H-Bridge Circuit.
H-bridge Circuit
A circuit known as the H-bridge (named for its topological similarity to the letter H) is commonly used to drive motors. in this circuit ( shown above), two of four transistors are selectively enabled to control current flow through a motor.

The H-bridge with left to right current flow
as shown above, an opposite pair of transistors( Transistor One and transistor three) is enabled, allowing current to flow through the motor. The other pair is disabled, and can be thought of as out of the circuit. by determining which pair of transistors is enabled, current can be made to flow in either of the two directions through the motor. Because permanent magnet motors reverse their direction of turn when the current flow is reversed, this circuit allows bidirectional control of the motor.

L293D
The L293D is a dual h-bridge driver IC. The IC is also referred to as a push-pull four channel driver. An h-bridge is ideal for driving motors. The L293D provides two h-bridges for driving both motors on the robot base. The motor direction is controlled by logic signals from the microcontroller. Two signals per motor are required to control the direction.


















Tamiya Geared Motor 12




The Tamiya double gearbox is a compact unit with two independent motors and gear trains. The kit includes two motors and all gears and parts to build any of the four possible gear ratio configurations (12.7:1, 38:1, 115:1, and 344:1). Although it is not typical, it is possible to assemble each side with different gear ratios. There are two possible output axle locations (for any given gear ratio, only one output location is possible).

Independently Adjust Left/Right Gear Ratios

This innovative gearbox will allow you to separately control the output of two motors. Both the left and right motors have 4 gear ratios to choose from, allowing precision control.


Complementary products
The output shafts included in this kit are 3 mm hexagonal axles that are 10 cm (about four inches) from tip to tip. The axles work with any of the Tamiya wheels we carry, giving you many options for your robot speed. The two low-voltage motors run on 3-6 volts and draw up to a few amps, making them perfect candidates for the Pololu low-voltage dual serial motor controller. Motor overheating can be caused by excessive stalling, even at very low voltages. We recommend that you use stall-detection sensors, or just watch your robot, to make sure that it doesn’t stall for more than a few seconds at a time.

Comparison to the Tamiya double gearbox





Tamiya 70168 Double Gearbox (left) and Tamiya 70097 Twin-Motor Gearbox (right)
The twin-motor gearbox is very similar to the Tamiya 70168 double gearbox, as shown in the picture to the right. The gear ratio options of the two products complement each other well, but the mounting holes and overall dimensions vary slightly. The double gearbox is shorter and wider than the twin-motor gearbox, and the gears are a bit smaller and wider.

listing down 91

After all of the block diagram and flowchart is finish, it is time to start understand about each of the component which are being use in the project. Here is the list of the important parts in the robot :

  1. Controller ( Transmitter)
    • Infrared Transmitter
    • PIC 16F877A
    • Voltage Regulator
  2. Robot ( Receiver)
    • Infrared Receiver
    • PIC16f877A
    • Voltage Regulator
    • Motor driver (L293D)
    • Motor
    • Distance sensor (GP2D12)
I will be explaining on this next week. i have assignment which are need to be done!!

Voltage Regulator (LM7805) 11


The voltage regulator module is used to protect PIC and other connected sensors / actuators from over voltage. This is because PIC and all other connected sensors, actuators all support 5V DC only. Over voltage will cause any of the module burn.
LM7805
LM7805 is used to regulate voltage in the system and output 5V DC (max output current: 1000mA). It supports input voltage from 7V DC to 18V DC. If the input voltage is over, the LM7805 will burn or auto shutdown due to overheat.
The generated 5V from LM7805 will be noise filtered by 0.1uF ceramic capacitor and a 1000uF electrolytic capacitor. This is to avoid high frequency oscillation on the outputs which may cause system hang or unstable.

A diode is connected at the input of the LM7805. This is to avoid voltage connected reversely. An on/off switch is used to turn on/off the system and a LED (5V, 5mA) is used to indicate the system is power on/off. The LED is connected through 1KR resistor to limit current pass through LED is 5mA. 

Advantages
The 7805 series has several key advantage over many other voltage regulator circuits which have resules in it's popularity:
  • 7805 series IC do not require any additional components to provide a constant, regulated source of power, making them easy to use, as well as economical, and also efficient uses of circuit board real estate. By contrast, most other voltage regulators require several additional components to set the output voltage level, or to assist in the regulation process. Some other designs (such as a switching power supply) can require not only a large number of components but also substantial engineering expertise to implement correctly as well.
  • 78xx series IC have built-in protection against a circuit drawing too much power. They also have protection against overheating and short circuits, making them quite robust in most applications. in some cases, the current-limiting features of the 78xx devices can provide protection not only for the 78xx itself but also for other parts of teh circuit is is used in. precenting other components from being damaged as well.
Disadvantages
  • The input voltage must always be higher than the output voltage by some minimum amount (typically 2 volts). This can make these devices unsuitable for powering some devices from certain types of power sources (for example, powering a circuit which requires 5 volts using 6-volt batteries will not work using a 7805).
  • as they are based on a linear regulation design, the input current required is always the same as the output current. as the input voltage must always be higher than the output voltage. means that the total power(voltage multiplied by current) going into the 78xx will be more than the output power provided. The extra input power is dissipated as heat. this means both that for some application an adequate heat-sink must be provided, and also that a (often substantial) portion of the input power is wasted during the process, rendering them less efficient than some other types of power supplies. when the input voltage is significantly higher than the regulated output voltage (for example, powering a 7805 using 24 volt power source), this inefficiency can be significant issue.


PIC16F877A 10..

The PIC16F877A micro controller is used to control the whole system. It is designed using flash technology. So the PIC can read/write program for more than 100,00 times. The PIC16F877A has 8K words or program memory. Since each word in the mid range family is 14 bits long the program memory can also be expressed as 14K bytes. The unit has 368 bytes of data ram and 256 bytes of EEPROM. It has 8 channels of A/D with 10 bit resolution. The unit has 2 8bit Timer?Counters and a single 16 bit Timer/Counter. in addition to this, it has several different types of serial communication functions such as SPI, 12C, and normal PC type serial communication functions.



PIC16F877A port.
OSC1 and OSC2 pins are connected to 20MHZ crystal to execute every single program line in the system. 20MHz crystal is used because this is the maximum frequency that the PIC can support. If over frequency the PIC will burn. Else if crystal speed is less than 20MHz the the PIC response speed will slower. The MCLR pin of the PIC is pull up to 5V through a 10KR resistor. The PIC can operate using 4.5V to 6.0V DC voltage. In the project is operating at 5.0V (by using 7805). It is DIP layout (dual in line package) and suitable for student project. It has 40 pins but only 33 I/O pins can be set as digital input or digital output. The digital output of the PIC is 5V (for signal) and 0V (for signal 0) these signals will be directly connected to actuators for control purpose. When the PIC pin is set as digital input. it will detect input voltage 5V as signal 1 and 0V as signal 0. Any voltage less than 0V or more than 5V will damage PIC.
























Infarred Sensor 92

as stated before, i will be explaining on the Infrared Transmitter and Receiver. Please take note that in the previous post the reader will notice that i separate the transmitter and the receiver. Here, i will be explaining on it together since both of the transmitter and receiver came together.


An infrared sensor in its simplest form is a sensor capable of detecting an object adjacent surface, such as difference in color or roughness properties. Using simple optoelectronics, such as infrared photo-transistors, object can easily be detected. 

Infrared sensor.
Above show the picture of infrared sensor. The infrared emitter and detector can be arranged face to face or side by side to detect object. The infrared emitter output beam is around 1100nm, and infrared detector only receive infrared beam. Thus infrared sensor is not easily affected by environment brightness. Infrared emitter/detectors or photo-transistors are inexpensive and reliable way to detect object.
In this project the sensor will be separated from each other. The detector or receiver will follow the emitter where it goes. That is all for the explanation of the Infrared sensor. about the connection i will be explaining it during i assembled all of the component. 








Flowchart 8

From here i will start to explain on how the robot function. This robot is actually contains of 2 parts, which are the controller and the receiver. This robot will follow the controller which is the target which are being sent. below is the flowchart of the controller.


Infrared Transmitter Flowchart (controller)

After finishing the flowchart on the controller, next is the robot which is also the receiver. sorry for the picture since the robot flowchart is a little bit long i'll be dividing it into 2 parts.

 
Top part of the flowchart for receiver or the robot
bottom part of the flowchart for the receiver or the robot