Difference between revisions of "Matrix - 3-Axis Digital Accelerometer"

From FriendlyELEC WiKi
Jump to: navigation, search
(使用方法)
Line 8: Line 8:
 
* 13-bit,up to +-16g
 
* 13-bit,up to +-16g
 
* 2.54mm排针接口,接线方便,通用性强
 
* 2.54mm排针接口,接线方便,通用性强
==使用方法==
+
==How To==
===连接===
+
===Connection===
*连接到Tiny4412 SDK (1506)
+
*Connect Tiny4412 SDK (1506)
::GND针脚:   接地
+
::GND: Ground
::VCC:  接5V
+
::VCC:  5V
::INT2:留空
+
::INT2:N/A
::INT1: 留空
+
::INT1: N/A
::CS:  接5V
+
::CS:  5V
 
::SCL:  I2C SCL
 
::SCL:  I2C SCL
 
::SDA:  I2C SDA
 
::SDA:  I2C SDA
::SDO:  接5V,用来决定slave address
+
::SDO:  5V for slave address
  
 
===Code Sample in C Under Linux===
 
===Code Sample in C Under Linux===

Revision as of 11:06, 4 August 2015

查看中文

1 Introduction

3-Axis Digital Accelerometer

三轴重力加速度主要功能是用作测量x\y\z方向上的速度,可利用测量到的速度计算当前角度。模块可以使用IIC或SPI进行通信。此配件搭载了一颗ADXL345芯片。ADXL345是Anolog Device公司的三轴数字重力传感器,13-bit精度,采集范围可以是+-2g,+-4g,+-8g和+-16g,通讯方式为SPI或I2C。配件采用5V供电,PCB上的电源转换芯片输出3.3V给ADXL345。

2 特性

  • SPI/I2C,3.3V
  • 13-bit,up to +-16g
  • 2.54mm排针接口,接线方便,通用性强

3 How To

3.1 Connection

  • Connect Tiny4412 SDK (1506)
GND: Ground
VCC: 5V
INT2:N/A
INT1: N/A
CS: 5V
SCL: I2C SCL
SDA: I2C SDA
SDO: 5V for slave address

3.2 Code Sample in C Under Linux

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libfahw-adxl34x.h"
 
int main(int argc, char ** argv)
{
    char *position = (char *) malloc(32);
    memset(position, 0, 32);
 
    if (adxl34xRead(position) > 0) {
        printf("Get position: %s", position);
    } else {
        printf("Fail to get position\n");
    }
    free(position);
    return 0;
}

3.3 Compile and Run

git clone http://github.com/friendlyarm/fa-hardware.git
cd fa-hardware
cd demo
cd matrix-3_axis_digital_accelerometer
make

Copy your compiled bin to your board and you are ready to go.

4 Resources