Appendix c, Accessing the digital accelerometer – Lanner LVC-5770 User Manual

Page 40

Advertising
background image

40

Accessing the Digital Accelerometer

Appendix C

Embedded and Industrial Computing

Appendix C:

Accessing the Digital

Accelerometer Data from

the LVC-5770

The system employs Analog Devices’s ADXL345 Digital

Accelerometer which is a small, thin, ultralow power, 3-axis

accelerometer with high resolution (13-bit) measurement

at up to ±16 g. It interfaces with the LVC-5770 through a

SPI interface.

Driver Installation

To access the G-Sensor data, use the following

instructions:
Make sure you already installed the Lanner GPIO driver on

your LVC-5770 as instructed in Appendix B.

To access the Gsensor data, locate the adxl345_v001 folder

and execute the executable file adxl345 and it will show G

value of 3 axes.

A sample program in C:++
// main.cpp
// The adxl345.exe utility shows the 3 axis G value.
//
// History:
//

07/15/2011: Initial version

#include <winsock2.h>
#include <windows.h>
#include <stdio.h>
#include “ich7.h”
#include “adxl345.h”

void adxl345_init()
{

ich7_SM_WriteByte (0x1D, POWER_CTL, ACT_INACT_

SERIAL | MEASURE) ;

// Power CTL:

Measure mode, Activity and Inactivity Serial

ich7_SM_WriteByte (0x1d, BW_RATE, RATE_100);

/

/

Output Data Rate: 100Hz

ich7_SM_WriteByte (0x1d, DATA_FORMAT, FULL_

RESOLUTION | DATA_JUST_LEFT | RANGE_16G);

/

/

Data Format: 16g range, right justified, 256->1g
}

int main(int argc, char* argv[])
{

adxl345_init () ;

Advertising