Intermediate
30 min

Capture motion data in three dimensions with BMA456 and PIC32MZ2048EFH100

Learn how accelerometers revolutionize our world

Accel 11 Click with Flip&Click PIC32MZ

Published Oct 05, 2023

Click board™

Accel 11 Click

Dev Board

Flip&Click PIC32MZ

Compiler

NECTO Studio

MCU

PIC32MZ2048EFH100

By detecting gravitational forces, accelerometers aid in determining an object's orientation with respect to Earth's gravitational field, providing valuable information for navigation and alignment applications

A

A

Hardware Overview

How does it work?

Accel 11 Click is based on the BMA456, a digital triaxial acceleration sensor from Bosch Sensortec. This sensor has many features ideally suited for wearables, handheld, and IoT applications, offering a good balance between the performance and the power consumption. One of its key features is its extremely low power consumption, which makes it perfectly suited for such applications. There are several power modes that the BMA456 device can use. While in Low Power mode, the device consumes the least power, but access to some features is restricted. More information can be found within the BMA456 datasheet. The BMA456 sensor can measure acceleration within ranges of ±2 g, ±4 g, ±8, and ±16 g. It can output the measurement data using the Output Data Rate (ODR) from 0.78Hz (Low Power mode) up to 1600Hz (Performance mode). A high-precision analog front end facilitates highly sensitive MEMS, featuring a 16-bit A/D Converter. It allows very high output accuracy, even during low amplitude changes. This makes the sensor particularly sensitive and accurate with movements that

generate relatively low acceleration signals. However, using a highly sensitive MEMS makes the BMA456 prone to damage caused by extremely high g-forces (10,000g for less than 200µs). Acceleration data is available in 16-bit format from the data registers and the internal FIFO buffer of 1kb. The FIFO buffer can be used for more complex calculations or timed readings, reducing the traffic on the communication interface. The interrupt engine facilitates the FIFO buffer, triggering an interrupt for two FIFO events: the watermark event and the FIFO buffer full event. FIFO buffer allows optimization within the firmware that runs on the host MCU. Besides the acceleration MEMS and complementary analog front-end circuit, the BMA456 sensor has an integrated temperature sensor. It is updated every 1.2s and sampled to an 8-bit value (complement of 2’s format). Interrupts can be triggered for many different events. Some basic events include the data-ready interrupt event and aforementioned FIFO events, while so-called feature engines can trigger an interrupt for any of the detected

motion/movement events, including step detection/counter, activity recognition, tilt on the wrist, tap/double tap, any/no motion, and error event interrupt. The extensive interrupt engine can use two programmable interrupt pins. Depending on settings in appropriate registers, these pins can be assigned with any interrupt source and can be either LOW or HIGH on interrupt. These two pins are routed to the INT and AN pin of the mikroBUS™ and are labeled IT1 and IT2, respectively. Accel 11 click offers two communication interfaces. It can be used with either I2C or SPI. The onboard SMD jumpers labeled COMM SEL allow switching between the two interfaces. Note that all the jumpers must be positioned in the I2C or SPI position. When the I2C interface is selected, an additional SMD jumper labeled ADDR SEL becomes available, determining the least significant bit of the BMA456 I2C address. The Click board™ should be interfaced only with MCUs that use logic levels of 3.3V.

Accel 11 Click top side image
Accel 11 Click bottom side image

Features overview

Development board

Flip&Click PIC32MZ is a compact development board designed as a complete solution 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 PIC32MZ microcontroller, the PIC32MZ2048EFH100 from Microchip, four mikroBUS™ sockets for Click board™ connectivity, two USB connectors, LED indicators, buttons, debugger/programmer connectors, and two headers compatible with Arduino-UNO pinout. Thanks to innovative manufacturing technology,

it allows you to build gadgets with unique functionalities and features quickly. Each part of the Flip&Click PIC32MZ development kit contains the components necessary for the most efficient operation of the same board. In addition, there is the possibility of choosing the Flip&Click PIC32MZ programming method, using the chipKIT bootloader (Arduino-style development environment) or our USB HID bootloader using mikroC, mikroBasic, and mikroPascal for PIC32. This kit includes a clean and regulated power supply block through the USB Type-C (USB-C) connector. All communication

methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, user-configurable buttons, and LED indicators. Flip&Click PIC32MZ development kit allows 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.

Flip&Click PIC32MZ double image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

Interrupt 1
RB11
AN
NC
NC
RST
SPI Chip Select
RA0
CS
SPI Clock
RG6
SCK
SPI Data OUT
RC4
MISO
SPI Data IN
RB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt 2
RD9
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RA2
SCL
I2C Data
RA3
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Accel 11 Click Schematic schematic

Step by step

Project assembly

Flip&Click PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Flip&Click PIC32MZ as your development board.

Flip&Click PIC32MZ front image hardware assembly
Buck 22 Click front image hardware assembly
Prog-cut hardware assembly
Flip&Click PIC32MZ - 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
Flip&Click PIC32MZ 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

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for Accel 11 Click driver.

Key functions:

  • accel11_get_axis_data - This function reads accel axis

  • accel11_test_comunication - This function test comunication

  • accel11_power_on_procedure - This function for power on chip

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 Accel11 Click example
 * 
 * # Description
 * This demo application reads X / Y / Z axis acceleration data.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initialization device.
 * 
 * ## Application Task  
 * Reads X / Y / Z axis acceleration data and it logs to USBUART every 1500ms.
 * 
 * \author MikroE Team
 *
 */

// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "accel11.h"

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

static accel11_t accel11;
static log_t logger;

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

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

    accel11_cfg_setup( &cfg );
    ACCEL11_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    accel11_init( &accel11, &cfg );

    tmp = accel11_test_comunication( &accel11 );
    if ( tmp == ACCEL11_TEST_COMUNICATION_OK )
    {
        log_printf( &logger, " Comunication OK !!!\r\n" );
    }
    else
    {
        log_printf( &logger, " Comunication ERROR !!!\r\n" );
        for ( ; ; );
    }
    accel11_default_cfg( &accel11 );
}

void application_task ( void )
{
    int16_t x_axis;
    int16_t y_axis;
    int16_t z_axis;

    x_axis = accel11_get_axis_data( &accel11, ACCEL11_ACCEL_X_AXIS );
    log_printf( &logger, " X axis : %d\r\n", x_axis );

    y_axis = accel11_get_axis_data( &accel11, ACCEL11_ACCEL_Y_AXIS );
    log_printf( &logger, " Y axis : %d\r\n", y_axis );

    z_axis = accel11_get_axis_data( &accel11, ACCEL11_ACCEL_Z_AXIS );
    log_printf( &logger, " Z axis : %d\r\n", z_axis );

    log_printf( &logger, "---------------------------------\r\n" );
    Delay_ms( 1500 );
}

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.