c6dofimu22  2.1.0.0
Main Page

6DOF IMU 22 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : Nov 2023.
  • Type : I2C/SPI type

Software Support

We provide a library for the 6DOF IMU 22 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 6DOF IMU 22 Click driver.

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of 6DOF IMU 22 click board by reading and displaying

the accelerometer and gyroscope data (X, Y, and Z axis) as well as a temperature measurement in degrees Celsius.

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;
c6dofimu22_cfg_t c6dofimu22_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
c6dofimu22_cfg_setup( &c6dofimu22_cfg );
C6DOFIMU22_MAP_MIKROBUS( c6dofimu22_cfg, MIKROBUS_1 );
err_t init_flag = c6dofimu22_init( &c6dofimu22, &c6dofimu22_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( C6DOFIMU22_ERROR == c6dofimu22_default_cfg ( &c6dofimu22 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Waits for a data ready indication and then reads the accelerometer, gyroscope, and temperature measurements.

The results are displayed on the USB UART every 80ms as per the accel and gyro output data rate which is set to 12.5 Hz.

void application_task ( void )
{
static c6dofimu22_data_t meas_data;
if ( !c6dofimu22_get_int1_pin ( &c6dofimu22 ) )
{
c6dofimu22_clear_data_ready ( &c6dofimu22 );
if ( C6DOFIMU22_OK == c6dofimu22_read_data ( &c6dofimu22, &meas_data ) )
{
log_printf ( &logger, " Accel X: %.2f g\r\n", meas_data.accel.x );
log_printf ( &logger, " Accel Y: %.2f g\r\n", meas_data.accel.y );
log_printf ( &logger, " Accel Z: %.2f g\r\n", meas_data.accel.z );
log_printf ( &logger, " Gyro X: %.1f dps\r\n", meas_data.gyro.x );
log_printf ( &logger, " Gyro Y: %.1f dps\r\n", meas_data.gyro.y );
log_printf ( &logger, " Gyro Z: %.1f dps\r\n", meas_data.gyro.z );
log_printf ( &logger, " Temperature: %.2f C\r\n\n", meas_data.temperature );
}
}
}

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.6DOFIMU22

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.


c6dofimu22_axes_t::z
float z
Definition: c6dofimu22.h:515
c6dofimu22_data_t::accel
c6dofimu22_axes_t accel
Definition: c6dofimu22.h:526
C6DOFIMU22_MAP_MIKROBUS
#define C6DOFIMU22_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: c6dofimu22.h:422
c6dofimu22_read_data
err_t c6dofimu22_read_data(c6dofimu22_t *ctx, c6dofimu22_data_t *data_out)
6DOF IMU 22 read data function.
c6dofimu22_cfg_t
6DOF IMU 22 Click configuration object.
Definition: c6dofimu22.h:485
c6dofimu22_data_t::temperature
float temperature
Definition: c6dofimu22.h:527
c6dofimu22_clear_data_ready
err_t c6dofimu22_clear_data_ready(c6dofimu22_t *ctx)
6DOF IMU 22 clear data ready function.
C6DOFIMU22_ERROR
@ C6DOFIMU22_ERROR
Definition: c6dofimu22.h:538
application_task
void application_task(void)
Definition: main.c:68
c6dofimu22_axes_t::x
float x
Definition: c6dofimu22.h:513
c6dofimu22_get_int1_pin
uint8_t c6dofimu22_get_int1_pin(c6dofimu22_t *ctx)
6DOF IMU 22 get int1 pin function.
c6dofimu22_default_cfg
err_t c6dofimu22_default_cfg(c6dofimu22_t *ctx)
6DOF IMU 22 default configuration function.
c6dofimu22_s
6DOF IMU 22 Click context object.
Definition: c6dofimu22.h:459
c6dofimu22_data_t
6DOF IMU 22 Click data structure.
Definition: c6dofimu22.h:524
c6dofimu22_data_t::gyro
c6dofimu22_axes_t gyro
Definition: c6dofimu22.h:525
c6dofimu22_cfg_setup
void c6dofimu22_cfg_setup(c6dofimu22_cfg_t *cfg)
6DOF IMU 22 configuration object setup function.
C6DOFIMU22_OK
@ C6DOFIMU22_OK
Definition: c6dofimu22.h:537
application_init
void application_init(void)
Definition: main.c:31
c6dofimu22_axes_t::y
float y
Definition: c6dofimu22.h:514
c6dofimu22_init
err_t c6dofimu22_init(c6dofimu22_t *ctx, c6dofimu22_cfg_t *cfg)
6DOF IMU 22 initialization function.