With a gyroscope, you can achieve responsive motion sensing capabilities, enabling devices to react to changes in orientation and movement quickly and accurately
A
A
Hardware Overview
How does it work?
Gyro 3 Click is based on the I3G4250, a three-axis digital gyroscope sensor IC from STMicroelectronics. This device is produced using a proprietary CMOS micromachining technology, which results in a high level of integration, allowing very good linearity over temperature, and increased output stability when no motion applied (referred to as a zero-rate level in the I3G4250 datasheet). It also makes it resistant to shocks, allowing it to be used for speeds up to 2000 dps. It supports signal conditioning including low and high-pass filtering, as well as the threshold detection on each axis. Typically, higher dps range results in lower sensitivity. Therefore, the I3G4250 allows to dynamically select the full-scale range (FSR) value in several discrete steps: ±245, ±500, 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. A high-accuracy 16-bit A/D converter sampled the MEMS output voltage, 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 I3G4250 datasheet, for every FS range, respectively. There are two filters available on the I3G4250 sensor: an external low-pass (LP) filter, and a digital high-pass (HP) filter with user-selectable cutoff frequency. Both of these signals 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 I3G4250 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 I3G4250 device can be configured to use the FIFO buffer in three different modes: Bypass mode, FIFO mode, and Stream mode. While the first mode allows the developer to read the values directly from the output registers, two other modes allow the utilization of the buffer. The FIFO mode will collect the data and stop collecting until its read (or reset), while the Streaming mode will continuously fill the buffer, discarding the oldest value. One of the two interrupt lines is labeled as DRDY/INT2 on the schematic, and it is routed to the mikroBUS™ AN pin (labeled as DI2). 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 STATUS register. The second interrupt line is used to report when the programmed threshold is reached. It is possible to detect events which are above or below a programmable threshold, and trigger an interrupt on the INT1 pin, routed to the mikroBUS™ INT pin. By directing the I3G4250 device to wait for a built-in timer to expire, a false triggering can be prevented. To detect an interrupt source, the MCU can should read the status of the respective flag bits from the INT1_SRC register. Gyro 3 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 I3G4250 slave I2C address. The Click board™ should be interfaced only with MCUs that use logic levels of 3.3V.
Features overview
Development board
SparkFun MicroMod mikroBUS Carrier board takes advantage of the MicroMod, Qwiic, and mikroBUS™ ecosystems making it easy to prototype with each combined rapidly. The MicroMod M.2 socket and mikroBUS™ 8-pin header allow users to experiment with any processor board in the MicroMod ecosystem and any Click board™ in the mikroBUS™ ecosystem,
respectively. This board also features two Qwiic connectors to seamlessly integrate hundreds of Qwiic sensors and accessories into your project. The mikroBUS™ socket comprises a pair of 8-pin female headers with a standardized pin configuration. The pins consist of three groups of communications pins (SPI, UART, and I2C), six additional pins (PWM, Interrupt, Analog input,
Reset, and Chip select), and two power groups (3.3V and 5V). While a modern USB-C connector makes programming easy, the Carrier Board is also equipped with an MCP73831 single-cell Lithium-Ion/Lithium-Polymer charge IC so you can charge an attached single-cell Li-Po battery. The charge IC receives power from the USB connection and can source up to 450mA to charge an attached battery.
Microcontroller Overview
MCU Card / MCU
Architecture
ARM Cortex-M4
MCU Memory (KB)
1024
Silicon Vendor
STMicroelectronics
Pin count
64
RAM (Bytes)
196608
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project 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.
Software Support
Library Description
This library contains API for Gyro 3 Click driver.
Key functions:
gyro3_get_temp
- This function reads value stored in temperature register (26h)gyro3_get_fifo_data_level
- This function reads data level value in FIFO register from FIFO SRC register (2Fh) and stores result in fifo_data_levelgyro3_get_axes
- This function reads values from XYZ axes registers and converts them to degrees per second value
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 Gyro3 Click example
*
* # Description
* This example shows values of the 3 axis from the gyroscope module.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes I2C driver, basic device configuration, I2C interface, LOG interface and GPIO pins.
*
* ## Application Task
* Checks if new data is available on all three axes, If yes then reads and logs their values.
*
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "gyro3.h"
// ------------------------------------------------------------------ VARIABLES
static gyro3_t gyro3;
static log_t logger;
static uint8_t status_register;
static float x_axis;
static float y_axis;
static float z_axis;
static const char degrees_celsius[ 3 ] = { ' ', 'C', 0 };
static const char degrees_per_second[ 7 ] = { ' ', 'd', 'e', 'g', '/', 's', 0 };
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
gyro3_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.
gyro3_cfg_setup( &cfg );
GYRO3_MAP_MIKROBUS( cfg, MIKROBUS_1 );
gyro3_init( &gyro3, &cfg );
gyro3_default_cfg( &gyro3 );
}
void application_task ( void )
{
// Task implementation.
gyro3_get_status( &gyro3, &status_register );
if ( ( status_register & GYRO3_ZYX_NEW_DATA_MASK ) == GYRO3_ZYX_NEW_DATA_MASK )
{
gyro3_get_axes( &gyro3, &x_axis, &y_axis, &z_axis, GYRO3_MEAS_RANGE_2000 );
log_printf( &logger, "\r\nx_axis : %.2f %s\t", x_axis, degrees_per_second );
log_printf( &logger, "y_axis : %.2f %s\t", y_axis, degrees_per_second );
log_printf( &logger, "z_axis : %.2f %s\r\n", z_axis, degrees_per_second );
}
Delay_ms( 1500 );
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END
Additional Support
Resources
Category:Motion