Skip to content

Latest commit

 

History

History

6dofimu2

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

6DOF IMU 2 Click

6DOF IMU 2 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Mihajlo Djordjevic
  • Date : Dec 2019.
  • Type : I2C/SPI type

Software Support

Example Description

Example Code presents acceleration and angular rate (gyroscopic) measurement.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.6DofImu2

Example Key Functions

  • c6dofimu2_cfg_setup Config Object Initialization function.
void c6dofimu2_cfg_setup ( c6dofimu2_cfg_t *cfg );
  • c6dofimu2_init Initialization function.
err_t c6dofimu2_init ( c6dofimu2_t *ctx, c6dofimu2_cfg_t *cfg );
  • c6dofimu2_default_cfg Click Default Configuration function.
void c6dofimu2_default_cfg ( c6dofimu2_t *ctx );
  • c6dofimu2_default_cfg This function executes default configuration for 6DOF IMU 2 Click.
void c6dofimu2_default_cfg ( c6dofimu2_t *ctx, c6dofimu2_cfg_t *cfg );
  • c6dofimu2_read_accel This function read Accel X-axis, Y-axis and Z-axis.
void c6dofimu2_read_accel ( c6dofimu2_t *ctx, c6dofimu2_accel_data_t *accel_data );
  • c6dofimu2_read_gyro This function read Gyro X-axis, Y-axis and Z-axis.
void c6dofimu2_read_gyro ( c6dofimu2_t *ctx, c6dofimu2_gyro_data_t *gyro_data );

Application Init

Application Init performs Logger and Click initialization.

void application_init ( void )
{
    log_cfg_t log_cfg;
    c6dofimu2_cfg_t cfg;

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_printf( &logger, "--------------------------\r\n\n" );
    log_printf( &logger, "     Application  Init\r\n" );
    Delay_ms ( 100 );

    //  Click initialization.

    c6dofimu2_cfg_setup( &cfg );
    C6DOFIMU2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    c6dofimu2_init( &c6dofimu2, &cfg );
    
    log_printf( &logger, "--------------------------\r\n\n" );
    log_printf( &logger, " --- 6DOF IMU 2 Click ---\r\n" );
    log_printf( &logger, "--------------------------\r\n\n" );
    Delay_ms ( 100 );
    
    c6dofimu2_default_cfg( &c6dofimu2, &cfg );
    Delay_ms ( 100 );
    
    log_printf( &logger, " ---- Initialization ---\r\n" );
    log_printf( &logger, "--------------------------\r\n\n" );
    Delay_ms ( 100 );
}

Application Task

This is an example which demonstrates the usage of 6DOF IMU 2 Click board. It measures accel and gyro coordinates (X,Y,Z) and then the results are being sent to the UART Terminal where you can track their changes for every 1 sec.

void application_task ( void )
{
    c6dofimu2_read_accel( &c6dofimu2, &accel_data );
    Delay_ms ( 100 );
    c6dofimu2_read_gyro( &c6dofimu2, &gyro_data );
    Delay_ms ( 100 );
    
    log_printf( &logger, "    Accel    |    Gyro    \r\n" );
    log_printf( &logger, "--------------------------\r\n" );
    log_printf( &logger, " X = %d  | X = %d \r\n", accel_data.accel_x, gyro_data.gyro_x );
    log_printf( &logger, " Y = %d  | Y = %d \r\n", accel_data.accel_y, gyro_data.gyro_y );
    log_printf( &logger, " Z = %d  | Z = %d \r\n", accel_data.accel_z, gyro_data.gyro_z );
    log_printf( &logger, "--------------------------\r\n" );    
    Delay_ms ( 1000 );
}

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.