Beginner
10 min

Achieve accurate measurement of vertical velocity with FXLS8974CF, MPL3115A2 and STM32F407VGT6

Measure the speed at which an object is ascending or descending vertically

Accel&Pressure Click with Clicker 4 for STM32F4

Published Jan 22, 2024

Click board™

Accel&Pressure Click

Dev Board

Clicker 4 for STM32F4

Compiler

NECTO Studio

MCU

STM32F407VGT6

Unlock precise vertical velocity insights and determine your application's exact rate of ascent or descent

A

A

Hardware Overview

How does it work?

Accel&Pressure Click is based on the FXLS8974CF, a 3-axis low-g accelerometer, and the MPL3115A2, a precision pressure sensor with altimetry, both from NXP Semiconductor. The accelerometer has a ±2/4/8/16 g user-selectable, full-scale measurement range with a 12-bit acceleration data output. It can work in several modes, such as active, hibernate, standby, and more. The integrated FIFO/LIFO buffer of 144 bytes can store 32 12-bit X/Y/Z/ data triplets. The sensor also has flexible data change detection, such as motion, freefall, and other inertial events. The pressure sensor has an absolute operating range of

20kPa to 110kPa in 20-bit measurements. Besides the pressure, the MPL3115A2 can also measure the altitude in a range of -698 up to 11775 meters in a 20-bit resolution. It also comes with an embedded FIFO (32 samples) and up to 12 days of data logging using the FIFO. Both sensors have an integrated temperature sensor and are temperature-compensated. Accel&Pressure Click uses a standard 2-wire I2C interface to allow the host MCU to communicate with both sensors. If the motion is detected, the FXLS8974CF uses a motion MOT pin to interrupt the host MCU. Depending on your application, you can choose one of the

available pins (PWM, AN, CS) by soldering one of the jumpers (R8, R9, R10) to control the hibernation mode wake-up function of the FXLS8974CF. In addition, there are LP Cut jumpers at the bottom of the Accel&Pressure Click board™, with which a low power consumption feature can be achieved. 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.

Accel&Pressure Click hardware overview image

Features overview

Development board

Clicker 4 for STM32F4 is a compact development board designed as a complete solution that you can use to quickly build your own gadgets with unique functionalities. Featuring an STM32F407VGT6 MCU, four mikroBUS™ sockets for Click boards™ connectivity, power management, and more, it represents a perfect solution for the rapid development of many different types of applications. At its core is an STM32F407VGT6 MCU, a powerful microcontroller by STMicroelectronics based on the high-performance

Arm® Cortex®-M4 32-bit processor core operating at up to 168 MHz frequency. It provides sufficient processing power for the most demanding tasks, allowing Clicker 4 to adapt to any specific application requirements. Besides two 1x20 pin headers, four improved mikroBUS™ sockets represent the most distinctive connectivity feature, allowing access to a huge base of Click boards™, growing on a daily basis. Each section of Clicker 4 is clearly marked, offering an intuitive and clean interface. This makes working with the

development board much simpler and, thus, faster. The usability of Clicker 4 doesn’t end with its ability to accelerate the prototyping and application development stages: it is designed as a complete solution that can be implemented directly into any project, with no additional hardware modifications required. Four mounting holes [4.2mm/0.165”] at all four corners allow simple installation by using mounting screws.

Clicker 4 for STM32F4 double image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M4

MCU Memory (KB)

10

Silicon Vendor

STMicroelectronics

Pin count

100

RAM (Bytes)

100

Used MCU Pins

mikroBUS™ mapper

Hibernation Mode Wake-Up
PC4
AN
ID SEL
PC15
RST
Hibernation Mode Wake-Up / ID COMM
PA4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Hibernation Mode Wake-Up
PE9
PWM
Motion Detection
PD0
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB10
SCL
I2C Data
PB11
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Accel&Pressure Click Schematic schematic

Step by step

Project assembly

Clicker 4 for STM32F4 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Clicker 4 for STM32F4 as your development board.

Clicker 4 for STM32F4 front image hardware assembly
Rotary O 2 Click front image hardware assembly
Clicker 4 STM32F4 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
Clicker 4 for STM32F4 HA 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

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for Accel&Pressure Click driver.

Key functions:

  • accelpressure_get_axes_data - This function reads the accelerometer sensor axes data.

  • accelpressure_get_pressure - This function reads the sensor pressure data conversion in mbar.

  • accelpressure_get_temperature - This function reads the conversion of sensor pressure data in degrees Celsius.

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 main.c
 * @brief AccelPressure Click example
 *
 * # Description
 * This library contains API for the AccelPressure Click driver.
 * The library initializes and defines the I2C drivers to 
 * write and read data from registers, as well as the default configuration 
 * for the reading accelerator, pressure, and temperature data.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * The initialization of the I2C module, log UART, and additional pins.
 * After the driver init, the app executes a default configuration.
 *
 * ## Application Task
 * This example demonstrates the use of the AccelPressure Click board.
 * Measures and displays acceleration data for the X-axis, Y-axis, and Z-axis [mg],
 * pressure [mBar], and temperature [degree Celsius] data.
 * Results are being sent to the UART Terminal, where you can track their changes.
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "accelpressure.h"

static accelpressure_t accelpressure;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    accelpressure_cfg_t accelpressure_cfg;  /**< Click config object. */

    /** 
     * 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.
    accelpressure_cfg_setup( &accelpressure_cfg );
    ACCELPRESSURE_MAP_MIKROBUS( accelpressure_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == accelpressure_init( &accelpressure, &accelpressure_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( ACCELPRESSURE_ERROR == accelpressure_default_cfg ( &accelpressure ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
    log_printf( &logger, "_________________\r\n" );
}

void application_task ( void ) 
{
    accelpressure_axes_t acc_axis;
    float pressure = 0, temperature = 0;
    if ( ACCELPRESSURE_OK == accelpressure_get_axes_data( &accelpressure, &acc_axis ) )
    {
        log_printf( &logger, " Accel X: %.2f mg\r\n", acc_axis.x );
        log_printf( &logger, " Accel Y: %.2f mg\r\n", acc_axis.y );
        log_printf( &logger, " Accel Z: %.2f mg\r\n", acc_axis.z );
    }
    log_printf( &logger, "_________________\r\n" );
    Delay_ms( 100 );

    if ( ACCELPRESSURE_OK == accelpressure_get_pressure( &accelpressure, &pressure ) )
    {
        log_printf( &logger, " Pressure: %.2f mbar\r\n", pressure );
    }
    Delay_ms( 100 );

    if ( ACCELPRESSURE_OK == accelpressure_get_temperature( &accelpressure, &temperature ) )
    {
        log_printf( &logger, " Temperature: %.2f mbar\r\n", 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.