Intermediate
30 min

Achieve accurate current measurements with TMCS1100A4 and ATmega6450 that meet industry standards

Maximize performance with precise current sensing

Hall Current 12 Click with EasyAVR PRO v8

Published Aug 12, 2023

Click board™

Hall Current 12 Click

Dev. board

EasyAVR PRO v8

Compiler

NECTO Studio

MCU

ATmega6450

Unlock the potential of our Hall-effect current sensing solution to attain unparalleled accuracy in measuring AC or DC currents, enabling fine-tuned control of power systems

A

A

Hardware Overview

How does it work?

Hall Current 12 Click is based on the TMCS1100A4, a precision Hall-effect current sensor featuring a 600V isolation working voltage, <1% full-scale error across temperature, and a reference voltage enabling unidirectional or bidirectional current sensing from Texas Instruments. The input current flows through an internal 1.8mΩ conductor that generates a magnetic field measured by an integrated Hall-effect sensor and amplified by a precision signal chain. The device has a bandwidth of 80kHz and can be used for both AC and DC current measurements. It is optimized for high accuracy and temperature stability, with offset and sensitivity compensated across the operating temperature range. The reference voltage provided to the TMCS1100A4 on the VREF pin determines the zero current output voltage. This zero-current output level and sensitivity determine the measurable input current range allowing for unidirectional or bidirectional sensing. An onboard SMD switch labeled as VREF SEL, placed in an appropriate

position marked as VCC/2 and GND, can select reference voltage. With VCC/2, the TMCS1100A4 measures input current up to ±5.75A, while with the GND position from 0.125A up to 12A. Hall Current 12 Click has two ways to communicate with the MCU. The output analog signal from TMCS1100A4 is forwarded to the input of the operational amplifier, the LMV321 low-voltage rail-to-rail OpAmp from Texas Instruments, representing the most cost-effective solution for applications where low-voltage operation is needed. The output of the LMV321 OpAmp has a stable unity gain, acting as a buffer so that the host MCU can sample the output voltage of the TMCS1100A4 via the AN pin of the mikroBUS™ socket. Also, this method can increase the sensitivity of its output signal by placing the switch labeled as SENSITIVITY in the appropriate position marked as LOW or HIGH, giving the user the option to select reduced or increased sensitivity. Another way of signal processing is for the TMCS1100A4 analog output signal to be converted to a digital value using

MCP3221, a successive approximation A/D converter with a 12-bit resolution from Microchip using a 2-wire I2C compatible interface. Selection can be performed by using an onboard SMD switch labeled as VOUT SEL, placing it in an appropriate position marked as AN and ADC. With the MCP3221, data transfers at rates of up to 100kbit/s in the Standard and 400kbit/s in the Fast Mode. Also, this Click board™ should be connected in series with the load. Two onboard terminal connectors measure the current, one terminal block for the positive and the other for the negative current input. 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. Also, this 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.

Hall Current 12 Click hardware overview image
Hall Current 12 Click Current Warning image

Features overview

Development board

EasyAVR PRO 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 8/16-bit AVR® MCUs from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over a WiFi network. 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, EasyAVR PRO v8 provides a fluid and immersive working experience, allowing access

anywhere and under any circumstances at any time. Each part of the EasyAVR PRO 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 and USB DEVICE are also included, alongside 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. EasyAVR PRO 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.

EasyAVR PRO v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

AVR

MCU Memory (KB)

64

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

4096

Used MCU Pins

mikroBUS™ mapper

Analog Signal
PF0
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
PE4
SCL
I2C Data
PE5
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Hall Current 12 Click Schematic schematic

Step by step

Project assembly

EasyAVR PRO v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyAVR PRO v8 as your development board.

EasyAVR PRO v8 front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for ATmega6450 front image hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
EasyAVR PRO v8 Access SiBRAIN 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

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 Hall Current 12 Click driver.

Key functions:

  • hallcurrent12_calibration - Hall Current 12 calibration function

  • hallcurrent12_get_adc - Hall Current 12 get ADC function

  • hallcurrent12_get_current - Hall Current 12 get current 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 HallCurrent12 Click example
 *
 * # Description
 * This library contains API for Hall Current 12 Click driver.
 * The demo application reads ADC voltage ( V ) and current ( A ).
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and logger and calibrates the device offset.
 *
 * ## Application Task
 * This is an example that demonstrates the use of the Hall Current 12 Click board™.
 * In this example, we read and display the ADC voltage ( V ) and current ( A ) data.
 * Results are being sent to the Usart Terminal where you can track their changes.
 *
 * @note
 * Switches: 
 *   Sensitivity : Low ( GAIN = 1 ),
 *   Vout_Sel    : AN  ( Analog interface ),
 *   Vref_Sel    : VCC/2 ( bidirectional measurement ).
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "hallcurrent12.h"

