Intermediate
30 min

Break the limits of motion capture with ICM-20789 and PIC32MZ2048EFM100

Seamless motion capture, effortless precision: The 6DoF revolution

6DOF IMU 5 Click with Curiosity PIC32 MZ EF

Published Oct 07, 2023

Click board™

6DOF IMU 5 Click

Dev Board

Curiosity PIC32 MZ EF

Compiler

NECTO Studio

MCU

PIC32MZ2048EFM100

Our mission is to infuse your projects with the enchantment of 6-axis motion sensing, unlocking entirely new possibilities for them to interact seamlessly with the physical world

A

A

Hardware Overview

How does it work?

6DOF IMU 5 Click is based on the ICM-20789, a 6-axis inertial sensor (3-axis gyroscope and a 3-axis accelerometer), and ultra-low noise MEMS capacitive barometric pressure sensor from TDK InvenSense. ICM-20789 features a 4 KB FIFO that can lower the traffic on the serial bus interface. The digital output barometric pressure sensor is based on an ultra-low noise innovative MEMS capacitive technology that can measure pressure differences with an accuracy of ±1 Pa, an accuracy enabling altitude measurement differentials as small as 8.5 cm without the penalty of increased power consumption or reduced sensor throughput. The capacitive pressure sensor has a ±1 hPa absolute accuracy over its full range of 300 hPa -1100 hPa. The pressure sensor offers industry leading temperature stability of the pressure sensor with a temperature coefficient offset of ±0.5 Pa/°C, embedded temperature sensor and 400kHz I2C

bus for communication. The gyroscope has a programmable full-scale range of ±250 dps, ±500 dps, ±1000 dps, and ±2000 dps. The accelerometer has a user-programmable full-scale range of ±2g, ±4g, ±8g, and ±16g. Factory-calibrated initial sensitivity of both sensors reduces production-line calibration requirements. Other features include on-chip 16-bit ADCs, programmable digital filters, another embedded temperature sensor, and programmable interrupts. The device features I2C serial interface to access its registers at 400 kHz as well as at 8 MHz SPI. The onboard chip ICM-20789 requires stable voltage for power supply of input/output pins (VDDIO) at 1.8V which also supplies the pressure sensor. 6DOF IMU 5 click does all of the power supply regulations as well as the logic level translations needed for proper operation. The MCP1826, a 1000 mA Low Dropout (LDO) linear regulator provides high-current and

low-output voltage of 1.8V to all of the essential parts of the board, while TXB0106 and PCA9306 do the SPI and I2C signal level translations, respectively, between the MCU and the ICM-20789. Interacting with the 6-axis is possible through SPI communication protocol while the I2C bus allows access to pressure sensors 16-bit address space registers. This device is intended for implementation in Drones and Flying Toys, Motion-based gaming controllers, Virtual Reality Headsets & Controllers, Indoor/Outdoor Navigation (dead-reckoning, floor/elevation/step detection). This Click Board™ uses both I2C and SPI communication interfaces. It is designed to be operated only with 3.3V logic levels. A proper logic voltage level conversion should be performed before the Click board™ is used with MCUs with logic levels of 5V.

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

Features overview

Development board

Curiosity PIC32 MZ EF development board is a fully integrated 32-bit development platform featuring the high-performance PIC32MZ EF Series (PIC32MZ2048EFM) that has a 2MB Flash, 512KB RAM, integrated FPU, Crypto accelerator, and excellent connectivity options. It includes an integrated programmer and debugger, requiring no additional hardware. Users can expand

functionality through MIKROE mikroBUS™ Click™ adapter boards, add Ethernet connectivity with the Microchip PHY daughter board, add WiFi connectivity capability using the Microchip expansions boards, and add audio input and output capability with Microchip audio daughter boards. These boards are fully integrated into PIC32’s powerful software framework, MPLAB Harmony,

which provides a flexible and modular interface to application development a rich set of inter-operable software stacks (TCP-IP, USB), and easy-to-use features. The Curiosity PIC32 MZ EF development board offers expansion capabilities making it an excellent choice for a rapid prototyping board in Connectivity, IOT, and general-purpose applications.

