Intermediate
30 min

ECG at your fingertips with ADS1194 and PIC18F57Q43

Unveiling vital rhythms

ECG 2 Click with Curiosity Nano with PIC18F57Q43

Published Feb 13, 2024

Click board™

ECG 2 Click

Dev. board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

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

PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive

mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI

GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.

PIC18F57Q43 Curiosity Nano double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

48

RAM (Bytes)

8196

You complete me!

Accessories

Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.

Curiosity Nano Base for Click boards accessories 1 image

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
PA0
AN
Reset
PA7
RST
SPI Chip Select
PD4
CS
SPI Clock
PC6
SCK
SPI Data OUT
PC5
MISO
SPI Data IN
PC4
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Power Down
PB0
PWM
Data Ready
PA6
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

Click board™ Schematic

ECG 2 Click Schematic schematic

Step by step

Project assembly

Curiosity Nano Base for Click boards front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity Nano with PIC18F57Q43 as your development board.

Curiosity Nano Base for Click boards front image hardware assembly
Charger 27 Click front image hardware assembly
PIC18F47Q10 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Curiosity Nano with PICXXX 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 image step 5 hardware assembly
Necto image step 6 hardware assembly
PIC18F57Q43 Curiosity 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 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

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

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.