accel24  2.1.0.0
Main Page

Accel 24 click

Accel 24 Click is a compact add-on board that contains an acceleration sensor. This board features the MXC6655XA, a 12-bit three-axis accelerometer from MEMSIC. It allows selectable full-scale acceleration measurements in ranges of ±2g, ±4g, or ±8g in three axes with a compatible I2C serial interface with 400KHz fast mode operation. Alongside low offset and temperature signal with high accuracy, the MXC6655XA also detects six orientation positions, X/Y shake, and shake directions with an appropriate interrupt signal for these states.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Aug 2022.
  • Type : I2C type

Software Support

We provide a library for the Accel 24 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 Accel 24 Click driver.

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of Accel 24 click board by reading and displaying accel data (X, Y, and Z axis) as well as temperature measurements on the USB UART.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the click default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
accel24_cfg_t accel24_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
accel24_cfg_setup( &accel24_cfg );
ACCEL24_MAP_MIKROBUS( accel24_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == accel24_init( &accel24, &accel24_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ACCEL24_ERROR == accel24_default_cfg ( &accel24 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Reads and displays the accel data (X, Y, and Z axis) as well as temperature measurements on the USB UART every 100ms approximately.

void application_task ( void )
{
accel24_data_t meas_data;
// Wait for data ready indication
while ( accel24_get_int_pin ( &accel24 ) );
if ( ACCEL24_OK == accel24_read_data ( &accel24, &meas_data ) )
{
log_printf( &logger, " X: %.3f g\r\n", meas_data.x );
log_printf( &logger, " Y: %.3f g\r\n", meas_data.y );
log_printf( &logger, " Z: %.3f g\r\n", meas_data.z );
log_printf( &logger, " Temperature: %.2f degC\r\n", meas_data.temperature );
}
Delay_ms ( 100 );
}

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.Accel24

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. UART terminal is available in all MikroElektronika compilers.


accel24_default_cfg
err_t accel24_default_cfg(accel24_t *ctx)
Accel 24 default configuration function.
accel24_cfg_setup
void accel24_cfg_setup(accel24_cfg_t *cfg)
Accel 24 configuration object setup function.
ACCEL24_ERROR
@ ACCEL24_ERROR
Definition: accel24.h:319
accel24_t
Accel 24 Click context object.
Definition: accel24.h:269
accel24_data_t::z
float z
Definition: accel24.h:307
application_task
void application_task(void)
Definition: main.c:65
accel24_read_data
err_t accel24_read_data(accel24_t *ctx, accel24_data_t *data_out)
Accel 24 read data function.
accel24_get_int_pin
uint8_t accel24_get_int_pin(accel24_t *ctx)
Accel 24 get int pin function.
accel24_cfg_t
Accel 24 Click configuration object.
Definition: accel24.h:288
accel24_data_t::x
float x
Definition: accel24.h:305
accel24_init
err_t accel24_init(accel24_t *ctx, accel24_cfg_t *cfg)
Accel 24 initialization function.
accel24_data_t
Accel 24 Click data structure.
Definition: accel24.h:304
accel24_set_full_scale_range
err_t accel24_set_full_scale_range(accel24_t *ctx, uint8_t fsr)
Accel 24 set full scale range function.
application_init
void application_init(void)
Definition: main.c:29
ACCEL24_OK
@ ACCEL24_OK
Definition: accel24.h:318
accel24_data_t::y
float y
Definition: accel24.h:306
accel24_data_t::temperature
float temperature
Definition: accel24.h:308
ACCEL24_MAP_MIKROBUS
#define ACCEL24_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: accel24.h:256