Sunday, 13 October 2013

Analog 3-Axis Accelerometer interfacing with ATmega8 board

Every body is having a smart phone. The vary first game that you will look for is "TEMPLE RUN".
This game became favorite of many.

In the above situation how the player bends side?

I know what you will say "we tilt the smart phone left".

the question is how your mobile is able to sense the tilt. Here comes the concept of a small devise called

Accelerometer

 what is this thing?????????

It is a Micro Electro Mechanical device. For short MEMS.

How the accelerometer work?
when ever you tilt the accelerometer at any axis the module of the corresponding axis will sense the change in "g"(acceleration due to gravity) and produces a corresponding change in the terms of analog voltage. 

Now we are going to use an accelerometer to control the robot. This technique helps a physically challenged person to control the wheel chair with their hand gesture .
As shown in the above figure this sensor module is available at many models from different vendors. But the basic connection are same for all ADXL335 modules.

Actually this sensor module comes with an internal 3.3V voltage regulator. then you can directly use a 5V supply. otherwise you have to go for 3.3V supply. 

These X Y Z pins are the analog outputs from the sensor. As the device internally works at 3.3V the maximum voltage produced at these pins will be 3.3V

As we know that our microcontroller is digital and it cannot process the analog data directly. We need to convert the analog data into digital. An A/D converter is required for this process.

In this tutorial We are going to use an AVR microcontroller (ATmega8) based platform which is having an in built ADC mechanism in it.

This board was developed by ROBOGENESIS.
The specialty of the board is "NO EXTERNAL PROGRAMMER IS REQUIRED" .
It can be programmed through USB port.
comes along with a special library so any one can program the board.
Also compatible with ARDUINO programming.
For more info about This board mail us at : vaabrobotics@gmail.com
This board comes with a CD that include the necessary libraries for all the modules compatible with this microcontroller hardware.

So in this project we are going to use "adc.h" header file
which helps in using the ADC port of this board.

to check the ADC values at the respective levels we are going to interface an LCD too..
this will help us in calibrating the ADC data from the accelerometer.
to support the LCD port the "lcd.h" header file can be used.

connect the sensor X,Y,Z axis outputs to the ADC0, ADC1, ADC2 channels respectively

CODE FOR ATmega8 INTERFACING WITH ADXL335
#include<avr/io.h>                    //  I/O port definitions 
#define F_CPU 12000000UL  // frequency of the board
#include<util/delay.h>              // headder file for delay functions
#include"lcd.h"                        // LCD headder file
#include"adc.h"                       // ADC headder file
void main()
 lcd_init();   // initializing LCD
 adc_init();   // initializing ADC
 lcd_string("working"); // displays "working" on first row of LCD
 _delay_ms(1200);      // delay of 1.2seconds
 lcd_clear();               // LCD display cleared
lcd_cursor(0,0);         // setting cursor to row 0 column 0 position
 lcd_string("  X    Y    Z    "); // display on row 0
 unsigned char x,y,z; // variables
 while(1)
 {
  x=getdata(0x00);  //reading data from ADC0 storing in variable x
  y=getdata(0x01);  //reading data from ADC1 storing in variable y
  z=getdata(0x02);  //reading data from ADC2 storing in variable z
  
  lcd_cursor(1,0);  // setting cursor to row 1 colums 0 position
  lcd_num(x);       //displays the value of x
  lcd_cursor(1,5);  // setting cursor to row 1 colums 5 position
  lcd_num(y);        //displays the value of y
  lcd_cursor(1,10);// setting cursor to row 1 colums 10 position
  lcd_num(z);        //displays the value of z
 }
}

NOTE:ALL THE HEADER FILES ARE PROVIDED ALONG WITH THIS BOARD.....

6 comments:

Mayuresh said...

I want those header files for LCD and ADC

VAMSI DANDA said...

These header files are provided only with this development board only
cost of this board will be 2300/-

Abrar Ahmed said...

sir, are you a member of the robogenesis team? i have attended a workshop on haptics conducted by Mr. Varma Naidu. He also gave a demo on the humanoid which is der in ur dp. venue - CBIT, Hyderabad. I had lost winavr when i formatted my pc. I was wondering if u cud share the program to control 3 motors with 3 potentiometers using a motor driver? it'll be of a great help!

VAMSI DANDA said...

winavr is a opensource software that can be downloaded from atmel official website

Saurabh jain said...

Sir can i run almost all project on your development board.

VAMSI DANDA said...

yes you can it is based on atmega8 microcontroller with on board programmer
perfectly suitable to the beginners..

Post a Comment