Tuesday 23 July 2013

ABSTRACT
                                                                                                                                               
   A robot is a machine designed to execute one or more tasks repeatedly, with speed and precision. There are as many different types of robots as there are tasks for them to perform. A robot can be controlled by a human operator, sometimes from a great distance. In such type of applications wireless communication is more important.

The basic idea behind the project is to develop an artificial intelligence to the machines we use in our daily life. It has been always a desire for human beings to   impart artificial intelligence. In the process of it we started training our robot to differentiate colours present the nature.
OUTPUT VIDEO

In the final stages we shall try to explore new ways of image processing techniques to develop the robot for real time purpose. Its always better to design something which can work in indoors and detect different symbols like left arrow, right arrow, up arrow, down arrow.

To impart these ideas we like to MATLAB as our image processing tool, to compute various parameters of the surroundings.

The data is send through the laptop by using two ways. They are by using doclite software or by using Matlab software. In doclite software we can send the ASCII values directly and control the robot by giving the baud rate and com port. The second way is by using Matlab  program so that we can control the robot by pressing different keys A, S, W, D, X or a, s, w, d, x. We can control the robot by using these 2 ways.
 It captures the video by using two ways. They are by using wireless video transmission or by using IP web cam app in android mobile phone. In wireless video transmission we require wireless camera, RF video modulator, and a tuner card. The second one is by using IP web cam app in android mobile phone. Application is turned on and writes the IP address given in that application. IP address is opened in browser and adds video in that laptop. It captures the video in the laptop where the robot is moving.
             

  

1. INTRODUCTION




Robotics is a growing field. This has caused many universities to offer classes and programs in the field of robotics that combine elements of electrical engineering, mechanical engineering and computer science. Additionally, project-based learning is an important part of learning an engineering discipline.


For that reason, many of these schools use educational robots as
experimental platforms. These robots are built to perform basic functions such as line following and obstacle avoidance. Students can then program them to perform tasks such as collecting small balls or travelling from one area to another. The concepts behind a robot that carries radioactive fuel rods and one that carries red Ping-Pong balls are very similar.


Although the control part of different robots might be different, the vision part and decision-making part could be compatible with any other kind of robot. We endeavor to develop a program with universality which could be taken advantage by different robots. Build a robot that can use this program to avoid different types of obstacles. The different types of obstacles include chairs, desks, bottles, walls etc. Despite their different appearances, the principles of their detection with stereo vision are the same.
TECHNICAL SPECIFICATIONS
The technical specifications include hardware and software require for designing a robot.
2. HARDWARE REQUIRED
  RS 232
  MAX 232
  Microcontroller ATMEGA16
  Motor driver(L293d)
  DC motor
  Voltage regulator(LM7805)
  Two main wheels, two support wheel
  Vehicle base
  Capacitors




 SOFTWARE REQUIRED

Software specifications: Codevision AVR software
The Codevision AVR software is used to convert the code into the hex file in order to dump the code into the microcontroller. The converted file is thus successfully loaded in the microcontroller and the desired results are checked by interfacing it to other components embedded in the circuit.









3. COMPONENTS
RS 232
           Interface between data terminal equipment and data communications equipment using serial binary data exchange. In RS-232, user data is sent as a time-series of bits. Both synchronous and asynchronous transmissions are supported by the standard. In addition to the data circuits, the standard defines a number of control circuits used to manage the connection between the DTE and DCE. Each data or control circuit only operates in one direction, that is, signaling from a DTE to the attached DCE or the reverse. Since transmit data and receive data are separate circuits, the interface can operate in a full duplex manner, supporting concurrent data flow in both directions. The standard does not define character framing within the data stream, or character encoding.
        The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to RS232 level to TTL levels. When a MAX232 IC receives a TTL level to convert, it changes a TTL Logic 0 to between +3 and +15 V, and changes TTL Logic 1 to between -3 to -15 V, and vice versa for converting from RS232 to TTL. This can be confusing when you realize that the RS232 Data Transmission voltages at a certain logic state are opposite from the RS232 Control Line voltages at the same logic state.
ATMEGA16 MICROCONTROLLER

