Difference between revisions of "Triple-Axis Analog Accelerometer"

From LinkSprite Playgound
Jump to: navigation, search
(Created page with "== Introduction == Based on the excellent ADXL-345, this digital 3-axis accelerometer has excellent EMI protection. Its variable output makes it suitable for a wide range of...")
 
 
(11 intermediate revisions by 2 users not shown)
Line 11: Line 11:
 
The sensor is utilizes a 4-pin Grove interface (3-5VDC) for easy connectivity with your standard Arduino device or Seeed Stalker.
 
The sensor is utilizes a 4-pin Grove interface (3-5VDC) for easy connectivity with your standard Arduino device or Seeed Stalker.
  
[[File:trip-axisanalog accelerometer.jpg]]
+
[[File:trip-axisanalog accelerometer.jpg | 400px]]
 +
 
 
== Features  ==
 
== Features  ==
  
Line 42: Line 43:
  
 
[[Image:schematic.jpg]]
 
[[Image:schematic.jpg]]
 +
 +
*[https://s3.amazonaws.com/linksprite/LinkerKit/Accelerometer.pdf Schematics]
  
 
== Usage  ==
 
== Usage  ==
  
The sensor communicates with the MCU via I<sup>2</sup>C interface. Connected the sensor to the I<sup>2</sup>C port via grove 4 pin wires if you are using the [http://www.seeedstudio.com/depot/grove-base-shield-p-754.html?cPath=132_134 Grove Base Shield].  
+
The sensor communicates with the MCU via I<sup>2</sup>C interface.  
  
For the first use you should download the [http://www.seeedstudio.com/wiki/File:ADXL345_Driver_for_Arduino.zip ADXL345 Driver for Arduino.zip] and unpack into arduino-1.0\libraries in your Arduino installation folder.  
+
For the first use you should download the [https://s3.amazonaws.com/linksprite/sensor_pack/Triple-Axis_Analog_Accelerometer+/ADXL345_Driver_for_Arduino.zip ADXL345 Driver for Arduino.zip] and unpack into '''arduino-1.0\libraries''' in your Arduino installation folder.  
  
 
If you are using jumper wire to connect the sensor, make sure that the sensor's SDA pin is connect to the analog port A4 and the SCL pin is connect to A5. This two pins are used as the I<sup>2</sup>C interface at your Arduino.&nbsp;  
 
If you are using jumper wire to connect the sensor, make sure that the sensor's SDA pin is connect to the analog port A4 and the SCL pin is connect to A5. This two pins are used as the I<sup>2</sup>C interface at your Arduino.&nbsp;  
  
[[Image:Grove - 3-Axis Digital Accelerometer ADXL345 connect photo.JPG|495px|Grove - 3-Axis Digital Accelerometer ADXL345 connect photo.JPG]]&nbsp;&nbsp; [[Image:Grove - 3-axis digital accelerometer-ADXL345 V1.0 serial.bmp|400px|Grove - 3-axis digital accelerometer-ADXL345 V1.0 serial.bmp]]
+
 
 +
 
 +
 
  
 
== Programming  ==
 
== Programming  ==
Line 171: Line 176:
 
== Support  ==
 
== Support  ==
  
If you have questions or other better design ideas, you can go to our [http://www.seeedstudio.com/forum forum]&nbsp;or [http://wish.seeedstudio.com wish]&nbsp;to discuss.  
+
If you have questions or other better design ideas, you can go to our [http://www.linksprite.com/forum/index.php forum]&nbsp;or [http://www.linksprite.com/ wish]&nbsp;to discuss.
  
 
== Resources  ==
 
== Resources  ==
  
 +
*[https://s3.amazonaws.com/linksprite/sensor_pack/Triple-Axis_Analog_Accelerometer+/Grove_-_3-axis_digital_accelerometer-ADXL345_V1.0_Eagle_file.zip Grove_-_3-axis_digital_accelerometer-ADXL345_V1.0_Eagle_file.zip]
 +
*[https://s3.amazonaws.com/linksprite/sensor_pack/Triple-Axis_Analog_Accelerometer+/ADXL345_Driver_for_Arduino.zip ADXL345 lib for Arduino.zip]
 +
*[https://s3.amazonaws.com/linksprite/sensor_pack/Triple-Axis_Analog_Accelerometer+/Grove_3_axis_digital_accelerometer_ADXL345_demo_code.ino.zip Grove - 3-axis digital accelerometer-ADXL345 V1.0 Eagle file.zip]
 +
*[https://s3.amazonaws.com/linksprite/sensor_pack/Triple-Axis_Analog_Accelerometer+/ADXL345_datasheet.pdf ADXL345 datasheet.pdf]
  
 
== How to buy  ==
 
== How to buy  ==
 +
Retired
  
 +
== See Also  ==
  
== See Also  ==
+
Other related products and resources.

Latest revision as of 07:45, 25 February 2014

Introduction

Based on the excellent ADXL-345, this digital 3-axis accelerometer has excellent EMI protection. Its variable output makes it suitable for a wide range of applications:

  • HDD shock protection
  • Vibration sensor
  • Game controller input
  • Robotics
  • Smart vehicles
  • Anywhere you need to obtain motion-sensing & orientation information.

The excellent sensitivity (3.9mg/LSB @2g) provids high-precision output up to ±16g.
The sensor is utilizes a 4-pin Grove interface (3-5VDC) for easy connectivity with your standard Arduino device or Seeed Stalker.

Trip-axisanalog accelerometer.jpg

Features

  • Wide power range DC3V to 5V
  • Grove module
  • 3 axis sensing
  • I2C digital interface
  • High sensitivity
  • Small, low-profile package: 14-Terminal LGA
  • Low power 0.1 μA in standby mode at VS = 2.5 V (typical)
  • 10,000 g shock survival
  • RoHS/WEEE lead-free compliant


Application Ideas

  • Motion Sensor
  • Shock detector
  • Vibration sensor
  • Toy car
  • Robotics
  • Disk drive Shock Protection
  • Game Controller

Cautions

Notice: Before you got this sensor, we have tested it to ensure that the sensor is working right. Sometimes there might be a small offset of the sensor, but it is within the acceptable error range. You can set the offset register according to the chip's datasheet to regulate the sensor.
Warning: wrong operation can cause danger.

Schematic

Schematic.jpg

Usage

The sensor communicates with the MCU via I2C interface.

For the first use you should download the ADXL345 Driver for Arduino.zip and unpack into arduino-1.0\libraries in your Arduino installation folder.

If you are using jumper wire to connect the sensor, make sure that the sensor's SDA pin is connect to the analog port A4 and the SCL pin is connect to A5. This two pins are used as the I2C interface at your Arduino. 



Programming

<syntaxhighlight lang="c"> //Arduino 1.0+ Only! //Arduino 1.0+ Only!

  1. include <Wire.h>
  2. include <ADXL345.h>


ADXL345 adxl; //variable adxl is an instance of the ADXL345 library

void setup(){

 Serial.begin(9600);
 adxl.powerOn();
 //set activity/ inactivity thresholds (0-255)
 adxl.setActivityThreshold(75); //62.5mg per increment
 adxl.setInactivityThreshold(75); //62.5mg per increment
 adxl.setTimeInactivity(10); // how many seconds of no activity is inactive?

 //look of activity movement on this axes - 1 == on; 0 == off 
 adxl.setActivityX(1);
 adxl.setActivityY(1);
 adxl.setActivityZ(1);

 //look of inactivity movement on this axes - 1 == on; 0 == off
 adxl.setInactivityX(1);
 adxl.setInactivityY(1);
 adxl.setInactivityZ(1);

 //look of tap movement on this axes - 1 == on; 0 == off
 adxl.setTapDetectionOnX(0);
 adxl.setTapDetectionOnY(0);
 adxl.setTapDetectionOnZ(1);

 //set values for what is a tap, and what is a double tap (0-255)
 adxl.setTapThreshold(50); //62.5mg per increment
 adxl.setTapDuration(15); //625μs per increment
 adxl.setDoubleTapLatency(80); //1.25ms per increment
 adxl.setDoubleTapWindow(200); //1.25ms per increment

 //set values for what is considered freefall (0-255)
 adxl.setFreeFallThreshold(7); //(5 - 9) recommended - 62.5mg per increment
 adxl.setFreeFallDuration(45); //(20 - 70) recommended - 5ms per increment

 //setting all interupts to take place on int pin 1
 //I had issues with int pin 2, was unable to reset it
 adxl.setInterruptMapping( ADXL345_INT_SINGLE_TAP_BIT,   ADXL345_INT1_PIN );
 adxl.setInterruptMapping( ADXL345_INT_DOUBLE_TAP_BIT,   ADXL345_INT1_PIN );
 adxl.setInterruptMapping( ADXL345_INT_FREE_FALL_BIT,    ADXL345_INT1_PIN );
 adxl.setInterruptMapping( ADXL345_INT_ACTIVITY_BIT,     ADXL345_INT1_PIN );
 adxl.setInterruptMapping( ADXL345_INT_INACTIVITY_BIT,   ADXL345_INT1_PIN );

 //register interupt actions - 1 == on; 0 == off  
 adxl.setInterrupt( ADXL345_INT_SINGLE_TAP_BIT, 1);
 adxl.setInterrupt( ADXL345_INT_DOUBLE_TAP_BIT, 1);
 adxl.setInterrupt( ADXL345_INT_FREE_FALL_BIT,  1);
 adxl.setInterrupt( ADXL345_INT_ACTIVITY_BIT,   1);
 adxl.setInterrupt( ADXL345_INT_INACTIVITY_BIT, 1);

}

void loop(){

 //Boring accelerometer stuff   
 int x,y,z;  
 adxl.readAccel(&x, &y, &z); //read the accelerometer values and store them in variables  x,y,z
 // Output x,y,z values - Commented out
 Serial.print(x);
 Serial.print('\t');
 Serial.print(y);
 Serial.print('\t');
 Serial.println(z);
 delay(500);

/*

 //Fun Stuff!    
 //read interrupts source and look for triggerd actions
 
 //getInterruptSource clears all triggered actions after returning value
 //so do not call again until you need to recheck for triggered actions
  byte interrupts = adxl.getInterruptSource();
 
 // freefall
 if(adxl.triggered(interrupts, ADXL345_FREE_FALL)){
   Serial.println("freefall");
   //add code here to do when freefall is sensed
 } 
 
 //inactivity
 if(adxl.triggered(interrupts, ADXL345_INACTIVITY)){
   Serial.println("inactivity");
    //add code here to do when inactivity is sensed
 }
 
 //activity
 if(adxl.triggered(interrupts, ADXL345_ACTIVITY)){
   Serial.println("activity"); 
    //add code here to do when activity is sensed
 }
 
 //double tap
 if(adxl.triggered(interrupts, ADXL345_DOUBLE_TAP)){
   Serial.println("double tap");
    //add code here to do when a 2X tap is sensed
 }
 
 //tap
 if(adxl.triggered(interrupts, ADXL345_SINGLE_TAP)){
   Serial.println("tap");
    //add code here to do when a tap is sensed
 } */

} </syntaxhighlight>

Support

If you have questions or other better design ideas, you can go to our forum or wish to discuss.

Resources

How to buy

Retired

See Also

Other related products and resources.