accelerometer(proj report)

Upload: priya-sharma

Post on 10-Oct-2015

39 views

Category:

Documents


1 download

DESCRIPTION

Project report of robot moving according to hand movements using an accelerometer.

TRANSCRIPT

  • 5/20/2018 Accelerometer(PROJ REPORT)

    1/22

    1 | P a g e

    PROJECT OUTLINE

    The main objective is to control the motion of a robot using wristmovements. If we move our arm towards right, then the robot would move towards

    right, if we move our wrist towards left, then the robot would move left, the samecase in moving front or backwards.

    This is done by using an accelerometer. The device consists of a surfacemicro machined capacitive sensing cell (g-cell) and a signal conditioning ASICcontained in a single package. The sensing element is sealed hermetically at thewafer level using a bulk micro machined cap wafer. An accelerometer has fixed andmovable capacitances in it. When shifted from its initial position, the movablecapacitances are displaced which lead to a change in the value of the capacitance.The value of the robot velocity changes in accordance with this changedcapacitance as we move the accelerometer attached to a glove on our hand.

    An Ultrasonic sensor is used for proximity detection. If there is any obstaclewithin 30cm of the robots path, then the motors would stop, halting all movement.A vibrator attached to the users glove would vibrate in this case, thereby telling theuser to move backwards.

    DC motors are used to move the wheels of the robot. A DC motor is amechanically commutatedelectric motor powered fromdirect current (DC). Thestator is stationary in space by definition and therefore so is its current. The currentin the rotor is switched by thecommutator to also be stationary in space. This ishow the relative angle between the stator and rotor magnetic flux is maintainednear 90 degrees, which generates the maximum torque.

    A wired camera is placed on top of the robot which sends live footage back tothe laptop.

    Arduino is used to run the whole project. Arduino is asingle-boardmicrocontroller designed to make the process of using electronicsinmultidisciplinary projects more accessible. The hardware consists of asimpleopen source hardware board designed around an 8-bitAtmelAVR microcontroller, though a new model has been designed around a32-bit AtmelARM. The software consists of a standard programming language

    compiler and aboot loader that executes on themicrocontroller.

    It is also note worthy that we use an external chip (motor driver) to

    drive the DC motors because an arduino board can only supply voltage up to

    5V while the dc motors used in the robot work at 12 V.

    http://en.wikipedia.org/wiki/Electric_motorhttp://en.wikipedia.org/wiki/Direct_currenthttp://en.wikipedia.org/wiki/Commutator_(electric)http://en.wikipedia.org/wiki/Single-board_microcontrollerhttp://en.wikipedia.org/wiki/Single-board_microcontrollerhttp://en.wikipedia.org/wiki/Multidisciplinaryhttp://en.wikipedia.org/wiki/Open_source_hardwarehttp://en.wikipedia.org/wiki/Atmelhttp://en.wikipedia.org/wiki/Atmel_AVRhttp://en.wikipedia.org/wiki/AT91SAMhttp://en.wikipedia.org/wiki/Boot_loaderhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Boot_loaderhttp://en.wikipedia.org/wiki/AT91SAMhttp://en.wikipedia.org/wiki/Atmel_AVRhttp://en.wikipedia.org/wiki/Atmelhttp://en.wikipedia.org/wiki/Open_source_hardwarehttp://en.wikipedia.org/wiki/Multidisciplinaryhttp://en.wikipedia.org/wiki/Single-board_microcontrollerhttp://en.wikipedia.org/wiki/Single-board_microcontrollerhttp://en.wikipedia.org/wiki/Commutator_(electric)http://en.wikipedia.org/wiki/Direct_currenthttp://en.wikipedia.org/wiki/Electric_motor
  • 5/20/2018 Accelerometer(PROJ REPORT)

    2/22

    2 | P a g e

    COMPONENTS REQUIRED

    1 Arduino board 1 Ultrasonic Sensor

    1 serial USB cable 1 mobile vibrator

    1 accelerometer

    Chassis 1 adapter

    2 DC motors Connecting wires

    1 caster wheel

    DESCRIPTION OF COMPONENTS USED

    ARDUINO BOARDArduino is an open-source electronics prototyping platform based on

    flexible, easy-to-use hardware and software. Arduino can sense the

    environment by receiving input from a variety of sensors and can affect itssurroundings by controlling lights, motors, and other actuators. The

    microcontroller on the board is programmed using theArduino programming

    language (based onWiring) and the Arduino development environment

    (based onProcessing). It has an ATmega AT168 microcontroller that has a

    pre-installed bootloader, so one can download code to the board using only a

    USB-serial connection. Arduino projects can be stand-alone or they can

    communicate with software running on a computer.

    http://arduino.cc/en/Reference/HomePagehttp://arduino.cc/en/Reference/HomePagehttp://wiring.org.co/http://www.processing.org/http://www.processing.org/http://wiring.org.co/http://arduino.cc/en/Reference/HomePagehttp://arduino.cc/en/Reference/HomePage
  • 5/20/2018 Accelerometer(PROJ REPORT)

    3/22

    3 | P a g e

    Figure 2(Arduino Board)

    Figure 3(Arduino Board)

  • 5/20/2018 Accelerometer(PROJ REPORT)

    4/22

    4 | P a g e

    1. USB Jack

    2. Power Jack

    3. Voltage Regulator

    4. Digital Input Pins

    5.

    Analog Input Pins6. Power Pins

    7. Reset Button

    USB CABLE

    The Arduino Duemilanove connects to a host PC with a simple USB

    cable. The Duemilanove comes with an FTDI USB-serial converter chip, so

    the device mounts as a "virtual COM" port from the perspective of the host

    PC.

    Figure 4 (USB cable)

    MOTORDRIVER BOARD(L293D)The bot runs on two dc motors these DC motors work on a 12 Volt DC

    supply. The problem here is evident. The Arduino Board has an output signal

    of 5V. So to run the motors a Motor Driver Board is used. This board uses

    the IC L293D.The board is powered by a 12V Adapter which is plugged into

    an electrical output. Using this board the input to the motors is controlled

    through inputs from the arduino which itself is being powered by the Motor

    Driver,by Monitoring the potential difference between the two terminals if

    the motor the board also enable us to vary the speed of the motors and

    hence the bot.

    Therefore the motor Driver is used to operate the motors using an

    arduino without connecting the two, and simultaneously allows us to control

    their speeds.

  • 5/20/2018 Accelerometer(PROJ REPORT)

    5/22

    5 | P a g e

    ULTRASONIC DISTANCE SENSOR

    Figure 5 (Working of Ultrasonic Sensor)

    Figure 7 (Ultrasonic Sensor)

    Figure 8 (Connections of Ultrasonic Sensor to Arduino)

  • 5/20/2018 Accelerometer(PROJ REPORT)

    6/22

    6 | P a g e

    An Ultrasonic sensor has two transducers: an ultrasonic speaker and a

    matching microphone. When triggered by a digital signal, the speaker emits

    a modulated burst (or "ping") of ultrasonic sound. This sound then travels

    through the air; if it hits a nearby object, it is reflected back to the

    microphone. The microphone has a circuit to amplify and detect the reflectedping, and the device signals a digital "true" if it receives the reflected sound.

    By measuring the interval between the transmitted pulse and the

    received signal, the Arduino can determine distance to the object, by using a

    simple formula based on the speed of sound (approximately, one foot or 30

    cm per millisecond).

    MOBILE VIBRATORS

    Figure 10 (Mobile Vibrator)

  • 5/20/2018 Accelerometer(PROJ REPORT)

    7/22

    7 | P a g e

    Figure 11 (Connections of a buzzer/vibrator with Arduino)

    A mobile vibrator is a device used to generate vibrations, generally of

    high frequency such that the user is able to perceive them. Its connections

    to the arduino are identical to that of the buzzer, that is, a vibrator is also

    attached to a digital pin of the arduino.

    ACCELEROMETER

    We are using thepololu 0J2300which is a capacitive type low current

    accelerometer.

    A capacitive accelerometer uses a sensing mechanism, known as a

    capacitive acceleration sensor, to measure both static acceleration and

    dynamic acceleration forces. With consideration to all accelerometers, there

    typically is some sort of electrical circuitry wired to the sensing mechanism

    in order to portray the output, or voltage, of its measurements.

    Static acceleration force is generated by a gravitational pull. When

    measuring static acceleration with a capacitive accelerometer, the

    measurements would portray the angle of tilt at which the device is being

    held or suspended in relation to the Earth's gravitational pull. A common

    capability of many modern cell phones, smart phones and personal digital

  • 5/20/2018 Accelerometer(PROJ REPORT)

    8/22

    8 | P a g e

    assistants (PDAs) is that

    the orientation of the

    screen changes in

    relation to the angle at

    which the device isbeing held.

    Dynamic

    acceleration force is generated by vibrations from movement. Measuring

    vibrations allows a capacitive accelerometer to determine in which direction

    the device is moving and at what speed. Additionally, dynamic acceleration

    can be measured to track the impact that an object encounters.

  • 5/20/2018 Accelerometer(PROJ REPORT)

    9/22

    9 | P a g e

  • 5/20/2018 Accelerometer(PROJ REPORT)

    10/22

    10 | P a g e

    ARDUINO CODE

    #include

    const int ping = 12;

    int vib=13;

    //int buzz=2;

    int lp=4;

    int ln=5;

    int rp=8;

    int rn=9;

    int speedl=255;

    int speedr=255;

    int sensex=A0;

    int sensey=A1;

    int debug =1;

    int handle;

    int c=0;

    double theetax,theetay;

    const double precision = 255;

    double meanx,meany;

    void setup(){

  • 5/20/2018 Accelerometer(PROJ REPORT)

    11/22

    11 | P a g e

    Serial.begin(9600);

    handle=Serial.read();

    pinMode(lp,OUTPUT);

    pinMode(ln,OUTPUT);

    pinMode(rp,OUTPUT);

    pinMode(rn,OUTPUT);

    pinMode(vib,OUTPUT);

    // pinMode(buzz,OUTPUT);

    Serial.begin(9600);

    calib();

    }

    void loop(){

    if(handle !=1)

    {

    int valx = analogRead(sensex);

    int valy = analogRead(sensey);

    speedl = theetax*(meanx - valx);

    speedr = theetay*(meany - valy);

    Serial.print(meanx);

    Serial.print(" ");

    Serial.print(meany);

    Serial.print(" ");

  • 5/20/2018 Accelerometer(PROJ REPORT)

    12/22

    12 | P a g e

    Serial.print(valx);

    Serial.print(" ");

    Serial.println(valy);

    if(valxmeany+50){

    speedl=speedl*(-10);

    verify();

    left();

    }

    else if(valymeanx+20){

    if(valy>meany+50){

    speedl=speedl*(-10);

  • 5/20/2018 Accelerometer(PROJ REPORT)

    13/22

    13 | P a g e

    verify();

    left();

    // right();

    }

    else if(valy

  • 5/20/2018 Accelerometer(PROJ REPORT)

    14/22

    14 | P a g e

    forward();

    if(c == 'b')

    back();

    if(c == 'l')

    left();

    if(c == 'r')

    right();

    }

    long duration, cm;

    // The PING))) is triggered by a HIGH pulse of 2 or more

    microseconds.

    // Give a short LOW pulse beforehand to ensure a clean HIGH

    pulse:

    pinMode(ping, OUTPUT);

    digitalWrite(ping, LOW);

    delayMicroseconds(2);

    digitalWrite(ping, HIGH);

    delayMicroseconds(5);

    digitalWrite(ping, LOW);

    pinMode(ping, INPUT);

    duration = pulseIn(ping, HIGH);

    // convert the time into a distance

    cm = microsecondsToCentimeters(duration);

  • 5/20/2018 Accelerometer(PROJ REPORT)

    15/22

    15 | P a g e

    if(cm

  • 5/20/2018 Accelerometer(PROJ REPORT)

    16/22

    16 | P a g e

    return microseconds / 29 / 2;

    }

    void verify(){

    if(speedl255)

    speedl=255;

    }

    void calib(){

    int i=0;

    int valx,valy,minx=1023,miny=1023,maxx=0,maxy=0;

    while(i

  • 5/20/2018 Accelerometer(PROJ REPORT)

    17/22

    17 | P a g e

    delay(10);

    }

    theetax = (maxx-minx)/precision;

    theetay = (maxy-miny)/precision;

    meanx = 0.5*(maxx + minx);

    meany = 0.5*(maxy + miny);

    if(debug == 1){

    Serial.print(maxx);

    Serial.print(" ");

    Serial.println(maxy);

    Serial.print(" ");

    Serial.print(minx);

    Serial.print(" ");

    Serial.println(miny);

    Serial.print(" ");

    Serial.print(theetax);

    Serial.print(" ");

    Serial.println(theetay);

    Serial.print(meanx);

    Serial.print(" ");

    Serial.println(meany);

    }

    }

    void back(){

  • 5/20/2018 Accelerometer(PROJ REPORT)

    18/22

    18 | P a g e

    digitalWrite(lp,LOW);

    analogWrite(ln,(255));

    digitalWrite(rp,LOW);

    analogWrite(rn,(255));

    }

    void forward(){

    digitalWrite(lp,HIGH);

    analogWrite(ln,0);

    digitalWrite(rp,HIGH);

    analogWrite(rn,0);

    }

    void right(){

    digitalWrite(lp,LOW);

    analogWrite(ln,255);

    digitalWrite(rp,HIGH);

    analogWrite(rn,0);

    }

    void left(){

    digitalWrite(lp,HIGH);

    analogWrite(ln,0);

    digitalWrite(rp,LOW);

    analogWrite(rn,255);

    }

    void stop(){

    digitalWrite(lp,LOW);

  • 5/20/2018 Accelerometer(PROJ REPORT)

    19/22

    19 | P a g e

    analogWrite(ln,0);

    digitalWrite(rp,LOW);

    analogWrite(rn,0);

    }

  • 5/20/2018 Accelerometer(PROJ REPORT)

    20/22

    20 | P a g e

    RESULT

    The walking stick is equipped with 4 ultrasonic sensors to tell the user

    if there are any obstructions on his right, left, front or if there is a potholes

    or stair in front. It was observed that 1 Arduino board drawing power

    through the USB cable from a laptop is not enough to power 4 ultrasonic

    sensors, 2 buzzers and 2 mobile vibrators. An adaptor should be used in

    such a case to power the arduino board. Due to unavailability of an adapter

    at the present moment 2 Arduino boards have been used to power the cane

    properly.

    The water sensor made using IC NE555 is working successfully.

    APPLICATIONS

    This walking stick can bring a new lease of life for blind and old people.

    It is a means of independence for them. It will prove to be a useful tool tomillions of blind people in navigating their environment with confidence and

    safety. It will allow then to travel where and when they want, and as suchleads to self sufficiency. Independence and freedom to travel are so

    important to the quality of life of blind people that every blind person shouldhave this cane.

  • 5/20/2018 Accelerometer(PROJ REPORT)

    21/22

    21 | P a g e

    PRECAUTIONS

    1. Connections should be tight.2. Make sure that all the components are getting the required amount of

    voltage so that they function properly.3. The ultrasonic sensors must face the obstructions head on and not at an

    angle or they would not give correct values of distance.

    LEARNING OUTCOME

    I learnt how to use the Arduino board and program sensors, buzzers

    and vibrators using it. I also learnt the mechanism as to how the ultrasonic

    sensor works.

    It was also observed that 1 arduino board cannot power multiple

    ultrasonic sensors as one ultrasonic sensor requires 15mA when active, and

    Arduino can supply a maximum of 40mA current through each pin and atotal of 200mA through all pins. Even then the sensor shows the correct

    value of distance in the serial monitor, but could not power the buzzer or

    vibrator properly, defeating the purpose for which it is being used.

    It was learnt how to make a simple water sensor using household

    components.

  • 5/20/2018 Accelerometer(PROJ REPORT)

    22/22

    22 | P a g e

    BIBLIOGRAPHY

    1. Getting Started with Arduino by Massimo Banzi

    2. Introduction to Arduino by Alan G. Smith

    3. www.arduino.com

    4. www.google.com

    5. www.wikipedia.org

    http://www.arduino.com/http://www.arduino.com/http://www.google.com/http://www.google.com/http://www.google.com/http://www.arduino.com/