Beginner
10 min

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

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

Accel&Pressure Click with Kinetis Clicker

Published Jan 22, 2024

Click board™

Accel&Pressure Click

Dev.Board

Kinetis Clicker

Compiler

NECTO Studio

MCU

MK22FN512VLH12

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

Kinetis Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit ARM Cortex-M4 microcontroller, the MK22FN512VLH12 from NXP Semiconductor, a USB connector, LED indicators, buttons, a mikroProg connector, and a header for interfacing with external electronics. Thanks to its compact design with clear and easy-recognizable silkscreen markings, it provides a fluid and immersive working experience, allowing access

anywhere and under any circumstances. Each part of the Kinetis Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the Kinetis Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for Kinetis programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB-MiniAB connection provides up to 500mA of current, which is more than enough to operate all

onboard and additional modules. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. Kinetis Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Kinetis Clicker double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M4

MCU Memory (KB)

512

Silicon Vendor

NXP

Pin count

64

RAM (Bytes)

131072

Used MCU Pins

mikroBUS™ mapper

Hibernation Mode Wake-Up
PTB2
AN
ID SEL
PTB3
RST
Hibernation Mode Wake-Up / ID COMM
PTC4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Hibernation Mode Wake-Up
PTC1
PWM
Motion Detection
PTD0
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PTB0
SCL
I2C Data
PTB1
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Accel&Pressure Click Schematic schematic

Step by step

Project assembly

Kinetis Clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Kinetis Clicker as your development board.

Kinetis Clicker front image hardware assembly
Thermo 28 Click front image hardware assembly
Prog-cut hardware assembly
Kinetis Mini B Connector clicker - 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
Kinetis Clicker HA MCU/Select 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