Accelerometer 1

Post on 06-Jul-2015

454 views 2 download

transcript

Learn about Accelerometer• The Indian Way - Low Cost and Quick

Accelerometer

Accelerometer

• An accelerometer is a device that measures the proper acceleration of the device.

• It is an electromechanical device that will measure acceleration forces.

• These forces may be static, like the constant force of gravity pulling at your feet, or they could be dynamic - caused by moving or vibrating the accelerometer.

Conti..

• An accelerometer measures weight per unit of (test) mass, a quantity also known as specific force, or g-force.

• Most accelerometers do not display the value they measure, but supply it to other devices.

• Conceptually, an accelerometer behaves as a damped mass on a spring. When the accelerometer experiences an acceleration, the mass is displaced to the point that the spring is able to accelerate the mass at the same rate as the casing. The displacement is then measured to give the acceleration.

What are accelerometers useful for?• By measuring the amount of static acceleration due to gravity,

you can find out the angle the device is tilted at with respect to the earth.

• By sensing the amount of dynamic acceleration, you can analyze the way the device is moving.

• An accelerometer can help your project understand its surroundings better.

Conti..

• In the computing world, IBM and Apple have recently started using accelerometers in their laptops to protect hard drives from damage.

• If you accidentally drop the laptop, the accelerometer detects the sudden freefall, and switches the hard drive off so the heads don't crash on the platters.

• In a similar fashion, high g accelerometers are the industry standard way of detecting car crashes and deploying airbags at just the right time.

Applications

• Engineering

• Biology

• Industry

• Building and structural monitoring

• Medical applications

• Navigation

• Transport

• And more…

Types of Accelerometers• 2-Axis Accelerometers

• 3-Axis Accelerometers

2-Axis Accelerometers• Memsic 2125 Dual-axis Accelerometer

The Memsic 2125 is a low cost, dual-axis thermal

accelerometer capable of measuring tilt,

acceleration, rotation, and vibration with a range

of ±3 g. For integration into existing applications,

the Memsic 2125 is electrically compatible with

other popular accelerometers.

Conti..

• Features:- Measures ±3 g on each axis

- Simple pulse output of g-force for each axis

- Convenient 6-pin 0.1" spacing DIP module

- Analog output fo temperature (Tout pin)

- Low current at 3.3 or 5 V operation: less than 4 mA at 5 VDC .

• Sample Applications:-Dual-axis tilt sensing for autonomous robotics

applications

- Single-axis rotational position sensing

- Movement/Lack-of-movement sensing for alarm systems

- R/C hobby projects such as autopilots

• Key Specifications:- Power requirements: +3.3 to +5 VDC

- Communication: TTL/CMOS compatible 100 Hz PWM - output signal with duty cycle proportional to

acceleration

- Dimensions: 0.42 x 0.42 x 0.45 in (10.7 x 10.7 x 11.8 mm)

- Operating temp range: 32 to +158 °F (0 to +70 °C)

3-axis accelerometer• Triple-axis accelerometer with 3

analog outputs for X, Y and Z axis measurements on a 0.75"x0.75" breakout board.

• MMA7260 is 3-axis accelerometer and measure the accelerations in X Y and Z axis with range +-1.5 g to 6 g.

Conti..

• Features-Selectable Sensitivity (1.5g/2g/4g/6g)-Low Current Consumption: 500 μA-Sleep Mode: 3 μA-Low Voltage Operation: 2.2 V – 3.6 V-6mm x 6mm x 1.45mm QFN-High Sensitivity (800 mV/g @ 1.5g)-Fast Turn On Time-Integral Signal Conditioning with Low Pass Filter-Robust Design, High Shocks Survivability-Pb-Free Terminations-Low Cost

• Typical Applications-HDD MP3 Player: Freefall Detection

-Laptop PC: Freefall Detection, Anti-Theft

-Cell Phone: Image Stability, Text Scroll, Motion Dialing,

E-Compass

-Pedometer: Motion Sensing

-PDA: Text Scroll

-Navigation and Dead Reckoning: E-Compass Tilt Compensation

-Gaming: Tilt and Motion Sensing, Event Recorder

-Robotics: Motion Sensing

How to use

• In Accelerometer we can read the change in output values corresponding to the change in X-axis, Y-axis and Z-axis.

• Connect these PINS to the ADC pins of Atmega8.

• The varying output at the pins is reflected to ADC and the converted digital values can be displayed on LCD display.

• Calibration of the accelerometer can be done by giving the reference values in programs

