3-axis Accelerometer sensor
interfacing with ATmega16
(ADXL335)
Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005
Website: www.ablab.in | E-mail: info@ablab....
Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005
Website: www.ablab.in | E-mail: info@ablab....
Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005
Website: www.ablab.in | E-mail: info@ablab....
Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005
Website: www.ablab.in | E-mail: info@ablab....
Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005
Website: www.ablab.in | E-mail: info@ablab....
Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005
Website: www.ablab.in | E-mail: info@ablab....
Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005
Website: www.ablab.in | E-mail: info@ablab....
Upcoming SlideShare
Loading in...5
×

3 axis accelerometer sensor interfacing with atmega16(adxl335)

1,701

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,701
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
144
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "3 axis accelerometer sensor interfacing with atmega16(adxl335)"

  1. 1. 3-axis Accelerometer sensor interfacing with ATmega16 (ADXL335)
  2. 2. Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005 Website: www.ablab.in | E-mail: info@ablab.in | Ph: 91-674-6573832 Table of Contents Project Description .................................................................................................... 3 Hardwares Required .................................................................................................. 3 Softwares Required ................................................................................................... 3 Circuit Diagram .......................................................................................................... 4 C Program.................................................................................................................. 4 Connection Guide ...................................................................................................... 7 Update Yourself......................................................................................................... 8
  3. 3. Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005 Website: www.ablab.in | E-mail: info@ablab.in | Ph: 91-674-6573832 Project Description In this project, we will interface a 3-axisAccelerometer Sensor (ADXL335) with ATmega16 microcontroller. Then, we will read the values of x-axis, y-axis and z-axis of 3-axis Accelerometer Sensor. The read values of Accelerometer Sensor will be displayed in the 16X2 LCD. Hardwares Required  AVR Trainer Board-100-1pcs  AVR USB Programmer-1pcs  12V DC Adapter-1pcs  16X2 Alphanumeric LCD(JHD162A)-1pcs  Accelerometer Sensor(ADXL335)-1pcs  1 to 1 Connector-8pcs  10 to 10 FRC Female Connector-2pcs  USB AM-AF Cable(Optional)-1pcs Softwares Required  AVR Studio 4  WinAVR -2010  SinaProg Hex Downloader  USBasp Driver
  4. 4. Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005 Website: www.ablab.in | E-mail: info@ablab.in | Ph: 91-674-6573832 Circuit Diagram C Program //**************************************************************// //Microcontroller :ATmega16 //System Clock :1MHz //Project :3-axis Accelerometer sensor interfacing with ATmega16 (ADXL335) //AVR Compiler :AVR-GCC 4.3.2 //Author :ABLab Solutions // :www.ablab.in // :info@ablab.in //Date :1st January 2012 //**************************************************************//
  5. 5. Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005 Website: www.ablab.in | E-mail: info@ablab.in | Ph: 91-674-6573832 #include<avr/io.h> /*Includes io.h header file where all the Input/Output Registers and its Bits are defined for AVR microcontroller*/ #define F_CPU 1000000 /*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/ #include<util/delay.h> /*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/ #define LCD_DATA_PORT PORTB /*Defines a macro for the lcd.h header File. LCD_DATA_PORT is the microcontroller PORT Register to which the data pins of the LCD are connected*/ #define LCD_CONT_PORT PORTD /*Defines a macro for the lcd.h header File. LCD_CONT_PORT is the microcontroller PIN Register to which the control pins of the LCD are connected*/ #define LCD_RS PD0 /*Defines a macro for the lcd.h header file. LCD_RS is the microcontroller Port pin to which the RS pin of the LCD is connected*/ #define LCD_RW PD1 /*Defines a macro for the lcd.h header file. LCD_RW is the microcontroller Port pin to which the RW pin of the LCD is connected*/ #define LCD_EN PD2 /*Defines a macro for the lcd.h header file. LCD_EN is the microcontroller Port pin to which the EN pin of the LCD is connected*/ #include<avr/lcd.h> /*Includes lcd.h header file which defines all the functions for all Alphanumeric LCD*/ #include<avr/adc.h>
  6. 6. Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005 Website: www.ablab.in | E-mail: info@ablab.in | Ph: 91-674-6573832 /*Includes adc.h header file which defines all the functions for Analog to Digital Converter*/ #include<avr/adxl335.h> /*Includes adxl335.h header file which defines all the functions for Accelometer*/ void main(void) { DDRB=0xff; /*All pins of PortB are declared output (data pins of LCD are connected)*/ DDRD=0x07; /*PD0,PD1 and PD2 pins of PortD are declared output (control pins of LCD connected)*/ int x,y,z; /*Variable declarations*/ adc_init(); /*ADC initialization*/ lcd_init(); /*LCD initialization*/ /*Start of infinite loop*/ while(1)//Start of Infinite loop. { x=read_adxl335_x_value(0); /*Reading x-axis value*/ lcd_command_write(0x01); /*Clear screen*/ lcd_string_write("ABLab Solutions"); /*String display in LCD*/
  7. 7. Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005 Website: www.ablab.in | E-mail: info@ablab.in | Ph: 91-674-6573832 lcd_command_write(0xc0); /*Cursor moves to 2nd row 1st column of LCD*/ lcd_number_write(x,10); /*x-axis value display in LCD*/ y=read_adxl335_x_value(1); /*Reading y-axis value*/ lcd_command_write(0xc5); /*Cursor moves to 6th column of 1st row*/ lcd_number_write(y,10); /*y-axis value display in LCD*/ z=read_adxl335_x_value(2); /*Reading z-axis value*/ lcd_command_write(0xca); /*Cursor moves to 11th column of 1st row*/ lcd_number_write(z,10); /*z-axis value display in LCD*/ _delay_ms(1000); /*1 second delay*/ } } /*End of Program*/ Connection Guide The step-by-step procedures for 3-Axis Accelerometer sensor interfacing with ATmega16 are as follows:  Insert the DC Pin of 12V DC Adapter to the DC Socket of AVR Trainer Board-100.  Connect PORTB header with LCD data header of AVR Trainer Board-100 with a 10 to 10 FRC Female Connector.
  8. 8. Sneha Palace, Plot No.60,Laxmi Vihar, Near Appolo Hospital, Bhubaneswar-751005 Website: www.ablab.in | E-mail: info@ablab.in | Ph: 91-674-6573832  Connect RS, RW & EN pin of LCD control header with PD0, PD1 & PD2 pin of PORTD header respectively of AVR Trainer Board-100 with 1 to 1 Connectors.  Connect the ISP header of AVR Trainer Board-100 with AVR USB Programmer header with a 10 to 10 FRC Female Connector.  Connect the 16X2 Alphanumeric LCD to the LCD header of AVR Trainer Board- 100.  Connect the X, Y, Z, VCC and GND pins of Accelerometer Sensor with PA0, PA1, PA2, +5V and GND pins of AVR Trainer Board-100 with 1 to 1 connectors.  Connect the AVR USB Programmer to the PC/Laptop’s USB Port.  Switch on the power with the help of Power Switch of AVR Trainer Board-100.  Download the 3-Axis Accelerometer sensor interfacing with ATmega16 (ADXL335) Hex file to AVR Trainer Board-100.  Tilt the 3-Axis Accelerometer sensor in different direction and see the output. Update Yourself For more Softwares, Tutorials, Sample Codes, Installation Guides, User Guides, User Manuals, Videos, Products & Components and Updates, Please Visit us at: www.ablab.in Mail us at: Info@ablab.in View us at: www.youtube.com/ablabsolutions Like us at: www.facebook.com/ablab.in Join us at: www.facebook.com/groups/ablabsolutions

×