Intermediate
30 min

ECG at your fingertips with ADS1194 and STM32F437ZG

Unveiling vital rhythms

ECG 2 Click with Fusion for ARM v8

Published Jul 28, 2023

Click board™

ECG 2 Click

Dev Board

Fusion for ARM v8

Compiler

NECTO Studio

MCU

STM32F437ZG

Experience the power of real-time ECG monitoring that provides instant and accurate insights into heart health

A

A

Hardware Overview

How does it work?

ECG 2 Click is based on the ADS1194, a low-power, 8-channel, 16-bit analog front-end for biopotential measurements from Texas Instruments. The ADS1194 is a multichannel simultaneous sampling delta-sigma analog-to-digital converter with a built-in programmable gain amplifier, internal reference, and onboard oscillator. It has a flexible input multiplexer per channel that can be independently connected to the internally generated signals for test, temperature, and lead-off detection. This ADC can sample data in a range of 125sps up to 8ksps data rates, with a programmable gain in 1, 2, 3, 4, 6, 8, or 12 steps. In addition, the ECG 2 Click features the built-in right leg drive amplifier, lead-off detection, WCT, test signals, pace detection channel selection, and more. The ECG 2 Click can work in several modes. The Continuous mode is ideal for applications that require a fixed stream of conversion results. The Single-Shot conversion mode is provided for applications that require a non-standard or non-continuous data rate. An onboard 3.5mm phone

jack is used to connect cables/electrodes to the Click board™. The electrode collects voltage from the skin, after which the signal is amplified, filtered, and sent to the host MCU over the mikroBUS™ socket. The three electrodes should be placed on the left arm, right arm, and the left side of the abdomen (below the heart), on the left leg. In addition to the phone jack, the ECG 2 Click includes screw terminals for a 4-wire measurement. ECG 2 click can also be connected by four electrodes placed on both arms and legs. The final measurement results can be displayed as an Electrocardiogram using a free app, the MikroPlot, a free data visualization tool (Windows). It's a simple tool to help you visualize sensor data recorded over time, suitable for biosignals (ECG, EEG, EMG) and environmental data logging (temperature, humidity, and more). The graph is generated from data sent from the MCU (ADC values from ECG 2 click input + timestamp). The app can receive data sets from a microcontroller through a USB UART connection. ECG 2 Click uses

a standard 4-Wire SPI serial interface to communicate with the host MCU. The data-ready output is used as a status signal to indicate when data are ready, where the DRD pin will go LOW if new data are available. In addition, other pins meet the ECG 2 Click's functionalities. The ADS1194 can be reset over the RST pin with an active LOW logic state, while it can be powered down with an active LOW on the PWD pin. The host MCU can be used to detect the presence of the pulse by bringing out the output of the PGA at the PAC pin (TEST PACE OUT1). This Click board™ can be operated only with a 3.3V logic voltage level while it uses a 5V for analog power supply via LDO (3V stabilized). The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used, as a reference, for further development.

ECG 2 Click hardware overview image

Features overview

Development board

Fusion for ARM v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different ARM® Cortex®-M based MCUs regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, Fusion for ARM v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the Fusion for ARM v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.

Communication options such as USB-UART, USB HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. Fusion for ARM v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Fusion for ARM v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

ARM Cortex-M4

MCU Memory (KB)

1024

Silicon Vendor

STMicroelectronics

Pin count

144

RAM (Bytes)

262144

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 2 Click accessories image

Used MCU Pins

mikroBUS™ mapper

Test Pace Out
PA3
AN
Reset
PE11
RST
SPI Chip Select
PA4
CS
SPI Clock
PA5
SCK
SPI Data OUT
PA6
MISO
SPI Data IN
PB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Power Down
PD12
PWM
Data Ready
PD3
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

ECG 2 Click Schematic schematic

Step by step

Project assembly

Fusion for PIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Fusion for ARM v8 as your development board.

Fusion for PIC v8 front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
v8 SiBRAIN Access 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 Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for ECG 2 Click driver.

Key functions:

  • ecg2_read_an_pin_value - ECG 2 read AN pin value function

  • ecg2_send_command - ECG 2 send command function

  • ecg2_read_channel_data - ECG 2 read data channel 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 ECG2 Click example
 *
 * # Description
 * This is an example that demonstrates the use of the ECG 2 Click board.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes SPI and UART communication, configures INT pin as INPUT, RST pin as OUTPUT, CS pin as 
 * OUTPUT and PWM pin as OUTPUT. Initializes SPI driver, initializes ECG2 click, sends START and 
 * RDATAC opcodes.
 *
 * ## Application Task
 * Captures readings from channel and plots data to serial plotter.
 *
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "ecg2.h"

static ecg2_t ecg2;
static log_t logger;
uint32_t time;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    ecg2_cfg_t ecg2_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.
    ecg2_cfg_setup( &ecg2_cfg );
    ECG2_MAP_MIKROBUS( ecg2_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == ecg2_init( &ecg2, &ecg2_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    SET_SPI_DATA_SAMPLE_EDGE;
    
    if ( ECG2_ERROR == ecg2_default_cfg ( &ecg2 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    Delay_ms( 100 );
    ecg2_send_command( &ecg2, ECG2_START_CONVERSION );
    Delay_ms( 100 );
    ecg2_send_command( &ecg2, ECG2_ENABLE_READ_DATA_CONT_MODE );
    Delay_ms( 100 );
    
    log_info( &logger, " Application Task " );
    Delay_ms( 100 );
}

void application_task ( void ) 
{   
    uint16_t ecg_an = 0;
    ecg2_read_channel_data( &ecg2, 5, &ecg_an );
    log_printf( &logger, " %.6u, %.8lu \r\n", ecg_an, time );
    time += 5;
    Delay_ms( 5 );   
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources