Intermediate
30 min

Empower your projects with the magic of 6DoF IMU using BMI270 and ATmega644P

Move beyond limits: Unleash the power of 6-axis motion sensing

6DOF IMU 12 Click with EasyAVR v7

Published Oct 07, 2023

Click board™

6DOF IMU 12 Click

Dev. board

EasyAVR v7

Compiler

NECTO Studio

MCU

ATmega644P

Our 6DoF IMU solution is designed to revolutionize motion tracking, offering unparalleled accuracy and responsiveness for a wide range of applications

A

A

Hardware Overview

How does it work?

6DOF IMU 12 Click is based on the BMI270, an ultra-low-power IMU optimized for wearable applications from Bosch Sensortec. The IMU combines precise acceleration and angular rate measurement with intelligent on-chip motion-triggered interrupt features. The 6-axis sensor combines a 16-bit triaxial gyroscope and a 16-bit triaxial accelerometer in a compact 2.5x3.0x0.8mm LGA package. BMI270 is a member of Bosch Sensortec’s BMI260 family of IMUs, targeting fast and accurate inertial sensing in wearable applications. It also features Bosch’s automotive-proven gyroscope technology with an improved accelerometer. Significant improvements in BMI270 include, but are not restricted to, the overall accelerometer performance, i.e. an extremely low zero-g offset and sensitivity error, low temperature drifts, robustness over PCB strain and a low noise density. It also features the industry’s first self-calibrating gyroscope using motionless CRT (Component Re-Trimming) functionality to compensate MEMS typical soldering drifts, ensuring post-soldering sensitivity

errors down to ± 0.4%. BMI270 includes intuitive gesture, context and activity recognition with an integrated plug-and-play step counter/detector, which is optimized for accurate step counting in wrist-worn devices. The IMU is also well suited for other types of wearable devices, such as hearables, smart clothes, smart shoes, smart glasses and ankle bands. The smart IMU has a wide range for VDD and VDDIO supply voltages. The performance and current consumption are stable over the entire supply range. Typical current draw for BMI270’s accelerometer and gyroscope at full ODR of 6.4 kHz is under 700μA. By enabling high output data rates with low current consumption, wearable manufacturers can avoid an unpleasant aliasing effect – an effect that causes different signals to become indistinguishable when sampled at lower ODRs. Bosch Sensortec’s ultra-low-power IMU BMI270 provides an intelligent power management system enabling motion-triggered always-on features to run inside the ultra-low-power domain of the IMU. BMI270 significantly extends system battery life by

handling multiple activity tracking, step counting and gesture recognition functions independently of the main system processor, without having to wake it up. The processor-independent functions include tasks such as sending an interrupt when a certain number of steps is reached, or geofencing to activate GPS when the user stands up and starts walking. The device features I2C and SPI serial interfaces, a VDD operating range from 1.71V to 3.6V, and a separate digital IO supply (VDDIO) from 1.2V to 3.6V. Communication with all registers of the device can be performed using either SPI at 10MHz or I2C at up to 1MHz. 6DOF IMU 12 Click supports both SPI and I2C communication interfaces, allowing it to be used with a wide range of different MCUs. The communication interface can be selected by moving SMD jumpers grouped under the COM SEL to an appropriate position (SPI or I2C). The slave I2C address can also be configured by an SMD jumper when the Click board™ is operated in the I2C mode. An SMD jumper labeled as ADD SEL is used to set the least significant bit (LSB) of the I2C address.

6DOF IMU 12 Click top side image
6DOF IMU 12 Click bottom side image

Features overview

Development board

EasyAVR v7 is the seventh generation of AVR development boards specially designed for the needs of rapid development of embedded applications. It supports a wide range of 16-bit AVR microcontrollers from Microchip and has a broad set of unique functions, such as a powerful onboard mikroProg programmer and In-Circuit debugger over USB. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyAVR v7 allows you to connect accessory boards, sensors, and custom electronics more

efficiently than ever. Each part of the EasyAVR v7 development board contains the components necessary for the most efficient operation of the same board. An integrated mikroProg, a fast USB 2.0 programmer with mikroICD hardware In-Circuit Debugger, offers many valuable programming/debugging options and seamless integration with the Mikroe software environment. Besides it also includes a clean and regulated power supply block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-12V AC or 9-15V DC via DC connector/screw terminals, and a power source via the USB Type-B (USB-B)

connector. Communication options such as USB-UART and RS-232 are also included, alongside the well-established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets which cover a wide range of 16-bit AVR MCUs. EasyAVR v7 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

EasyAVR v7 horizontal image

Microcontroller Overview

MCU Card / MCU

Architecture

AVR

MCU Memory (KB)

64

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

4096

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
PA5
CS
SPI Clock
PB7
SCK
SPI Data OUT
PB6
MISO
SPI Data IN
PB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Interrupt 2
PD4
PWM
Interrupt 1
PD2
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PC0
SCL
I2C Data
PC1
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

6DOF IMU 12 Click Schematic schematic

Step by step

Project assembly

EasyAVR v7 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyAVR v7 as your development board.