FEATURES
• High-performance, Low-power Atmel® AVR® 8-bit Microcontroller
• Advanced RISC Architecture
– 131 Powerful Instructions – Most Single-clock Cycle Execution
– 32 x 8 General Purpose Working Registers
– Fully Static Operation
– Up to 16 MIPS Throughput at 16 MHz
– On-chip 2-cycle Multiplier
• High Endurance Non-volatile Memory segments
– 16 Kbytes of In-System Self-programmable Flash program memory
– 512 Bytes EEPROM
– 1 Kbyte Internal SRAM
– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
– Data retention: 20 years at 85°C/100 years at 25°C (1)
– Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
– Programming Lock for Software Security
• JTAG (IEEE std. 1149.1 Compliant) Interface
– Boundary-scan Capabilities According to the JTAG Standard
– Extensive On-chip Debug Support
– Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
• Peripheral Features
– Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode
– Real Time Counter with Separate Oscillator
– Four PWM Channels
– 8-channel, 10-bit ADC
• Special Microcontroller Features
– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated RC Oscillator
– External and Internal Interrupt Sources
– Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby and Extended Standby
• I/O and Packages
– 32 Programmable I/O Lines
– 40-pin PDIP, 44-lead TQFP, and 44-pad QFN/MLF
• Operating Voltages
– 2.7V - 5.5V for ATmega16L
– 4.5V - 5.5V for ATmega16
• Speed Grades
– 0 - 8 MHz for ATmega16L
– 0 - 16 MHz for ATmega16

USB to TTL converter

            It is used to convert the ASCII values voltages from pc i.e. 3v to 25v to TTL compatible voltages i.e. 0v or 5v and the output of this converter is directly given to transmitting module(TWS-434 A transmitter)


USB to Serial TTL Converter






 MOTOR DRIVER (L293D)

The Device is a monolithic integrated high voltage, high current four channel driver designed to accept standard DTL or TTL logic levels and drive inductive loads (such as relays solenoids, DC and stepping motors) and switching power transistors. To simplify use as two bridges each pair of channels is equipped with an enable input. A separate supply input is provided for the logic, allowing operation at a lower voltage and internal clamp diodes are included.

The L293D is a quadruple half H-bridge bidirectional motor driver IC that can drive current of up to 600mA with voltage range of 4.5 to 36 volts. It is suitable to drive small DC-Geared motors, bipolar stepper motor etc.

TRUTH TABLE:
                       A
                         B
    
           
  DECRIPTION
0
0
Motor Stops or Breaks
0
1
Motor Runs Anti-Clockwise
1
0
Motor Runs Clockwise
1
1
Motor Stops or Breaks

Pin Diagram



Pin Description
 Pin No
 Function
 Name
1
Enable pin for Motor 1; active high
Enable 1,2
2
Input 1 for Motor 1
Input 1
3
Output 1 for Motor 1
Output 1
4
Ground (0V)
Ground
5
Ground (0V)
Ground
6
Output 2 for Motor 1
Output 2
7
Input 2 for Motor 1
Input 2
8
Supply voltage for Motors; 9-12V (up to 36V)
 Vcc 2
9
Enable pin for Motor 2; active high
Enable 3,4
10
Input 1 for Motor 1
Input 3
11
Output 1 for Motor 1
Output 3
12
Ground (0V)
Ground
13
Ground (0V)
Ground
14
Output 2 for Motor 1
Output 4
15
Input2 for Motor 1
Input 4
16
Supply voltage; 5V (up to 36V)
Vcc 1


Specifications
·         Supply Voltage Range 4.5V to 36V
·         600-mA Output current capability per driver
·         Separate Input-logic supply
·         It can drive small DC-geared motors, bipolar stepper motor.
·         Pulsed Current 1.2-A Per Driver
·         Thermal Shutdown
·         Internal ESD Protection
·         High-Noise-Immunity Input

 DC GEARED MOTOR


·         12V DC SUPPLY
·         1000 rpm
·         50mA


 VOLTAGE REGULATOR(LM7805)
The LM78M05 , a three-terminal positive voltage regulators employ built-in current limiting, thermal shutdown, and safe-operating area protection which makes them virtually immune to damage from output overloads.
With adequate heat sinking, they can deliver in excess of 0.5A output current. Typical applications would include local (on-card) regulators which can eliminate the noise and degraded performance associated with single-point regulation.
Output current in excess of 0.5A
No external components
Internal thermal overload protection
Output voltages of 5V

 OTHER COMPONENTS
CAPACITORS
·         10 µF
·         1 µF
IC BASE
·         28 pin
·         16 pin
BUG STRIP
      Used for placing the 7805 voltage regulator.This avoids heat from the soldering rod to reach the IC.
WIRE CONNECTORS
These connectors are used to connect wires through the Vero board through which input, power supply or outputs are taken out through the board.
ROBOTIC WHEEL
Two types of wheel have been used:
·         Main wheel(Front)
·         Support wheel(Rear)


ROBOTIC BASE
It is made up of light weight material aluminum which provides easy movement of the robotic vehicle. It has following provision s in it:
·         Slot for DC motors.
·         Rear support wheel.
·         Slot to clamp sensors.
9V battery holder.
4.BLOCK DIAGRAM

