Balancer 4 click
Balancer 4 Click is a compact add-on board optimized for overvoltage protection balancing the voltage of serially connected batteries. This board features the MP2672A, a highly integrated, flexible switch-mode battery charger for Lithium-Ion batteries with two cells in series from Monolithic Power Systems (MPS). The MP2672A has a narrow voltage DC (NVDC) power structure and monitors the voltage across each cell, equalizing the cell’s voltages if the difference between the two cells exceeds the mismatch threshold. It also has two selective operating modes with configurable output current up to 2A via register setting via I2C serial interface, alongside selectable MP2672A power supply, LED indication, and protection features allowing a reliable operation.
click Product page
Click library
- Author : Stefan Filipovic
- Date : Jan 2022.
- Type : I2C type
Software Support
We provide a library for the Balancer 4 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for Balancer 4 Click driver.
Standard key functions :
balancer4_cfg_setup
Config Object Initialization function.
void balancer4_cfg_setup(balancer4_cfg_t *cfg)
Balancer 4 configuration object setup function.
Balancer 4 Click configuration object.
Definition balancer4.h:252
balancer4_init
Initialization function.
err_t balancer4_init(balancer4_t *ctx, balancer4_cfg_t *cfg)
Balancer 4 initialization function.
Balancer 4 Click context object.
Definition balancer4.h:238
balancer4_default_cfg
Click Default Configuration function.
err_t balancer4_default_cfg(balancer4_t *ctx)
Balancer 4 default configuration function.
Example key functions :
balancer4_write_register
This function writes a desired data byte to the selected register by using I2C serial interface.
err_t balancer4_write_register(balancer4_t *ctx, uint8_t reg, uint8_t data_in)
Balancer 4 write register function.
balancer4_write_and_verify_register
This function writes a desired data byte to the selected register and verifies if is is written correctly by reading it.
err_t balancer4_write_and_verify_register(balancer4_t *ctx, uint8_t reg, uint8_t data_in)
Balancer 4 write and verify register function.
balancer4_read_register
This function reads a data byte from the selected register by using I2C serial interface.
err_t balancer4_read_register(balancer4_t *ctx, uint8_t reg, uint8_t *data_out)
Balancer 4 read register function.
Example Description
This example demonstrates the use of Balancer 4 click board by configuring the click board for charging and then reading the status and fault registers.
The demo application is composed of two sections :
Application Init
Initializes the driver and configures the click board for charging.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
balancer4_init( &balancer4, &balancer4_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ BALANCER4_ERROR
Definition balancer4.h:268
#define BALANCER4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition balancer4.h:226
void application_init(void)
Definition main.c:28
Application Task
Reads and displays the status and fault registers on the USB UART every 500ms approximately.
{
uint8_t status, fault;
{
log_printf ( &logger, "\r\n - STATUS - \r\n", status );
log_printf ( &logger, " Battery status: " );
{
log_printf ( &logger, "missing\r\n" );
}
else
{
log_printf ( &logger, "present\r\n" );
log_printf ( &logger, " Charging status: " );
{
{
log_printf ( &logger, "not charging\r\n" );
break;
}
{
log_printf ( &logger, "pre-charge\r\n" );
break;
}
{
log_printf ( &logger, "constant current or constant voltage charge\r\n" );
break;
}
{
log_printf ( &logger, "charging complete\r\n" );
break;
}
}
}
}
{
if ( fault )
{
log_printf ( &logger, "\r\n - FAULT - \r\n" );
{
log_printf ( &logger, " The watchdog timer has expired\r\n" );
}
{
log_printf ( &logger, " Input OVP has occured\r\n" );
}
{
log_printf ( &logger, " Thermal shutdown\r\n" );
}
{
log_printf ( &logger, " The safety timer has expired\r\n" );
}
{
log_printf ( &logger, " Battery OVP has occured\r\n" );
}
{
{
log_printf ( &logger, " An NTC cold fault has occured\r\n" );
break;
}
{
log_printf ( &logger, " An NTC cool fault has occured\r\n" );
break;
}
{
log_printf ( &logger, " An NTC warm fault has occured\r\n" );
break;
}
{
log_printf ( &logger, " An NTC hot fault has occured\r\n" );
break;
}
}
}
}
Delay_ms ( 500 );
}
@ BALANCER4_OK
Definition balancer4.h:267
#define BALANCER4_REG_FAULT
Definition balancer4.h:77
#define BALANCER4_REG_STATUS
Definition balancer4.h:76
#define BALANCER4_FAULT_NTC_HOT
Definition balancer4.h:200
#define BALANCER4_STATUS_CHG_STAT_MASK
Definition balancer4.h:174
#define BALANCER4_FAULT_TIMER
Definition balancer4.h:195
#define BALANCER4_FAULT_WD
Balancer 4 fault register setting.
Definition balancer4.h:192
#define BALANCER4_STATUS_PRE_CHARGE
Definition balancer4.h:171
#define BALANCER4_FAULT_INPUT
Definition balancer4.h:193
#define BALANCER4_FAULT_NTC_COOL
Definition balancer4.h:198
#define BALANCER4_FAULT_NTC_MASK
Definition balancer4.h:201
#define BALANCER4_STATUS_CONSTANT_CHARGE
Definition balancer4.h:172
#define BALANCER4_STATUS_NOT_CHARGING
Balancer 4 status register setting.
Definition balancer4.h:170
#define BALANCER4_FAULT_NTC_COLD
Definition balancer4.h:197
#define BALANCER4_FAULT_BAT
Definition balancer4.h:196
#define BALANCER4_STATUS_BATTERY_MISSING
Definition balancer4.h:179
#define BALANCER4_FAULT_NTC_WARM
Definition balancer4.h:199
#define BALANCER4_FAULT_THERMAL_SD
Definition balancer4.h:194
#define BALANCER4_STATUS_CHARGING_COMPLETE
Definition balancer4.h:173
void application_task(void)
Definition main.c:64
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.Balancer4
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.