Error-free AC/DC current sensing solution
A
A
Hardware Overview
How does it work?
Hall Current 14 Click is based on the MCS1801, a Hall-effect current sensor from Monolithic Power Systems (MPS) that sends an analog voltage proportional to the magnetic field intensity caused by the current flowing through the primary input conductor. Immune to external magnetic fields by differential sensing, the MCS1801 can detect both DC and AC designed for the current range of ±25A. Device accuracy, ±3%, is optimized across the operating ambient temperature through the proximity of the magnetic signal to the Hall sensors. A primary conductor with a low resistance allows current to flow close to the IC, containing high-accuracy Hall-effect sensors. This current generates a magnetic field sensed by the integrated Hall-effect transducers at two different points. The magnetic field difference between these
two points is then converted into a voltage (analog output) proportional to the applied current. The analog output signal of the MCS1801 can 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, or can be sent directly to an analog pin of the mikroBUS™ socket labeled as AN. Selection can be performed by onboard SMD jumper labeled AD SEL to an appropriate position marked as AN and ADC. The MCP3221 provides one single-ended input with low power consumption, a low maximum conversion current, and a Standby current of 250μA and 1μA, respectively. Data can be transferred up to 100kbit/s in the Standard and 400kbit/s in the FastMode. Also, maximum sample rates of
22.3kSPS with the MCP3221 are possible in a Continuous-Conversion Mode with a clock rate of 400kHz. 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. 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.
Features overview
Development board
Arduino UNO is a versatile microcontroller board built around the ATmega328P chip. It offers extensive connectivity options for various projects, featuring 14 digital input/output pins, six of which are PWM-capable, along with six analog inputs. Its core components include a 16MHz ceramic resonator, a USB connection, a power jack, an
ICSP header, and a reset button, providing everything necessary to power and program the board. The Uno is ready to go, whether connected to a computer via USB or powered by an AC-to-DC adapter or battery. As the first USB Arduino board, it serves as the benchmark for the Arduino platform, with "Uno" symbolizing its status as the
first in a series. This name choice, meaning "one" in Italian, commemorates the launch of Arduino Software (IDE) 1.0. Initially introduced alongside version 1.0 of the Arduino Software (IDE), the Uno has since become the foundational model for subsequent Arduino releases, embodying the platform's evolution.
Microcontroller Overview
MCU Card / MCU
Architecture
AVR
MCU Memory (KB)
32
Silicon Vendor
Microchip
Pin count
28
RAM (Bytes)
2048
You complete me!
Accessories
Click Shield for Arduino UNO has two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the Arduino UNO board without effort. The Arduino Uno, a microcontroller board based on the ATmega328P, provides an affordable and flexible way for users to try out new concepts and build prototypes with the ATmega328P microcontroller from various combinations of performance, power consumption, and features. The Arduino Uno has 14 digital input/output pins (of which six can be used as PWM outputs), six analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP header, and reset button. Most of the ATmega328P microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the Arduino UNO board with our Click Shield for Arduino UNO, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for Hall Current 14 Click driver.
Key functions:
hallcurrent14_read_voltage
This function reads the raw ADC value and converts it to a proportional voltage level.hallcurrent14_set_vref
This function sets the voltage reference for Hall Current 14 click driver.hallcurrent14_read_current
This function reads the input current level [A] based on @b HALLCURRENT14_NUM_CONVERSIONS of voltage measurements.
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 Hall Current 14 Click Example.
*
* # Description
* This example demonstrates the use of Hall Current 14 click board by reading and
* displaying the input current measurements.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and logger.
*
* ## Application Task
* Reads the input current measurements and displays the results on the USB UART
* approximately once per second.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "hallcurrent14.h"
static hallcurrent14_t hallcurrent14; /**< Hall Current 14 Click driver object. */
static log_t logger; /**< Logger object. */
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
hallcurrent14_cfg_t hallcurrent14_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.
hallcurrent14_cfg_setup( &hallcurrent14_cfg );
HALLCURRENT14_MAP_MIKROBUS( hallcurrent14_cfg, MIKROBUS_1 );
err_t init_flag = hallcurrent14_init( &hallcurrent14, &hallcurrent14_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 current = 0;
if ( HALLCURRENT14_OK == hallcurrent14_read_current ( &hallcurrent14, ¤t ) )
{
log_printf( &logger, " Current : %.3f[A]\r\n\n", current );
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