Saturday, August 24, 2013

Motion Control of Robotic Arm Using Color Sensor - Engineering Project (Program Code Included)



The objective of this project is to make robots follow human gestures i.e. robot follows the actions that humans do. This imitation done by robots can be used in various fields. For  example in industries we can instruct the remote robotic hand to pick and place a ready job from one place to another, by moving our hands  appropriately in the control room. In this project a robotic hand imitates the motion by sensing the colors on the fingers of the human hand. To make the robot understand what to sense from the surrounding various sensors are available. The sensors’ output is then properly processed, conditioned and then given to the microcontroller. The Hand is an advanced robot hand system that reproduces all the movements of the human hand and provides comparable force output and sensitivity. This means it can pick up or handle small to medium sized objects and perform precision tasks, so robots using it can have the versatility of humans.
TELEPRESENCE OPERATIONS
A remote system using the Hand technology will allow an operator to work in an inaccessible area. This could be a harmful environment where radiation, toxic chemicals or biological hazards are present. The Hand can also allow specialists to be present, whenever needed, anywhere across the world, even in places where humans cannot reach. This way machine repair could be done for example on drilling platforms, inside wind turbines etc. medical examination, education and training by experts could be done on long distance.
PICK AND PLACE ROBOTS
Pick and place robots are among the most popular material handling systems. They provide dependable solutions for production lines. Pick and place robot work cells perform tedious, repetitive tasks with ease, speed and accuracy.
ARTIFICIAL INTELLIGENCE
Robots can be taught the things and the work that we want them to perform. Robots follow the motions that we do in front of them, which in turn can be retrieved from their stored memory whenever and wherever necessary.
The basic principle employed in the project is to sense the light of different intensities from the hand by the sensing screen. The output of the sensor is then properly conditioned, processed and then given to microcontroller. The microcontroller then processes the input received from the sensors. It then moves the fingers of robot according to the operator’s hand movement, following some coding instructions written in it. Light is nothing but an electromagnetic wave. The visible light spectrum is the section of the electromagnetic radiation spectrum that is visible to the human eye. It ranges in wavelength from approximately 400 nm (4 x 10-7 m) to 700 nm (7 x 10-7 m). It is also known as the optical spectrum of light. The different color sensing by the sensors forms the basis of this project.
ELECTRICAL SPECIFICATIONS
IC LM324AmM, Sensor circuit and H Bridge need 12v for their operation
H-bridge needs 5V for enabling the drivers
Atmega32 works on 5V.

The system can be divided into five major blocks
The sensor LDR senses the light. The output of sensor circuit is then given to comparator to get the logical output that is 1 or 0 corresponding to light availability. This logical yes or no is then given to microcontroller’s input port. It analyses the data available at the input port and accordingly drives motor through motor driver circuit H-bridge.
LDR SENSOR
LDRs or Light Dependent Resistors are very useful especially in light/dark sensor circuits. Normally the resistance of an LDR is very high, sometimes as high as 1000 000 ohms, but when they are illuminated with light resistance drops dramatically. LDR has very high resistance when placed in dark ( or when no light falls on it). The resistance is of the order of Mega ohms. As soon as light falls on it its resistance decreases to a few kilo ohms. In the circuit LDR is kept in a voltage divider circuit along with a LED of appropriate color besides it for the illumination. Each led is used to illuminate the color strip on the operator’s fingers so that the light falling on the finger gets reflected back towards the LDR. The LDR resistance decreases as soon as it senses the reflected light. As LDR resistance decreases, the effective resistance of the voltage divider circuit changes and thus the output voltage changes.
SIGNAL CONDITIONING
The output of the LDR circuit is then given for proper signal conditioning before giving it to microcontroller. The signal conditioning circuit comprises of Comparator and Zener diode as voltage regulator. The comparator compares the output of the sensor circuit with a fixed voltage. The output from the sensor is given to the inverting terminal of comparator. And the non inverting terminal is fed from a variable DC voltage. It is kept variable because of the ability of LDR to respond to different light intensities, by giving different output voltages.
Let us assume that the potentiometer is adjusted for red light detection. The comparator works as follows in this case
Low output when no light is detected
High output when light is detected
That is as soon as we operator brings his finger in front of the sensor circuit, light gets reflected from the finger, sensed by the sensor, and thus a output is given by the sensor. The comparator used in this project is LM324am; it is basically a quad amplifier, used as comparator. The output of each comparator is (Vcc – 1.5) V. 
Vcc used in the project is around 11 V.
Therefore 11-1.5=9.5V.
This output voltage is to be given to microcontroller. Input voltage to microcontroller’s input pin cannot withstand such a high voltage. Therefore the output of the comparator is brought down to a voltage of about 5V, which is suitable for microcontroller operation. This step down is done with the help of Zener diode as shown in the figure. Zener diode is working as a voltage regulator. The output across the Zener is given to microcontroller.
 MICROCONTROLER