static hallcurrent12_t hallcurrent12;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;                      /**< Logger config object. */
    hallcurrent12_cfg_t hallcurrent12_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.
    hallcurrent12_cfg_setup( &hallcurrent12_cfg );
    HALLCURRENT12_MAP_MIKROBUS( hallcurrent12_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == hallcurrent12_init( &hallcurrent12, &hallcurrent12_cfg ) ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );
        for ( ; ; );
    }
    
    log_info( &logger, " Calibrating device, remove input current in the next 5 seconds..." );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    
    if ( I2C_MASTER_ERROR == hallcurrent12_calibration ( &hallcurrent12 ) )
    {
        log_error( &logger, " Calibration Error. " );
        log_info( &logger, " Please, run program again... " );
        for ( ; ; );
    }
    log_info( &logger, " Calibration done!" );

    log_info( &logger, " Application Task " );
    log_printf( &logger, "--------------------------\r\n" );
    Delay_ms ( 100 );
}

void application_task ( void ) 
{
    static float adc_voltage = 0;
    static float current = 0;
    if ( HALLCURRENT12_OK == hallcurrent12_get_adc( &hallcurrent12, &adc_voltage ) )
    {
        log_printf( &logger, " ADC voltage : %.3f V \r\n", adc_voltage );
    }
    if ( HALLCURRENT12_OK == hallcurrent12_get_current ( &hallcurrent12, &current ) )
    {
        log_printf( &logger, " Current     : %.3f A \r\n", current );
        log_printf( &logger, "--------------------------\r\n" );
    }
    Delay_ms ( 1000 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

// ------------------------------------------------------------------------ END
/*!
 * @file main.c
 * @brief HallCurrent12 Click example
 *
 * # Description
 * This library contains API for Hall Current 12 Click driver.
 * The demo application reads ADC voltage ( V ) and current ( A ).
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and logger and calibrates the device offset.
 *
 * ## Application Task
 * This is an example that demonstrates the use of the Hall Current 12 Click board™.
 * In this example, we read and display the ADC voltage ( V ) and current ( A ) data.
 * Results are being sent to the Usart Terminal where you can track their changes.
 *
 * @note
 * Switches: 
 *   Sensitivity : Low ( GAIN = 1 ),
 *   Vout_Sel    : AN  ( Analog interface ),
 *   Vref_Sel    : VCC/2 ( bidirectional measurement ).
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "hallcurrent12.h"

static hallcurrent12_t hallcurrent12;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;                      /**< Logger config object. */
    hallcurrent12_cfg_t hallcurrent12_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.
    hallcurrent12_cfg_setup( &hallcurrent12_cfg );
    HALLCURRENT12_MAP_MIKROBUS( hallcurrent12_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == hallcurrent12_init( &hallcurrent12, &hallcurrent12_cfg ) ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );
        for ( ; ; );
    }
    
    log_info( &logger, " Calibrating device, remove input current in the next 5 seconds..." );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    
    if ( I2C_MASTER_ERROR == hallcurrent12_calibration ( &hallcurrent12 ) )
    {
        log_error( &logger, " Calibration Error. " );
        log_info( &logger, " Please, run program again... " );
        for ( ; ; );
    }
    log_info( &logger, " Calibration done!" );

    log_info( &logger, " Application Task " );
    log_printf( &logger, "--------------------------\r\n" );
    Delay_ms ( 100 );
}

void application_task ( void ) 
{
    static float adc_voltage = 0;
    static float current = 0;
    if ( HALLCURRENT12_OK == hallcurrent12_get_adc( &hallcurrent12, &adc_voltage ) )
    {
        log_printf( &logger, " ADC voltage : %.3f V \r\n", adc_voltage );
    }
    if ( HALLCURRENT12_OK == hallcurrent12_get_current ( &hallcurrent12, &current ) )
    {
        log_printf( &logger, " Current     : %.3f A \r\n", current );
        log_printf( &logger, "--------------------------\r\n" );
    }
    Delay_ms ( 1000 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

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