An extensive interrupt engine with two output pins, along with the 192 bytes long FIFO buffer allows software optimization and reduced microcontroller unit (MCU) workload. An integrated 8-bit thermal sensor allows temperature compensation, although the device already has very low sensitivity temperature coefficients. Gyro 2 click is ready to be used right out of the box for a wide range of applications which rely on an accurate angular rate sensor. This includes gyro-stabilization for various types of robots, drones, UAVs and RC vehicles, game controllers, orientation sensing, gesture-based HMI applications, VR glasses, and similar types of applications.
How does it work?
Gyro 2 click features the FXAS21002C, a three-axis integrated angular rate gyroscope, by NXP. This device offers many advantages, compared to similar devices on the market. The key feature of this integrated gyroscope is its very good sensitivity-to-range ratio, which allows fairly high sensitivity, even when used with fast angle rates, up to 2000 °/s (degrees per second). Typically, increased range means lower sensitivity. Therefore, the FXAS21002C allows to dynamically select the full-scale range (FSR) value in several discrete steps: ±250, ±500, ±1000, and ±2000 °/s. This allows to optimize the 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. An additional FSR boost function allows doubling of the selected FSR at the expense of somewhat alleviated noise and nonlinearity, when used in applications with even higher angular rates, allowing angle rate detection up to ±4000 °/s.
The FXAS21002C employs advanced MEMS sensors for XY and Z axes, sampled by a low-noise 16-bit A/D converter. The ADC input signal is conditioned by the lowpass filter, reducing the input noise. The angle rate is reported in 2’s complement format, as 16-bit value for each axis, over the I2C or SPI interface, selectable by the user. An integrated temperature sensor provides 8-bit ambient temperature data in 2’s complement format, allowing the thermal compensation. However, the device already has very low sensitivity temperature coefficients ranging from 0.01% to 0.08% per °C.
This device has an extensive programmable interrupt engine. There are two dedicated pins (INT1 and INT2/PWR_CTRL) which can output the selected logic state when the chosen interrupt event is detected. An interrupt event can be selected among sevral different sources: data ready, rate threshold, and a FIFO buffer event. The data ready event can be used to alert the host MCU that there’s data to be read on the output data buffer. The angle rate threshold can be set by the user, and if this threshold is exceeded on any of the axes after a debouncing period, the interrupt event will be triggered. Interrupt pins INT1 and INT2/PWR_CTRL are routed to the mikroBUS™ PWM and INT pins, labeled as RDY and INT.
The FXAS21002C offers several power modes, allowing reduced power consumption in power sensitive applications. It can operate in the Standby, Ready, and Active mode. The power mode of the device can be either programmed over the communication interface, or by utilizing the INT2/PWR CTRL pin. For the detailed information about selecting the operating mode, please consult the FXAS21002C datasheet.
The RST pin is used to apply a hardware reset of the FXAS21002C. This pin is active LOW. It is pulled to a HIGH logic level by the onboard resistor, ensuring that there is a HIGH logic state on the pin while the Click board™ is operated.
The FIFO buffer can also trigger an interrupt event, allowing the host MCU to enter the sleep mode, waking it up only when there’s enoug data accumulated. It can also be used to reduce the traffic on the communication lines. The FIFO buffer is 192 bytes long, which translates to 32 X/Y/Z samples. The FIFO buffer can operate in either CIRCULAR mode or in the STOP mode, allowing the data to either be continously collected, discarding the oldest values, or to stop the data collection once the buffer is full. A so-called watermark interrupt can be triggered when the FIFO buffer is filled with a certain number of samples. This threshold is also programmable by the user.
This digital gyroscope IC offers both I2C and SPI communication interfaces. As mentioned above, the user is free to select the desired communication protocol by moving SMD jumpers on the Click board™ grouped under the SEL COMM label. Please note that all jumpers need to be moved to the same position: either SPI or I2C. When using the I2C interface, the slave address can be changed by moving the I2C ADD jumper. This jumper selects the LSB of the 7-bit I2C address. In addition to this, the I2C_B/SPI pin routed to the mikroBUS™ CS pin should be pulled HIGH in order to select the SPI interface, or LOW to select the I2C interface. This is the pin that actually commands the FXAS21002C to use the specified communication interface, while SMD jumpers only provide required hardware connections. Also note that when using the SPI interface, the usual SPI Chip Select (SPI_CS_B) pin is routed to the AN pin of the mikroBUS™, and when the FXAS21002C is operated in I2C mode, this pin should be held to a HIGH logic level for a proper operation. However, Gyro 2 click is shipped with the mikroSDK compatible library which contains functions that take care of the proper pin assignment, as well as for the angle rate data reading, mode selection, initialization, and other chip-specific functions. There is also an example, where these functions are demonstrated in practical use.
Specifications
Type
Gyroscope,Motion
Applications
It can be used to develop applications for gyro-stabilization of diferent types of robots, drones, UAVs and RC vehicles, game controllers, orientation sensing, gesture-based HMI applications, VR glasses, and similar types of applications.
On-board modules
FXAS21002C, a three-axis integrated angular rate gyroscope, by NXP
Key Features
Advanced interrupt engine allows simplified firmware development and better system-wide power consumption, a very good sensitivity-to-range ratio, allowing it to achieve the resolution of 0.0625 °/s, while operating in the ±2000 °/s FSR mode, FIFO buffer for reduced communications traffic and improved power saving, and more
Interface
I2C,SPI
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
M (42.9 x 25.4 mm)
Input Voltage
3.3V
Pinout diagram
This table shows how the pinout on Gyro 2 Click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
LD1 | PWR | – | Power LED indicator |
JP1-JP3 | SEL COMM | Right | Communication interface selection:left position SPI, right position I2C |
JP4 | I2C ADD | Right | I2C address LSB selection: left position 0, right position 1 |
Software support
We provide a library for the Gyro 2 click on our LibStock page, as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Library Description
The library provides generic functions for working with the click board.
Key functions:
uint8_t gyro2_getId()
- Function for reading the ID register of the click board.
void gyro2_getAxisraw(int16_t *axisData)
- Function for reading the raw axis data from the click board.
void gyro2_calcAxis(int16_t *axisData)
- Function for calculating the axis data.
Examples description
The application is composed of the three sections :
- System Initialization – Initialize the GPIO and communication structures.
- Application Initialization – Initialize the communication interface and configure the click board.
- Application Task – Read the x,y,z and temperature data from the click board and display the resoults on the serial port.
void applicationTask() { char text[10]; int16_t axisData[3]; char state; char temperature; gyro2_getAxisraw(&axisData[0]); gyro2_calcAxis(&axisData[0]); IntToStr(axisData[0],&text[0]); Ltrim(&text[0]); mikrobus_logWrite("x: ",_LOG_TEXT); mikrobus_logWrite(&text[0],_LOG_LINE); IntToStr(axisData[1],&text[0]); Ltrim(&text[0]); mikrobus_logWrite("y: ",_LOG_TEXT); mikrobus_logWrite(&text[0],_LOG_LINE); IntToStr(axisData[2],&text[0]); Ltrim(&text[0]); mikrobus_logWrite("z: ",_LOG_TEXT); mikrobus_logWrite(&text[0],_LOG_LINE); temperature=gyro2_readTemperature(); ByteToStr(temperature,&text[0]); Ltrim(&text[0]); mikrobus_logWrite("Temperature: ",_LOG_TEXT); mikrobus_logWrite(&text[0],_LOG_TEXT); mikrobus_logWrite(" °C",_LOG_LINE); mikrobus_logWrite("++",_LOG_LINE); Delay_ms(200); }
The full application code, and ready to use projects can be found on our LibStock page.
Other mikroE Libraries used in the example:
Conversions Library
C_String Library
UART Library
I2C Library
SPI Library
Additional notes and information
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.
mikroSDK
This click board is supported with mikroSDK - MikroElektronika Software Development Kit. To ensure proper operation of mikroSDK compliant click board demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.
For more information about mikroSDK, visit the official page.