Intermediate
30 min

Immerse yourself in the world of motion precision with MXC4005XC and PIC32MZ2048EFH100

Beyond tilt and turn

Accel 25 Click with Flip&Click PIC32MZ

Published Sep 13, 2023

Click board™

Accel 25 Click

Dev Board

Flip&Click PIC32MZ

Compiler

NECTO Studio

MCU

PIC32MZ2048EFH100

Master the art of movement with our 3-axis accelerometer, where the future of precision opens doors to applications that demand accuracy and reliability

A

A

Hardware Overview

How does it work?

Accel 25 Click is based on the MXC4005XC, a highly reliable digital triaxial acceleration from MEMSIC. The MXC4005XC is highly configurable with a programmable acceleration range of ±2g, ±4g, or ±8g based on MEMSIC's proprietary thermal technology built with a 0.18μm standard CMOS process. It contains no moving sensor parts, eliminating field reliability and repeatability issues; no measurable resonance (immunity to vibration), stiction, or detectable hysteresis exists. The MXC4005XC also eliminates the "click" sounds typically heard in ball-based orientation sensors.

The shock survival of this MEMS sensing structure is greater than 200,000g. This sensor provides X/Y/Z axis acceleration signals with a low 0g offset and temperature signals with high accuracy. In addition, it also detects six orientation positions, X/Y shake, and shakes directions. Accel 25 Click communicates with MCU using the standard I2C 2-Wire interface to read data and configure settings capable of operating in a standard or fast mode of operation. The acceleration signal is provided in 12-bit output resolution. In addition to communication pins, this board also possesses an

additional interrupt pin, routed to the INT pin on the mikroBUS™ socket, for orientation and X/Y shake detections. The MXC4005XC allows users to be placed in a Power-Down mode enabled through the I2C interface. 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 25 Click top side image
Accel 25 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

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
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

Schematic

Accel 25 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

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 25 Click driver.

Key functions:

  • accel25_soft_reset - Accel 25 soft reset function

  • accel25_set_full_scale_range - Accel 25 set full scale range function

  • accel25_read_data - Accel 25 read data function

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 Accel 25 Click example
 *
 * # Description
 * This example demonstrates the use of Accel 25 click board by reading and displaying 
 * accel data (X, Y, and Z axis) as well as temperature measurements on the USB UART.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration.
 *
 * ## Application Task
 * Reads and displays the accel data (X, Y, and Z axis) as well as temperature measurements
 * on the USB UART every 100ms approximately.
 *
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "accel25.h"

static accel25_t accel25;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    accel25_cfg_t accel25_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.
    accel25_cfg_setup( &accel25_cfg );
    ACCEL25_MAP_MIKROBUS( accel25_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == accel25_init( &accel25, &accel25_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( ACCEL25_ERROR == accel25_default_cfg ( &accel25 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    accel25_data_t meas_data;
    // Wait for data ready indication
    if ( ACCEL25_PIN_STATE_LOW == accel25_get_int_pin ( &accel25 ) );
    {
        if ( ACCEL25_OK == accel25_read_data ( &accel25, &meas_data ) )
        {
            log_printf( &logger, " X: %.3f g\r\n", meas_data.x );
            log_printf( &logger, " Y: %.3f g\r\n", meas_data.y );
            log_printf( &logger, " Z: %.3f g\r\n", meas_data.z );
            log_printf( &logger, " Temperature: %.2f degC\r\n", meas_data.temperature );
        }
    Delay_ms ( 100 );
    }
}

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.