The ADXL345 is a small, thin, low power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16 g. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface.
The ADXL345 is well suited for mobile device applications. It measures the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. Its high resolution (4 mg/LSB) enables measurement of inclination changes less than 1.0°.
Several special sensing functions are provided. Activity and inactivity sensing detect the presence or lack of motion and if the acceleration on any axis exceeds a user-set level. Tap sensing detects single and double taps. Free-fall sensing detects if the device is falling. These functions can be mapped to one of two interrupt output pins. An integrated, patent pending 32-level first in, first out (FIFO) buffer can be used to store data to minimize host processor intervention.
Low power modes enable intelligent motion-based power management with threshold sensing and active acceleration measurement at extremely low power dissipation.
The ADXL345 is supplied in a small, thin, 3 mm × 5 mm × 1 mm, 14-lead, plastic package.
The goal of this project (Microcontroller No-OS) is to be able to provide reference projects for lower end processors, which can't run Linux, or aren't running a specific operating system, to help those customers using microcontrollers with ADI parts. Here you can find a generic driver which can be used as a base for any microcontroller platform and also specific drivers for different microcontroller platforms.
The driver contains two parts:
The Communication Driver has a standard interface, so the ADXL345 driver can be used exactly as it is provided.
If the SPI communication is chosen, there are three functions which are called by the ADXL345 driver:
SPI driver architecture
If the I2C communication is chosen, there are three functions which are called by the ADXL345 driver:
I2C driver architecture
The implementation of these three functions depends on the used microcontroller.
The following functions are implemented in this version of ADXL345 driver:
Function | Description |
---|---|
char ADXL345_Init(char commProtocol) | Initializes the communication peripheral and checks if the ADXL345 part is present. |
void ADXL345_SetRegisterValue(unsigned char registerAddress, unsigned char registerValue) | Writes data into a register. |
unsigned char ADXL345_GetRegisterValue(unsigned char registerAddress) | Reads the value of a register. |
void ADXL345_SetPowerMode(unsigned char pwrMode) | Places the device into standby/measure mode. |
void ADXL345_GetXyz(short* x, short* y, short* z) | Reads the raw output data of each axis. |
void ADXL345_GetGxyz(float* x, float* y, float* z) | Reads the raw output data of each axis and converts it to g. |
void ADXL345_SetTapDetection(unsigned char tapType, unsigned char tapAxes, unsigned char tapDur, unsigned char tapLatent, unsigned char tapWindow, unsigned char tapThresh, unsigned char tapInt) | Enables/disables the tap detection. |
void ADXL345_SetActivityDetection(unsigned char actOnOff, unsigned char actAxes, unsigned char actAcDc, unsigned char actThresh, unsigned char actInt) | Enables/disables the activity detection. |
void ADXL345_SetInactivityDetection(unsigned char inactOnOff, unsigned char inactAxes, unsigned char inactAcDc, unsigned char inactThresh, unsigned char inactTime, unsigned char inactInt) | Enables/disables the inactivity detection. |
void ADXL345_SetFreeFallDetection(unsigned char ffOnOff, unsigned char ffThresh, unsigned char ffTime, unsigned char ffInt) | Enables/disables the free-fall detection. |
void ADXL345_SetOffset(unsigned char xOffset, unsigned char yOffset, unsigned char zOffset) | Calibrates the accelerometer. |
void ADXL345_SetRangeResolution(unsigned char gRange, unsigned char fullRes) | Selects the measurement range. |
HW Platform(s):
This section contains a description of the steps required to run the ADXL345 demonstration project on a Digilent Cerebot MX3cK platform.
The ADXL345 demonstration project for PIC32MX320F128H consists of three parts: the ADXL345 Driver, the PmodACL Demo for PIC32MX320F128H and the PIC32MX320F128H Common Drivers.
All three parts have to be downloaded.
A PmodACL can be connected to the J2 connector of Cerebot MX3cK development board for I2C operation,
or to the JE connector of Cerebot MX3cK development board for SPI operation.
The following commands were implemented in this version of ADXL345 reference project for Cerebot MX3cK board.
Command | Description |
---|---|
help? | Displays all available commands. |
communication= | Selects the communication interface. Accepted values: 0 - SPI. 1 - I2C. |
communication? | Displays the selected communication interface. |
acceleration? | Displays the accelerations on XYZ axes. |
accelerationX? | Displays the acceleration on X axis. |
accelerationY? | Displays the acceleration on Y axis. |
accelerationZ? | Displays the acceleration on Z axis. |
interrupts? | Displays the state of the interrupts. |
Commands can be executed using a serial terminal connected to the UART1 peripheral of PIC32MX320F128H.
The following image shows a generic list of commands in a serial terminal connected to processor’s UART peripheral.
This section presents the steps for developing a software application that will run on the Digilent Cerebot MX3cK development board for controlling and monitoring the operation of the ADI part.
This section contains a description of the steps required to run the ADXL345 demonstration project on a Digilent Cerebot MC7 platform.
A PmodACL can be connected to the J6 connector of Cerebot MC7 development board for I2C operation,
or to the JB connector of Cerebot MC7 development board for SPI operation.
Following commands were implemented in this version of ADXL345 reference project for Cerebot MC7 board.
Command | Description |
---|---|
help? | Displays all available commands. |
communication= | Selects the communication interface. Accepted values: 0(I2C),1(SPI). |
communication? | Displays the selected communication interface. |
acceleration? | Displays the acceleration on XYZ axis. |
interrupts? | Displays the state of the interrupts. |
Commands can be executed using a serial terminal connected to the UART1 peripheral of dsPIC33FJ128MC706A.
The following image shows a list of commands in a serial terminal connected to processor’s UART peripheral.
This section presents the steps for developing a software application that will run on the Digilent Cerebot MC7 development board for controlling and monitoring the operation of the ADI part.
This section contains a description of the steps required to run the ADXL345 chipKIT demonstration project on a Digilent Cerebot MX3cK platform.
A PmodACL can be connected to the J2 connector of Cerebot MX3cK development board for I2C operation,
or to the JE connector of Cerebot MX3cK development board for SPI operation.
Following commands were implemented in this version of ADXL345 reference project for Cerebot MX3cK board.
Command | Description |
---|---|
help? | Displays all available commands. |
communication= | Selects the communication interface. Accepted values: 0(I2C),1(SPI). |
communication? | Displays the selected communication interface. |
acceleration? | Displays the acceleration on XYZ axis. |
interrupts? | Displays the state of the interrupts. |
Commands can be executed using the serial monitor.
Carriage return has to be selected as a line ending character. The required baud rate is 9600 baud.
The following image shows a list of commands in the serial monitor.
This section presents the steps for developing a chipKIT application that will run on the Digilent Cerebot MX3cK development board for controlling and monitoring the operation of the ADI part.
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
全部0条评论
快来发表一下你的评论吧 !