accel16  2.0.0.0
Main Page

Accel 16 Click

Accel 16 Click is a compact add-on board that contains an acceleration sensor. This board features the ADXL363, a micropower three-sensor combination including acceleration and temperature from Analog Devices. This device combines a 3-axis MEMS accelerometer, a temperature sensor, and an analog-to-digital converter (ADC) input for synchronized conversions of external signals.

Click Product page


Click library

  • Author : Luka Filipovic
  • Date : Sep 2021.
  • Type : SPI type

Software Support

We provide a library for the Accel16 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for Accel16 Click driver.

Standard key functions :

Example key functions :

Example Description

This showcases ability of the Click board to

read x, y, and z axes data in different resolution, read IC temperature and also have additional functionality to read ADC data. Device also has ability to store data in internal fifo buffer.

The demo application is composed of two sections :

Application Init

Initialization of communication modules(SPI, UART) and

additional interrupt pins. Reads device ID's and revision. Then configures device to work in FIFO mode or to read data from the registers, sets 2g resolution, 12.5Hz output data rate, sets interrupt 1 active low, powers on device, and calibrates temperature.

void application_init ( void )
{
log_cfg_t log_cfg;
accel16_cfg_t accel16_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
accel16_cfg_setup( &accel16_cfg );
ACCEL16_MAP_MIKROBUS( accel16_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == accel16_init( &accel16, &accel16_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
accel16.application_type = ACCEL16_APPLICATION_REG;
uint8_t temp_buf[ 4 ] = { 0 };
log_printf( &logger, " > ID0: 0x%.2X\r\n > ID1: 0x%.2X\r\n > ID2: 0x%.2X\r\n > REV: 0x%.2X\r\n",
( uint16_t ) temp_buf[ 0 ], ( uint16_t ) temp_buf[ 1 ],
( uint16_t ) temp_buf[ 2 ], ( uint16_t ) temp_buf[ 3 ] );
if ( ACCEL16_ERROR == accel16_default_cfg ( &accel16 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Depending of the application mode selects example.

  • If fifo example is selected waits for the interrupt to indicate that data is ready in fifo buffer and reads number of fifo entries. Data that should be read are X, Y, Z axes and temperature.
  • If register example is selected also waits for interrupt to indicate that data is ready to read. Then reads X, Y, Z axes, temperature, and ADC data.
void application_task ( void )
{
if ( ACCEL16_APPLICATION_FIFO == accel16.application_type )
{
accel16_read_fifo_data( );
}
else if ( ACCEL16_APPLICATION_REG == accel16.application_type )
{
accel16_read_reg_data( );
}
log_printf( &logger, "********************************************************\r\n" );
Delay_ms ( 300 );
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Accel16

Additional notes and informations

Depending on the development board you are using, you may need USB UART Click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.


ACCEL16_APPLICATION_REG
#define ACCEL16_APPLICATION_REG
Definition: accel16.h:136
accel16_init
err_t accel16_init(accel16_t *ctx, accel16_cfg_t *cfg)
Accel 16 initialization function.
ACCEL16_APPLICATION_FIFO
#define ACCEL16_APPLICATION_FIFO
Accel 16 description setting.
Definition: accel16.h:135
accel16_multiple_reg_read
err_t accel16_multiple_reg_read(accel16_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Read multiple registers.
application_task
void application_task(void)
Definition: main.c:105
accel16_get_axes
err_t accel16_get_axes(accel16_t *ctx, accel16_axes_t *axes)
Get axes data.
accel16_cfg_t
Accel 16 Click configuration object.
Definition: accel16.h:210
accel16_filter_configuration
err_t accel16_filter_configuration(accel16_t *ctx, accel16_gain_t gain, accel16_output_rate_t odr)
Filter configuration.
accel16_gain_t
accel16_gain_t
Accel 16 Click gain.
Definition: accel16.h:256
accel16_t
Accel 16 Click context object.
Definition: accel16.h:190
accel16_axes_t
Accel 16 Click axes data.
Definition: accel16.h:233
ACCEL16_ERROR
@ ACCEL16_ERROR
Definition: accel16.h:247
ACCEL16_MAP_MIKROBUS
#define ACCEL16_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: accel16.h:174
accel16_default_cfg
err_t accel16_default_cfg(accel16_t *ctx)
Accel 16 default configuration function.
accel16_get_temperature
err_t accel16_get_temperature(accel16_t *ctx, float *temperature)
Get temperature data.
accel16_cfg_setup
void accel16_cfg_setup(accel16_cfg_t *cfg)
Accel 16 configuration object setup function.
application_init
void application_init(void)
Definition: main.c:60
ACCEL16_REG_DEVID_AD
#define ACCEL16_REG_DEVID_AD
Accel 16 description register.
Definition: accel16.h:82
accel16_output_rate_t
accel16_output_rate_t
Accel 16 Click output data rate.
Definition: accel16.h:268