Intermediate
30 min

Provide insights into balance and movement with ITG-3701 and PIC18LF4550

Spin the future

Gyro 5 Click with EasyPIC v7

Published Nov 01, 2023

Click board™

Gyro 5 Click

Dev Board

EasyPIC v7

Compiler

NECTO Studio

MCU

PIC18LF4550

Navigate the future of augmented reality and virtual environments with our gyroscope, delivering lifelike interactions and immersive simulations

A

A

Hardware Overview

How does it work?

Gyro 5 Click is based on the ITG-3701, a three-axis digital gyroscope sensor from TDK InvenSense. This device features factory calibrated scale factor, High cross-axis isolation via proprietary MEMS design and a precision clock with 1% drift from -40°C to 85°C, which results in a high level of integration, allowing very good linearity over temperature, and increased output stability when no motion. It also makes it resistant to shocks up to 10,000g, allowing it to be used for speeds up to 4000 dps. It supports signal conditioning including low-pass filtering, as well as the programmable interrupt. Typically, higher dps range results in lower sensitivity. Therefore, the ITG-3701 allows to dynamically select the full-scale range (FSR) value in several discrete steps: ±500, ±1000, ±2000 and ±2000 dps. This allows optimized performance for a given usage scenario. For example, if used in applications with faster angle rates such as sports equipment monitoring (golf club or tennis racket), a higher FSR might be required, at a cost of lower sensitivity. The MEMS output voltage is sampled by a high-accuracy 16-bit A/D converter, allowing the output in 2’s complement format. As mentioned above, different FS ranges have different sensitivity per

LSB. Therefore, raw output values of the sensor will have to be multiplied with the sensitivity to obtain the values in degrees per second (dps). These values can be obtained from the ITG-3701 datasheet, for every FS range, respectively. The ITG-3701 sensor feature an internal programmable low-pass filter, with user-selectable cutoff frequency. The output signal can be digitally selected and applied to an angular speed measurement, allowing the developer to reduce the noise or fine-tune the sensitivity within a desired bandwidth. The ITG-3701 device features a FIFO buffer, which in combination with a dedicated interrupt line, allows firmware optimizations while reducing the power consumption of the application as a result. The FIFO buffer has 32 slots, each 16-bit wide, used to store output values. The FIFO 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. A FIFO counter keeps track of how many bytes of valid data are contained in the FIFO. The FIFO register supports burst reads, while the interrupt function may be used to determine when new data is available. The interrupt pin is

routed to the mikroBUS™ INT pin (labeled as INT). This line is used to report one of the programmable FIFO events: watermark level is reached, FIFO buffer is empty, and there is an overrun event on the FIFO buffer (FIFO is full). The pin can also be used to report when there is a new data available at the output after the conversion period (data ready). To find out which event exactly has occurred, the host MCU should read the status of the respective flag bits from the INT_STATUS register. Gyro 5 click offers two communication interfaces. It can be used with either I2C or SPI. The onboard SMD jumpers labeled as COMM SEL allow switching between the two interfaces. Note that all the jumpers have to be positioned either I2C or to SPI position. When I2C interface is selected, an additional SMD jumper labeled as ADDR SEL becomes available, determining the least significant bit of the ITG-3701 slave I2C address. The Click board™ can operate with 3.3V MCUs only, it is set to work over the I2C by default, and it is already equipped with the pull-up resistors. It is ready to be used as soon as it is inserted into a mikroBUS™ socket of the development system.

Gyro 5 Click top side image
Gyro 5 Click bottom side image

Features overview

Development board

EasyPIC v7 is the seventh generation of PIC development boards specially designed to develop embedded applications rapidly. It supports a wide range of 8-bit PIC microcontrollers from Microchip and has a broad set of unique functions, such as a powerful onboard mikroProg programmer and In-Circuit debugger over USB-B. 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, EasyPIC v7 allows you to connect accessory boards, sensors, and custom electronics more efficiently than ever. Each part of

the EasyPIC 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 various external power sources, including an external 12V power supply, 7-23V AC or 9-32V 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. These sockets cover a wide range of 8-bit PIC MCUs, from PIC10F, PIC12F, PIC16F, PIC16Enh, PIC18F, PIC18FJ, and PIC18FK families. EasyPIC 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.

EasyPIC v7 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

2048

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
RE0
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
RB0
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RC3
SCL
I2C Data
RC4
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Gyro 5 Click Schematic schematic

Step by step

Project assembly

EasyPIC v7 front image hardware assembly

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

EasyPIC v7 front image hardware assembly
Buck 22 Click front image hardware assembly
MCU DIP 40 hardware assembly
EasyPIC 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

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.

Software Support

Library Description

This library contains API for Gyro 5 Click driver.

Key functions:

  • gyro5_get_axes - Getting gyroscope axes values

  • gyro5_get_temperature - Getting temperature value

  • gyro5_default_cfg - Click Default Configuration function

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 Gyro5 Click example
 * 
 * # Description
 * This application shows temperature and gyroscope axes values
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes GPIO pins, I2C and LOG modules.
 * 
 * ## Application Task  
 * Checks data ready INT, gets temperature and axes data and LOGs those values
 * 
 * \author Luka Filipovic
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "gyro5.h"

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

static gyro5_t gyro5;
static log_t logger;

uint8_t data_ready_flag;
float temperature_value;

float x_axis_value;
float y_axis_value;
float z_axis_value;

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

void application_init ( void )
{
    log_cfg_t log_cfg;
    gyro5_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.

    gyro5_cfg_setup( &cfg );
    GYRO5_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    gyro5_init( &gyro5, &cfg );
    gyro5_default_cfg ( &gyro5 );
    Delay_ms( 1000 );
    
    log_printf( &logger, "      Gyro 5 Click\r\n" );
    log_printf( &logger, "-----------------------\r\n" );
}

void application_task ( void )
{
    //  Task implementation.
    
    data_ready_flag = gyro5_int_status( &gyro5, GYRO5_INT_DATA_RDY );
    
    if ( data_ready_flag == GYRO5_STATUS_INT_DATA_RDY )
    {
        gyro5_get_temperature( &gyro5, &temperature_value );
        Delay_ms( 10 );
        gyro5_get_axes(  &gyro5, &x_axis_value, &y_axis_value, &z_axis_value );
        Delay_ms( 10 );
        log_printf( &logger, " Temperature = %.2f C\r\n", temperature_value );
        log_printf( &logger, " X axis = %.2f \r\n", x_axis_value );
        log_printf( &logger, " Y axis = %.2f \r\n", y_axis_value );
        log_printf( &logger, " Z axis = %.2f \r\n", z_axis_value );
        log_printf( &logger, "------------------------\r\n" );
        Delay_ms( 2000 );
    }
}

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.