Beginner
10 min
0

Provide real-time data on pitch, roll, and yaw with LSM6DS33 and PIC18F2515

Unveiling the power of 6-axis IMU technology

6DOF IMU Click with EasyPIC v8

Published Nov 01, 2023

Click board™

6DOF IMU Click

Development board

EasyPIC v8

Compiler

NECTO Studio

MCU

PIC18F2515

Virtual reality enthusiasts can immerse themselves in lifelike experiences, thanks to 6-axis IMUs that track head movements with unparalleled accuracy

A

A

Hardware Overview

How does it work?

6DOF IMU Click is based on the LSM6DS33, a high-performance 6-axis inertial measurement unit comprising a 3-axis gyroscope and accelerometer from STMicroelectronics. The LSM6DS33 delivers more sophisticated, best-in-class motion sensing of orientation and gesture. It has a full-scale acceleration range of ±2/±4/±8/±16 g and an angular rate range of ±125/±250/±500/±1000/±2000dps, alongside a selectable communication interface with a data synchronization feature. It also features 8kB FIFO that can lower the traffic on the serial bus interface and reduce power consumption by allowing the system processor to burst read sensor data and then go into a low-power mode. The LSM6DS33's integrated power-efficient modes reduce the power consumption in high-performance mode, combining always-on low-power features with

superior sensing precision for an optimal motion experience, thanks to ultra-low noise performance for both the gyroscope and accelerometer. Thanks to its valuable characteristics, this Click board™ can be used in various applications like tilt sensing, pedometer/step-counter, 6D orientation, free-fall detection, tap/double-tap detection, indoor navigation, and many more. 6DOF IMU Click allows the use of both I2C and SPI interfaces with a maximum frequency of 400kHz for I2C and 10MHz for SPI communication. The selection can be made by positioning SMD jumpers labeled as COMM SEL in an appropriate position. Note that all the jumpers' positions must be on the same side, or the Click board™ may become unresponsive. While the I2C interface is selected, the LSM6DS33 allows choosing the least significant bit (LSB) of its I2C slave address using the SMD jumper labeled

ADDR SEL. The event-detection interrupts of the LSM6DS33, INT1, and INT2 are selectable through the SMD jumper labeled INT SEL and processed on the INT pin on the mikroBUS™ socket. It enables efficient and reliable motion tracking and contextual awareness, implementing hardware recognition of free-fall events, 6D orientation, tap and double-tap sensing, activity or inactivity, and wake-up events. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.

6DOF IMU Click hardware overview image

Features overview

Development board

EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the EasyPIC v8 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.

Communication options such as USB-UART, USB DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC v8 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.

EasyPIC v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

48

Silicon Vendor

Microchip

Pin count

28

RAM (Bytes)

3968

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
RA5
CS
SPI Clock
RC3
SCK
SPI Data OUT
RC4
MISO
SPI Data IN
RC5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
RB1
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RC3
SCL
I2C Data
RC4
SDA
NC
NC
5V
Ground
GND
GND
2

Take a closer look

Schematic

6DOF IMU Click Schematic schematic

Step by step

Project assembly

EasyPIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyPIC v8 as your development board.

EasyPIC v8 front image hardware assembly
Rotary B 2 Click front image hardware assembly
MCU DIP 28 hardware assembly
EasyPIC v8 28pin-DIP - 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
Necto image step 8 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

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for 6DOF IMU Click driver.

Key functions:

  • c6dofimu_read_axis_data - This function reads axis data for the gyroscope or the accelerometer from predefined data register addresses

  • c6dofimu_read_temperature - This function reads temperature data from predefined data registers

  • c6dofimu_digital_read_int - This function reads the digital signal from the INT pin

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 6DofImu Click example
 * 
 * # Description
 * This example showcases how to initalize and use the 6DOF IMU click. The click contains a 
 * 6-axis inertial measurement unit ( accelerometer + gyroscope ). After configuring the click
 * module for proper use, axis and temperature data will be measured every second.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * This function initializes and configures the click and logger modules. In order for the 
 * device to work well, proper data needs to be written to the measurement control
 * registers as is done in the default_cfg(...) function.
 * 
 * ## Application Task  
 * This function reads and displays temperature and accelerometer/gyroscope axis data from
 * predefined registers. There is a 1 second delay between every read from the data output
 * registers.
 * 
 * *note:* 
 * <WARNING> If you write data to any of the "reserved" register addresses, you can permanently
 * damage the chip. If you are feeling adventurous, read the LSM6DS33 chip datasheet. 
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "c6dofimu.h"

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

static c6dofimu_t c6dofimu;
static log_t logger;

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

void application_init ( )
{
    log_cfg_t log_cfg;
    c6dofimu_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 ----" );
    Delay_100ms( );

    //  Click initialization.

    c6dofimu_cfg_setup( &cfg );
    C6DOFIMU_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    c6dofimu_init( &c6dofimu, &cfg );
    Delay_ms( 100 );
    c6dofimu_default_cfg( &c6dofimu );
    log_info( &logger, "---- Click Init ----" );
}

void application_task ( )
{
    float temperature; 

    c6dofimu_read_axis_data( &c6dofimu, C6DOFIMU_ACCEL_READ_MODE );
//     Delay_1sec( );
    c6dofimu_read_axis_data( &c6dofimu, C6DOFIMU_GYRO_READ_MODE );
//     Delay_1sec( );
    temperature = c6dofimu_read_temperature( &c6dofimu );

    log_printf( &logger, "--------------------------------------------\r\n" );
    log_printf( &logger, " * ACCEL * X: %d Y: %d Z: %d\r\n", c6dofimu.accel_axis.x,
                                                                   c6dofimu.accel_axis.y,
                                                                   c6dofimu.accel_axis.z );
    log_printf( &logger, " * GYRO * X: %d Y: %d Z: %d\r\n", c6dofimu.gyro_axis.x,
                                                                  c6dofimu.gyro_axis.y,
                                                                  c6dofimu.gyro_axis.z );
    log_printf( &logger, " * Temperature: %.2f C\r\n", temperature );
    Delay_ms( 500 );
}

void main ( )
{
    application_init( );

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

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

Additional Support

Resources