EasyAVR v7 front image hardware assembly
Buck 22 Click front image hardware assembly
MCU DIP 40 hardware assembly
EasyAVR v7 MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto DIP image step 7 hardware assembly
EasyPIC PRO v7a Display Selection Necto Step hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for 6DOF IMU 12 Click driver.

Key functions:

  • c6dofimu12_check_id - Function check status initialization of the device of BMI270 6-axis, smart, low-power Inertial Measurement on 6DOF IMU 12 Click

  • c6dofimu12_check_init_status - Function check status initialization of the device of BMI270 6-axis, smart, low-power Inertial Measurement on 6DOF IMU 12 Click

  • c6dofimu12_get_data - Function reads Accel and Gyro 16-bit ( signed ) X-axis, Y-axis data and Z-axis data from the 12 targeted starts from C6DOFIMU12_REG_ACC_X_LSB_ADDR register address of BMI270 6-axis, smart, low-power Inertial Measurement on 6DOF IMU 12 Click

Open Source

Code example

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.

/*!
 * \file 
 * \brief C6DofImu12 Click example
 * 
 * # Description
 * This example demonstrates the use of 6DOF IMU 12 Click board.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes the driver and checks the communication then initializes the device 
 * and sets the device default configuration.
 * 
 * ## Application Task  
 * Measures acceleration and gyroscope data and displays the results on USB UART each second.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "c6dofimu12.h"
#include "c6dofimu12_config.h"

// ------------------------------------------------------------------ VARIABLES

static c6dofimu12_t c6dofimu12;
static c6dofimu12_accel_t c6dofimu12_accel;
static c6dofimu12_gyro_t c6dofimu12_gyro;

static log_t logger;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    uint8_t tx_buf;

    log_cfg_t log_cfg;
    c6dofimu12_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_info( &logger, "---- Application Init ----" );

    //  Click initialization.

    c6dofimu12_cfg_setup( &cfg );
    C6DOFIMU12_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    c6dofimu12_init( &c6dofimu12, &cfg );
    Delay_ms ( 100 );

    log_printf( &logger, " Driver init done \r\n" );
    log_printf( &logger, "----------------------------------\r\n");
    
    if ( c6dofimu12_check_id( &c6dofimu12 ) == C6DOFIMU12_SUCCESS )
    {
        log_printf( &logger, "  Communication OK\r\n" );
        log_printf( &logger, "----------------------------------\r\n");
    }
    else
    {
        log_printf( &logger, " Communication ERROR\r\n" );
        log_printf( &logger, " Reset the device\r\n" );
        log_printf( &logger, "----------------------------------\r\n");

        for ( ; ; );
    }
    
    tx_buf = C6DOFIMU12_PWR_CONF_ADV_PWR_SAVE_DISABLED | 
             C6DOFIMU12_FIFO_READ_DISABLED | 
             C6DOFIMU12_FAST_PWR_UP_DISABLED;
    c6dofimu12_generic_write( &c6dofimu12, C6DOFIMU12_REG_PWR_CONF_ADDR, &tx_buf, 1 );
    Delay_ms ( 100 );
    tx_buf = C6DOFIMU12_CMD_INITIALIZATION_START;
    c6dofimu12_generic_write( &c6dofimu12, C6DOFIMU12_REG_INIT_CTRL_ADDR, &tx_buf, 1 );
    Delay_ms ( 100 );
    c6dofimu12_generic_write( &c6dofimu12, C6DOFIMU12_REG_INIT_DATA_ADDR, bmi270_config_file, 8192 );
    Delay_ms ( 100 );
    tx_buf = C6DOFIMU12_CMD_INITIALIZATION_STOP;
    c6dofimu12_generic_write( &c6dofimu12, C6DOFIMU12_REG_INIT_CTRL_ADDR, &tx_buf, 1 );
    Delay_ms ( 100 );

    if ( c6dofimu12_check_init_status( &c6dofimu12 ) == C6DOFIMU12_SUCCESS )
    {
        log_printf( &logger, " Initialization completed\r\n" );
        log_printf( &logger, "----------------------------------\r\n");
    }
    else
    {
        log_printf( &logger, " Initialization ERROR\r\n" );
        log_printf( &logger, " Reset the device\r\n" );
        log_printf( &logger, "----------------------------------\r\n");
        
        for( ; ; );
    }
    c6dofimu12_default_cfg( &c6dofimu12 );
    Delay_ms ( 100 );
}

void application_task ( void )
{
    c6dofimu12_get_data( &c6dofimu12, &c6dofimu12_accel, &c6dofimu12_gyro );

    log_printf( &logger, " Accel X: %d | Gyro X: %d\r\n", c6dofimu12_accel.x, c6dofimu12_gyro.x );
    log_printf( &logger, " Accel Y: %d | Gyro Y: %d\r\n", c6dofimu12_accel.y, c6dofimu12_gyro.y );
    log_printf( &logger, " Accel Z: %d | Gyro Z: %d\r\n", c6dofimu12_accel.z, c6dofimu12_gyro.z );
    log_printf( &logger, "----------------------------------\r\n");
    Delay_ms ( 1000 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}


// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.