5.CIRCUIT DIAGRAM






6.CODE DESCRIPTION
Microcontroller code:
#define F_CPU 16000000UL //Set the frequency of the microcontroller to 16 mhz. If the frequency is different, the corresponding value should be set
#include <avr/io.h>
#include <util/delay.h>
#define USART_BAUDRATE 9600 //Rate of data transfer
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)

void main() {
            DDRB = 0xff;
            char data;

            UCSRB |= (1 << RXEN) | (1 << TXEN);   // Turn on the transmission and reception circuitry
            UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1); // Use 8-bit character sizes

            UBRRL = BAUD_PRESCALE; // Load lower 8-bits of the baud rate value into the low byte of the UBRR register
            UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value into the high byte of the UBRR register

            for (;;) { // Loop forever

            while ((UCSRA & (1 << RXC)) == 0) {}; // Do nothing until data have been received and is ready to be read from UDR
             
            data = UDR; // Fetch the received byte value into the variable "ByteReceived"
             
            if(data=='w')//forward condition
              PORTB=0b00000101; // Both wheels rotate in forward direction and bot is moved forward  
             
              else if(data=='s')//Backward condition
              PORTB=0b00001010;
             
              else if(data=='a')//Left condition
              PORTB=0b00001001;
             
              else if(data=='d')//Right condition
              PORTB=0b00000110;
             
              else//Default condition
              PORTB=0b00001111;
   }
}


Matlabcode:
Initialise serial port with the following commands
C=serial(‘com38’);
fopen(‘c’);
Main Programme:
clc;
fprintf(c,'k');
url = 'http://192.168.43.1:8080/shot.jpg';
pause(1);
while(1);
    i=imread(url);
    i1=rgb2hsv(i);
    [len wid ~]=size(i1);
    h=i1(:,:,1);
    s=i1(:,:,2);
    v=i1(:,:,3);
    b=im2bw(v,graythresh(v));
    imshow(b);
    z=arrow(b);
    if z==1
        fprintf('\n\tTurn Left');
        fprintf(c,'k');
        pause(0.5);
         fprintf(c,'i');
         pause(2);
         fprintf(c,'w');
    elseif z==2
        fprintf('\n\tTurn Right');
         fprintf(c,'k');
        pause(0.5);
         fprintf(c,'s');
         pause(2);
         fprintf(c,'w');
     elseif z==3;
        fprintf('\n\tForward');
        fprintf(c,'k');
        pause(0.5);
        fprintf(c,'w');
         pause(0.5);
        fprintf(c,'k');
    elseif z==4;
        fprintf('\n\tBackward');
        fprintf(c,'d');
        pause(6);
        fprintf(c,'k');
    end
    pause(0.5);
end
arrow.m
%arrow.m
function a=arrow(c)
o=regionprops(c,'Extrema','Centroid','Orientation');
m=o.Orientation;
i1=o.Centroid;
o=o.Extrema;
%left and right arrow
if abs(m)<10
    if sqrt((o(7,1)-i1(1,1))^2+(o(7,2)-i1(1,2))^2)<sqrt((o(3,1)-i1(1,1))^2+(o(3,2)-i1(1,2))^2)       
        a=1;
    else
        a=2;
    end
else
    if sqrt((o(1,1)-i1(1,1))^2+(o(1,2)-i1(1,2))^2)<sqrt((o(5,1)-i1(1,1))^2+(o(5,2)-i1(1,2))^2)
        a=3;
    else
        a=4;
    end
end

FURTHER DEVELOPED CODES:

   %firoz.m
   function y=firoz(s1,l)
[len wid]=size(s1);
l=round(l);
for i=(l-3):len
    for j=1:wid
        s1(i,j)=0;
    end
end
% figure;
% imshow(i1);
  i1=im2bw(s1);
i1=bwareaopen(i1,900);
cc = bwconncomp(i1,8);
if(cc.NumObjects==0)
    y=4;
else
i3=false(cc.ImageSize);
i3(cc.PixelIdxList{1}) = true;
[~, wid ,~]=size(s1);
 xc=wid/2;
d4=regionprops(i3,'BoundingBox');
d4=d4.BoundingBox;
xc1=d4(1)+d4(3)/2;
z=xc-xc1;
if z>10
    y=2;
    fprintf('\n go left');
elseif z<-10
    y=1;
    fprintf('\n go right');
else
    y=0;
end
end
   end

