accel8 2.0.0.0
Main Page

Accel 8 click

Accel 8 Click is an advanced 6-axis motion tracking Click boardâ„¢, which utilizes the MPU6050, a very popular motion sensor IC, equipped with a 3-axis gyroscope and 3-axis accelerometer.

click Product page


Click library

  • Author : MikroE Team
  • Date : dec 2019.
  • Type : I2C type

Software Support

We provide a library for the Accel8 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

‍This library contains API for Accel8 Click driver.

Standard key functions :

  • Config Object Initialization function.

    ‍void accel8_cfg_setup ( accel8_cfg_t *cfg );

    - Initialization function.

    ‍ACCEL8_RETVAL accel8_init ( accel8_t *ctx, accel8_cfg_t *cfg );

  • Click Default Configuration function.

    ‍void accel8_default_cfg ( accel8_t *ctx );

Example key functions :

  • This function reads Accel axis data.

    ‍void accel8_get_accel_axis ( accel8_t *ctx, int16_t *x_axis, int16_t *y_axis, int16_t *z_axis );

    - This function reads Gyro axis data.

    ‍void accel8_get_gyro_axis ( accel8_t *ctx, int16_t *x_axis, int16_t *y_axis, int16_t *z_axis );

  • This function returns Interupt state.

    ‍uint8_t accel8_get_interrupt ( accel8_t *ctx );

    Examples Description

‍This application measures accelermeter and gyroscopic data and temperature.

The demo application is composed of two sections :

Application Init

‍Initialization driver init, reset chip and start configuration chip for measurement.

void application_init ( void )
{
log_cfg_t log_cfg;
uint8_t temp_write;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
ACCEL8_MAP_MIKROBUS( cfg, MIKROBUS_1 );
accel8_init( &accel8, &cfg );
log_printf( &logger, " *-* Device Reset *-* \r\n");
accel8_generic_write( &accel8, ACCEL8_REG_PWR_MGMT_1, &temp_write, 1 );
log_printf( &logger, " *-* Device Configuration *-* \r\n" );
Delay_ms ( 1000 );
log_printf( &logger, " --- Start Measurement --- \r\n" );
}
#define ACCEL8_GYRO_CFG_FULL_SCALE_RANGE_250dbs
Definition accel8.h:200
#define ACCEL8_INTE_DATA_RDY_ENABLE
Definition accel8.h:283
#define ACCEL8_MAP_MIKROBUS(cfg, mikrobus)
Definition accel8.h:66
#define ACCEL8_PM1_DEVICE_RESET
Definition accel8.h:332
void accel8_cfg_setup(accel8_cfg_t *cfg)
Config Object Initialization function.
void accel8_generic_write(accel8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void accel8_default_cfg(accel8_t *ctx, uint8_t accel_cfg, uint8_t gyro_cfg, range_retval_t *rng)
Click Default Configuration function.
ACCEL8_RETVAL accel8_init(accel8_t *ctx, accel8_cfg_t *cfg)
Initialization function.
#define ACCEL8_REG_SIGNAL_PATH_RESET
Definition accel8.h:162
#define ACCEL8_REG_PWR_MGMT_1
Definition accel8.h:164
#define ACCEL8_GYRO_RESET
Definition accel8.h:312
#define ACCEL8_TEMP_RESET
Definition accel8.h:314
#define ACCEL8_ACCEL_RESET
Definition accel8.h:313
void application_init(void)
Definition main.c:34
Click configuration structure definition.
Definition accel8.h:401

Application Task

‍Reads Accel X/Y/Z axis, Gyro X/Y/Z axis and device Temperature. All data logs on the USBUART every 2 sec.

void application_task ( void )
{
float temperature;
int16_t x_gyro_axis;
int16_t y_gyro_axis;
int16_t z_gyro_axis;
int16_t x_accel_axis;
int16_t y_accel_axis;
int16_t z_accel_axis;
// Task implementation.
accel8_get_accel_axis( &accel8,&x_accel_axis, &y_accel_axis, &z_accel_axis );
accel8_get_gyro_axis( &accel8, &x_gyro_axis, &y_gyro_axis, &z_gyro_axis );
temperature = accel8_get_temperature( &accel8 );
// LOGS DATA
log_printf( &logger, "________________ Accel 8 click _________________\r\n" );
log_printf( &logger, "| Data | X axis | Y axis | Z axis | Range |\r\n" );
log_printf( &logger, "|_________|________|________|________|_________|\r\n" );
log_printf( &logger, "| Accel | %d | %d | %d | %dg |\r\n", x_accel_axis, y_accel_axis, z_accel_axis, accel_range );
log_printf( &logger, "|_________|________|________|________|_________|\r\n" );
log_printf( &logger, "| Gyro | %d | %d | %d | %ddps|\r\n", x_gyro_axis, y_gyro_axis, z_gyro_axis, gyro_range );
log_printf( &logger, "|_________|________|________|________|_________|\r\n" );
log_printf( &logger, "| Temp | %.2f C |\r\n" , temperature);
log_printf( &logger, "|_________|_________________|\r\n" );
log_printf( &logger, " \r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
void accel8_get_accel_axis(accel8_t *ctx, int16_t *x_axis, int16_t *y_axis, int16_t *z_axis)
Functions for read Accel axis data.
void accel8_get_gyro_axis(accel8_t *ctx, int16_t *x_axis, int16_t *y_axis, int16_t *z_axis)
Functions for read Gyro axis data.
float accel8_get_temperature(accel8_t *ctx)
Functions for read Temperature data in C.
void application_task(void)
Definition main.c:80

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Accel8

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.