Intermediate
30 min

Empower your heart health with MCP6N16 and PIC32MZ2048EFH100

Monitor your cardiovascular wellness

ECG 7 Click with Flip&Click PIC32MZ

Published Apr 03, 2023

Click board™

ECG 7 Click

Dev. board

Flip&Click PIC32MZ

Compiler

NECTO Studio

MCU

PIC32MZ2048EFH100

Stay informed and in control with accurate readings and real-time ECG monitoring

A

A

Hardware Overview

How does it work?

ECG 7 Click is based on the MCP6N16, a zero-drift instrumentation amplifier designed for single-supply operation with rail-to-rail input and output performance from Microchip. The design of the MCP6N16 is based on a current feedback architecture which allows for the output voltage to be independently set regardless of the input common-mode voltage. Its internal offset correction gives high DC precision, low offset and drift, and negligible noise. The head part of the board represents a differential amplification stage based on the MCP6N16, with the RC input filter providing a low-pass function for differential mode signals. This part also comes with a selectable gain for the MCP6N16, performed by an onboard switch marked as GAIN, allowing users to quickly set the gain on the MCP6N16 to either 101V/V

or 301V/V by setting the switch to an appropriate position. After that, the signal from MCP6N16 goes through amplification and buffering by the MCP6002 operational amplifier. Then the signal is ready for further processing in analog or digital format. As mentioned before, this Click board™ possesses two ways to communicate with the MCU. The output voltage of the MCP6002 Op-Amp can be converted to a digital value using MCP3221, a successive approximation A/D converter from Microchip, using a 2-wire I2C compatible interface, or can be sent directly to an analog pin of the mikroBUS™ socket labeled as AN. Selection is performed by onboard SMD switch labeled as VOUT SEL to an appropriate position marked as AN and ADC. Using MCP3221 and I2C interface, data transfers at rates up to 100kbit/s in the Standard

and 400kbit/s in the Fast Mode. In addition to the 3.5mm jack connector reserved for connecting the ECG/EMG cable with ECG electrodes, this Click board™ offers the possibility of connecting electrodes through screw terminals labeled as VIN+ and VIN- or unpopulated header if the electrode connection does not match the jack connector. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. However, the Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used, as a reference, for further development.

ecg_7_click_hardware_overview

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

You complete me!

Accessories

3-wire ECG/EMG cable comes with a convenient 3.5mm phone jack, and it is designed for electrocardiogram recording. This 1m cable is a practical companion for medical professionals and enthusiasts. To complement this cable, you can also use single-use adhesive ECG/EMG electrodes measuring 48x34mm, each equipped with an ECG/EMG cable stud adapter. These electrodes ensure a seamless experience when paired with our ECG/EMG cable and guarantee reliable ECG/EMG signal transmission for comprehensive cardiac monitoring. Trust in the accuracy and convenience of this setup to effortlessly record electrocardiograms and electromyograms with confidence.

ECG 7 Click accessories image

Used MCU Pins

mikroBUS™ mapper

Analog Signal
RB11
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
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RA2
SCL
I2C Data
RA3
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

ECG 7 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
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Flip&Click PIC32MZ MB1 Access - 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 ECG 7 Click driver.

Key functions:

  • ecg7_read_raw_adc This function reads raw ADC value.

  • ecg7_read_voltageThis function reads the raw ADC value and converts it to a proportional voltage level.

  • ecg7_set_vref This function sets the voltage reference for ECG 7 click driver.

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 main.c
 * @brief ECG 7 Click Example.
 *
 * # Description
 * This example demonstrates the use of ECG 7 click board by reading and displaying
 * the voltage from VOUT BUFF which can be visualized on the SerialPlot application.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and logger.
 *
 * ## Application Task
 * Reads the output voltage and displays it on the USB UART (SerialPlot)
 * every 4ms approximately.
 *
 * @note
 * We recommend using the SerialPlot tool for data visualizing. 
 * Please make sure to set up ECG electrodes properly.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "ecg7.h"

static ecg7_t ecg7;   /**< ECG 7 Click driver object. */
static log_t logger;    /**< Logger object. */

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    ecg7_cfg_t ecg7_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.
    ecg7_cfg_setup( &ecg7_cfg );
    ECG7_MAP_MIKROBUS( ecg7_cfg, MIKROBUS_1 );
    err_t init_flag = ecg7_init( &ecg7, &ecg7_cfg );
    if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    float ecg7_an_voltage = 0;
    if ( ECG7_OK == ecg7_read_voltage ( &ecg7, &ecg7_an_voltage ) ) 
    {
        log_printf( &logger, "%.3f\r\n", ecg7_an_voltage );
        Delay_ms ( 4 );
    }
}

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.