INDOOR MOVEMENTS:
clc;
% vid=videoinput('winvideo',2);
while(1)
v3=0;
n=0;
e=0;
p=0;
x=90;
s=0;
n=0;
y=90;
z=90;
a=1;
b=1;
d=0;
 url = 'http://192.168.43.1:8080/shot.jpg';
 s1=imread(url);
%   s1=imread('stop_sign.jpg');
%   s1=getsnapshot(vid);
 
i1=rgb2hsv(s1);
s2=i1;
h=i1(:,:,1);
s1=i1(:,:,2);
v1=i1(:,:,3);
[len wid]=size(h);
for i=1:len
     for j=1:wid
%       if((v1(i,j) >=0.5)&&s1(i,j) <=0.15)
%              h(i,j)=0;
%              s1(i,j)=0;
%              v1(i,j)=1;
%       end
%       if(v1(i,j) >=0.3 && s1(i,j)>=0.5&&h(i,j)>0.7)
%        h(i,j) = 0.85;
%        s1(i,j) = 0.99;
%        v1(i,j) = 0.8;
%       end
%   if(v1(i,j)<0.1)
%       h(i,j)=0;
%       s1(i,j)=0;
%       v1(i,j)=0;
%   end
%   if(v1(i,j) >=0.25 && v1(i,j) <=0.5&&h(i,j)>0.25&&h(i,j)<0.4)
  if(h(i,j)>=0.35)&&(h(i,j)<=0.49)
      h(i,j) = 0.384;
      s1(i,j) = 0.99;
      v1(i,j) = 0.694;
  end

    
     end
end
i1(:,:,1)=h;
i1(:,:,2)=s1;
i1(:,:,3)=v1;
for i=1:len
     for j=1:wid
         if(h(i,j) >=0.85 && h(i,j) <= 1)
             v3=v3+1;
         elseif(h(i,j)>=0.293 && h(i,j) <=0.399)
             n=n+1;
            
         end
     end
end
p=im2bw(i1);
p=bwareaopen(p,300);
ar=regionprops(p,'Area');
ar=ar.Area;
ar1=len*wid;
na=ar/ar1;
a=1;
b=1;
[len wid]=size(h);

%    if(v3>1000)
%       s=1;fprintf('\nred');
%   elseif(n>1000)
%       s=2;fprintf('\ngreen');
%    end
s=2;
h=p(:,:,1);
s6=p(:,:,1);
v=p(:,:,1);
for i = 1:len
    for j= 1:wid
     if( h(i,j) == 1&&s6(i,j) == 1&&v(i,j) == 1)
      d(a)=i;
      m(b)=j;
      a=a+1;
      b=b+1;
     end

     end
end
o1=i1(:,:,3);
d=min(d)/2;
for i=1:(d)
    for j=1:wid
        i1(i,j,3)=0;
    end
end
v=i1(:,:,3);

imshow(v);
i2=im2bw(v,0.25);
imshow(i2);
i2=bwareaopen(i2,900);
imshow(i2);
cc = bwconncomp(i2,8);
i3= false(size(i2));
i3(cc.PixelIdxList{1}) = true;
e=regionprops(i3,'Extrema');
l=e.Extrema(1,2);
dis=len-l;
% imshow(i3);
i4=edge(i3);
% se= strel('rectangle',[1 15]);
%  i4=imdilate(i4,se);
% se= strel('rectangle', [1 15]);
%  i4=imerode(i4,se);
%  imshow(i4)
  if(na>=0.055)
         %[x d]= travel(s2,l);
          %if(x==0)
           fprintf('\nstop');
           pause(0.25);
           fprintf(c,'w');
           k=symb1(o1,l);
       
         switch k
             case 0
                 fprintf('\nDead end');
                 fprintf(c,'O');
                 pause(1);
                 fprintf(c,'I');
                 pause(2.3);
                 fprintf(c,'K');
                 continue
             case 1
                 fprintf(c,'L');
                 pause(0.5);
                 fprintf('\nStop');
                 fprintf(c,'K');
                 break;
             case 2
                 if s==1
                     fprintf('\nDont go left');
                     fprintf(c,'k');
                     pause(2);
                     fprintf(c,'d');
                     pause(1.2);
                     fprintf(c,'w');
                 
                     continue
                 elseif s==2
                     fprintf('\nGo left');
                     fprintf(c,'k');
                     pause(2);
                     fprintf(c,'i');
                     pause(1.2);
                     fprintf(c,'w');