Till now we have just sensed the presence or absence of light according to the movements of operator’s hand but this sensing is to be converted and utilized in a proper way for the desired movement of robotic hand. This job is to be done by the microcontroller. The microcontroller has four ports. These ports are bit addressable. So outputs from the comparator are given to one of the port. Motors are interfaced with the microcontroller for movement of fingers of robotic arm.
Description of ports used
1.         Port A: INPUT PORT
a.         PINA.0-INPUT FROM THUMB
b.         PINA.1- INPUT FROM INDEX FINGER
c.         PIN A.2- INPUT FROM MIDDLE FINGER
d.         PIN A.3- INPUT FROM RING FINGER
e.         PINA.4- INPUT FROM LITTLE FINGER
2.         PORTB & PORTC: OUTPUT PORT
Microcontroller used is ATMEGA 32.
MOTOR INTERFACING
The output of microcontroller is not able to drive the motor directly. Therefore a motor driver is used in between motors and microcontroller. In theory, there are four switching elements within the bridge. These four elements are often called, high side left, high side right, low side right, and low side left (when traversing in clockwise order). The switches are turned on in pairs, either high left and lower right, or lower left and high right, but never both switches on the same "side" of the bridge. If both switches on one side of a bridge are turned on it creates a short circuit between the battery plus and battery minus terminals. To power the motor, you turn on two switches that are diagonally opposed.

ALGORITHM
1.         Initialize port A as input, Port B and port C as output port.
2.         Initialize one flag for each finger as zero.
3.         Set variables for each finger as a, b, c, d, e.
4.         Check all the input pins
5.         Check status of pin
a.         If high
i.          Turn motor in clock wise direction
ii.          Set status as 0 for that finger
iii.         Give delay of 500ms
b.         Stop the motor
c.         if pin is low
i.          turn motor in anticlockwise direction 
ii.          Set status as 1
iii.         Give delay
iv.        Stop motor
6.         Repeat the procedure for each and every finger.

PROGRAM
#INCLUDE <MEGA32.H>
#INCLUDE <DELAY.H>
// DECLARE YOUR GLOBAL VARIABLES HERE

VOID UP (UNSIGNED INT X, UNSIGNED INT Y)
    {
     X=1;
     Y=0;    
     DELAY_MS (500);
    }   
VOID DOWN (UNSIGNED INT X, UNSIGNED INT Y)
    {
     X=0;
     Y=1;         
     DELAY_MS (500);
    }
VOID MAIN (VOID)
{
UNSIGNED INT A, B, C, D, E, STA=0, STB=0, STC=0, STD=0, STE=0;
PORTA=0X00;
DDRA=0X00;
PORTB=0X00;
DDRB=0XFF;
PORTC=0X00;
DDRC=0XFF;
PORTD=0X00;
DDRD=0X00;
TCCR0=0X00;
TCNT0=0X00;
OCR0=0X00;
TCCR1A=0X00;
TCCR1B=0X00;
TCNT1H=0X00;
TCNT1L=0X00;
ICR1H=0X00;
ICR1L=0X00;
OCR1AH=0X00;
OCR1AL=0X00;
OCR1BH=0X00;
OCR1BL=0X00;
ASSR=0X00;
TCCR2=0X00;
TCNT2=0X00;
OCR2=0X00;
MCUCR=0X00;
MCUCSR=0X00;
TIMSK=0X00;
ACSR=0X80;
SFIOR=0X00;
WHILE (1)
      {
       A=PINA.0;
       B=PINA.1;
       C=PINA.2;
       D=PINA.3;  
       E=PINA.4;
      
       //FINGER NO1
       IF (STA==1 & A==1)
        {
            ;
        }
       IF (STA==0 & A==1)
       {
        UP (PORTB.0, PORTB.1);
        STA=1;
       }
       IF (STA==1 & A==0)
        {
         DOWN (PORTB.0, PORTB.1);
         STA=0;
        }
       IF (STA==0 & A==0)
       {
        ;
       }
                 
       
       //FINGER 2
       IF(STB==1 & B==1)
        {
            ;
        }
       IF (STB==0 & B==1)
       {
        UP (PORTB.2, PORTB.3);
        STB=1;
       }
       IF (STB==1 & B==0)
        {
         DOWN (PORTB.2, PORTB.3);
         STB=0;
        }
       IF (STB==0 & B==0)
       {
        ;
       }
     
     
      //FINGER 3
       IF (STC==1 & C==1)
        {
            ;
        }
       IF (STC==0 & C==1)
       {
        UP(PORTB.4,PORTB.5);
        STC=1;
       }
       IF (STC==1 & C==0)
        {
         DOWN (PORTB.4, PORTB.5);
         STC=0;
        }
       IF (STC==0 & C==0)
       {
        ;
       }
      
      
       //FINGER 4
       IF (STD==1 & D==1)
        {
            ;
        }
       IF (STD==0 & D==1)
       {
        UP (PORTB.6, PORTB.7);
        STD=1;
       }
       IF (STD==1 & D==0)
        {
         DOWN (PORTB.6, PORTB.7);
         STD=0;
        }
       IF (STD==0 & D==0)
       {
        ;
       }
     
     
      //FINGER 5
       IF (STE==1 & E==1)
        {
            ;
        }
       IF (STE==0 & E==1)
       {
        UP (PORTC.0, PORTC.1);
        STE=1;
       }
       IF (STE==1 & E==0)
        {
         DOWN (PORTC.0, PORTC.1);
         STE=0;
        }
       IF (STE==0 & E==0)
       {
        ;
       }

      }
}


0 comments:

Post a Comment