Interfacing Accelerometer with AVR Microcontrollers

#define F_CPU 8000000UL

#include <avr/io.h>

#include <avr/interrupt.h>

#include<util/delay.h>

#include"lcd.h"

#include"lcd.c"

#define X_FORWARD 450

#define Y_FORWARD 380

#define Z_FORWARD 430

#define X_BACKWARD 320

#define Y_BACKWARD 380

#define Z_BACKWARD 440

#define X_RIGHT 380

#define Y_RIGHT 330

#define Z_RIGHT 440

#define X_LEFT 380

#define Y_LEFT 450

#define Z_LEFT 430

#define X_STOP 380

#define Y_STOP 382

#define Z_STOP 460

char buffer[5];

int ReadADC(uint8_t ch)

{

ADC=0;

//Select ADC Channel ch must be 0-7

ADMUX = ADMUX & 0b11100000;

ch=ch&0b00000111;

ADMUX|=ch;

//Start Single conversion

ADCSRA |= (1<<ADSC);

//Wait for conversion to complete

while(!(ADCSRA&(1<<ADIF)));

//Clear ADIF by writing one to it

ADCSRA|=(1<<ADIF);

return(ADC);

}

void initADC()

{

ADMUX=(1<<REFS0); // For Aref=AVcc;

ADCSRA=(1<<ADEN)|(1<<ADIE)|(1<<ADPS2)|(1<<ADPS1) |(1<<ADPS1); //Prescalar div factor =128

}

void wait(float x)

{

int i;

for(i=0;i<(int)(61*x);i++)

_delay_loop_2(0);

}

int main()

{

//DDRC=0x00;

DDRB=0xFF;

lcd_init(LCD_DISP_ON);

lcd_clrscr();

initADC();

int x=0,y=0,z=0, range=30;

while(1)

{

x=ReadADC(0);

y=ReadADC(1);

z=ReadADC(2);

lcd_gotoxy(0,0);

sprintf(buffer,"x=%4d, y=%4d,\nz=%4d ",x,y,z);

lcd_puts(buffer);

if((x>(X_STOP-range))&&(x<(X_STOP+range))&&(y>(Y_STOP-

range))&&(y<(Y_STOP+range))&&(z>(Z_STOP-

range))&&(z<(Z_STOP+range)))

{

PORTB=0b00000000;// stop

lcd_gotoxy(8,1);

lcd_puts("STOP");

}

if((x>(X_FORWARD-

range))&&(x<(X_FORWARD+range))&&(y>(Y_FORWARD-

range))&&(y<(Y_FORWARD+range))&&(z>(Z_FORWARD-

range))&&(z<(Z_FORWARD+range)))

{

PORTB=0b00100100; //forward

lcd_gotoxy(8,1);

lcd_puts("FRWD");

}

if((x>(X_BACKWARD-

range))&&(x<(X_BACKWARD+range))&&(y>(Y_BACKWARD-

range))&&(y<(Y_BACKWARD+range))&&(z>(Z_BACKWARD-

range))&&(z<(Z_BACKWARD+range)))

{

PORTB=0b00011000; // back

lcd_gotoxy(8,1);

lcd_puts("BACK");

}

if((x>(X_LEFT-range))&&(x<(X_LEFT+range))&&(y>(Y_LEFT-

range))&&(y<(Y_LEFT+range))&&(z>(Z_LEFT-

range))&&(z<(Z_LEFT+range)))

{

PORTB=0b00000100; // left

lcd_gotoxy(8,1);

lcd_puts("LEFT");

}

if((x>(X_RIGHT-

range))&&(x<(X_RIGHT+range))&&(y>(Y_RIGHT-

range))&&(y<(Y_RIGHT+range))&&(z>(Z_RIGHT-

range))&&(z<(Z_RIGHT+range)))

{

PORTB=0b00100000; // right

lcd_gotoxy(8,1);

lcd_puts("RIGHT");

}

wait(.1);

lcd_clrscr();

}

return 0;

}

Thank you…

About Open.Embedded

This is an initiative of group of professionals, students and hobbyists to share their knowledge among others using low cost open source software.

We think it criminal when students are taught 8085 and 8051 in college when world is moving forward and technology changes are happening every where in the world.

Join us at facebook.com/open.embedded

Buy low cost kits at stores.ebay.in/openembedded

MADE BY

SUMIT BALGUVHARM.TECH-EMBEDDED SYSTEM TECHNOLOGY