%                      fprintf(c,'O');
%                      pause(0.25);
%                      fprintf(c,'K');
                     continue
                 end
             case 3
                 if s==1
                     fprintf('\nDont go right');
                     fprintf(c,'k');
                     pause(2);
                     fprintf(c,'i');
                     pause(1.2);
                     fprintf(c,'w');
                     continue
                 elseif s==2
                     fprintf('\nGo right');
                     fprintf(c,'k');
                     pause(2);
                     fprintf(c,'d');
                     pause(1.2);
                     fprintf(c,'w');
%                      fprintf(c,'O');
%                      pause(0.25);
%                      fprintf(c,'K');
                     continue
                 end
             otherwise
                 continue
         end
%          elseif(x==1)
%              fprintf('\ngo straight');
%             fprintf(c,'L');
%             pause(0.25);
%          fprintf(c,'K');
%          pause(0.25);
%          fprintf(c,'A');
%          pause(0.25);
%          fprintf(c,'K');
         
  else
        y=firoz(v,l);
  end
    
     if(y==0)
         fprintf('\ngo straight')
   fprintf(c,'k');
            pause(0.5);
         fprintf(c,'w');
%          pause(0.25);
%          fprintf(c,'A');
%          pause(0.25);
%          fprintf(c,'K');
     elseif(y==2)
            fprintf('\nturn right')
            fprintf(c,'s');
            pause(0.1);
         fprintf(c,'w');
%          pause(0.25);
%          fprintf(c,'A');
%          pause(0.25);
%          fprintf(c,'K');
     elseif(y==1)
                fprintf('\nturnleft')
                fprintf(c,'i');
                pause(0.1);
         fprintf(c,'w');
%          pause(0.25);
%          fprintf(c,'W');
%          pause(0.25);
%          fprintf(c,'K');
     elseif(y==4)
%          fprintf(c,'O');
         pause(0.5)
%          fprintf(c,'K');
      elseif(y==3)
                continue;
     end
  end  


7. WORKING
·         The sensors (camera)  which are kept at the front part of the robot detects the symbol.
·         A signal will be given to the microcontroller whenever an symbol is detected through matlab.
·         Microcontroller is programmed in such a way that it interfaces with the motor driver IC
·         Motor driver IC will drive the robot  backwards and moves left or right based on the program.
8.PROBLEMS ENCOUNTERED
            Although the concept & design of the project seemed perfect, there were some problems faced while actual implementation:
1. DAMAGE OF ONE WHEEL DRIVING DC MOTOR
During the initial operation of the robot it was found that one of the DC motor was not running in reverse direction. The motor was checked by opening its outer case and it was found that geared part of the motor is damaged.
2. ALIGNMENT OF WHEELS
Solution:
Many methods were tried to correct the defect but success was not achieved. Finally a new DC motor was purchased and employed in the project.
9. APPLICATIONS
      Surveillance robots
      Fire extinguishing
      Security
      Industrial applications
10. SCOPE OF THE PROJECT
    SCIENTIFIC
Remote control vehicles have various scientific uses including hazardous environments, working in the deep ocean, and space exploration. The majority of the probes to the other planets in our solar system have been remote control vehicles, although some of the more recent ones were partially autonomous. The sophistication of these devices has fuelled greater debate on the need for manned spaceflight and exploration. The Voyager I spacecraft is the first craft of any kind to leave the solar system. The Martian explorers Spirit and Opportunity have provided continuous data about the surface of Mars since
January 3, 2004.
MILITARY AND SECURITY APPLICATIONS
      Military usage of remotely controlled military vehicles dates back to the first           half of 20th century. Soviet Red Army used remotely controlled Tele tanks during 1930s in the Winter War and early stage of World War II. There were also remotely controlled cutters and experimental remotely controlled planes in the Red Army. Remote control vehicles are used in law enforcement and military engagements for some of the same reasons. Remote controlled vehicles are used by many police department bomb-squads to defuse or detonate explosives. See Dragon Runner, Military robot. Unmanned Aerial Vehicles (UAVs) have undergone a dramatic evolution in capability in the past decade. Early UAV's were capable of reconnaissance missions alone and then only with a limited range. Current UAV's can hover around possible targets until they are positively identified before releasing their payload of weaponry. Backpack sized UAV's will provide ground troops with over the horizon surveillance capabilities.
SEARCH AND RESCUE
UAVs will likely play an increased role in search and rescue in the United States. Slowly other European countries (even some developing nations) are thinking about making use of these vehicles in case of natural calamities &emergencies. This can be a great asset to save lives of both people along with soldiers in case of terrorist attacks like the one happened in 26 Nov, 2008 in Mumbai, India. The loss of military personnel can be largely reduced by using these advanced methods. This was demonstrated by the successful use of UAVs during the 2008 hurricanes that struck Louisiana and Texas.