Curiosity PIC32MZ EF double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
RPD4
CS
SPI Clock
RPD1
SCK
SPI Data OUT
RPD14
MISO
SPI Data IN
RPD3
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
RF13
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RPA14
SCL
I2C Data
RPA15
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

6DOF IMU 5 Click Schematic schematic

Step by step

Project assembly

Curiosity PIC32MZ EF front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity PIC32 MZ EF as your development board.

Curiosity PIC32MZ EF front image hardware assembly
Thermo 28 Click front image hardware assembly
Prog-cut hardware assembly
Curiosity PIC32 MZ EF 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 image step 5 hardware assembly
Necto image step 6 hardware assembly
Curiosity PIC32 MZ EF MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

Software Support

Library Description

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

Key functions:

  • c6dofimu5_power - This function turns the device on or off

  • c6dofimu5_read_gyroscope - This function is used to read gyroscope data

  • c6dofimu5_read_accelerometer - This function is used to read accelerometer data

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

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

#include "board.h"
#include "log.h"
#include "c6dofimu5.h"

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

static c6dofimu5_t c6dofimu5;
static log_t logger;

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

void application_init ( void )
{
    log_cfg_t log_cfg;
    c6dofimu5_cfg_t cfg;
    uint8_t id_val;

    /** 
     * 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.

    c6dofimu5_cfg_setup( &cfg );
    C6DOFIMU5_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    c6dofimu5_init( &c6dofimu5, &cfg );
    
    c6dofimu5_read_bytes ( &c6dofimu5, C6DOFIMU5_WHO_AM_I, &id_val, 1 );
    if ( id_val == C6DOFIMU5_WHO_AM_I_VAL )
    {
        log_printf( &logger, "-------------------------\r\n " );
        log_printf( &logger, "   6DOF  IMU  5  click   \r\n " );
        log_printf( &logger, "-------------------------\r\n " );
        c6dofimu5_power ( &c6dofimu5, C6DOFIMU5_POWER_ON );
    }
    else
    {   
        log_printf( &logger, "-------------------------\r\n " );
        log_printf( &logger, "     FATAL  ERROR!!!     \r\n " );
        log_printf( &logger, "-------------------------\r\n " );
        for ( ; ; );
    }

    c6dofimu5_default_cfg( &c6dofimu5 );
    c6dofimu5_baro_settings( &c6dofimu5 );

    log_printf( &logger, "    ---Initialised---    \r\n " );
    log_printf( &logger, "-------------------------\r\n " );

    Delay_ms( 100 );
}

void application_task ( void )
{
    float x_gyro;
    float y_gyro;
    float z_gyro;
    float x_accel;
    float y_accel;
    float z_accel;
    uint32_t raw_pres;
    uint16_t raw_temp;
    c6dofimu5_process_data_t process_data;

    c6dofimu5_acceleration_rate( &c6dofimu5, &x_accel, &y_accel, &z_accel );
    c6dofimu5_angular_rate( &c6dofimu5, &x_gyro, &y_gyro, &z_gyro );

    log_printf( &logger, " Accel X: %.2f \t Gyro X: %.2f\r\n", x_accel, x_gyro );
    log_printf( &logger, " Accel Y: %.2f \t Gyro Y: %.2f\r\n", y_accel, y_gyro );
    log_printf( &logger, " Accel Z: %.2f \t Gyro Z: %.2f\r\n", z_accel, z_gyro );
    
    log_printf( &logger, "-------------------------\r\n " );

    c6dofimu5_read_raw_data( &c6dofimu5, &raw_pres, &raw_temp );

    process_data.p_raw = raw_pres;
    process_data.t_raw = raw_temp;

    c6dofimu5_process_data( &c6dofimu5, &process_data );

    log_printf( &logger, "Pressure: %.2f mBar\r\n " , process_data.pressure * 0.01 );
    log_printf( &logger, "Temperature: %.2f Celsius\r\n " , process_data.temperature );

    log_printf( &logger, "-------------------------\r\n" );
    Delay_ms( 1000 );
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}

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