We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2024-10-31
Package Version: 2.1.0.15
mikroSDK Library: 2.0.0.0
Category: Battery Charger
Downloaded: 255 times
Not followed.
License: MIT license
Charger 3 Click is a compact add-on board that represents a standalone battery charger with thermal regulation. This board features the TP4056, a complete constant-current/constant-voltage linear charger for single-cell lithium-ion batteries from NanJing Top Power ASIC Corp.
Do you want to subscribe in order to receive notifications regarding "Charger 3 Click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Charger 3 Click" changes.
Do you want to report abuse regarding "Charger 3 Click".
DOWNLOAD LINK | RELATED COMPILER | CONTAINS |
---|---|---|
4314_charger_3_click.zip [359.70KB] | mikroC AI for ARM GCC for ARM Clang for ARM mikroC AI for PIC mikroC AI for PIC32 XC32 GCC for RISC-V Clang for RISC-V mikroC AI for AVR mikroC AI for dsPIC XC16 |
|
Charger 3 Click is a compact add-on board that represents a standalone battery charger with thermal regulation. This board features the TP4056, a complete constant-current/constant-voltage linear charger for single-cell lithium-ion batteries from NanJing Top Power ASIC Corp.
We provide a library for the Charger3 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.
This library contains API for Charger3 Click driver.
Config Object Initialization function.
void charger3_cfg_setup ( charger3_cfg_t *cfg );
Initialization function.
CHARGER3_RETVAL charger3_init ( charger3_t *ctx, charger3_cfg_t *cfg );
Click Default Configuration function.
void charger3_default_cfg ( charger3_t *ctx );
Charger 3 enable write function.
void charger3_enable_write ( charger3_t *ctx );
Charger 3 set current function.
uint8_t charger3_set_current ( charger3_t *ctx, float curr_value );
Charger 3 calculate digipot resistance function.
float charger3_calc_digipot_res ( charger3_t *ctx );
This example demonstrates the utilization of Charger 3 Click.
The demo application is composed of two sections :
The application init sets up the UART LOG and I2C communication drivers. The default configuration disables write protection and sets the operation mode to charging.
void application_init ( void ) {
log_cfg_t log_cfg; /**< Logger config object. */
charger3_cfg_t charger3_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.
charger3_cfg_setup( &charger3_cfg );
CHARGER3_MAP_MIKROBUS( charger3_cfg, MIKROBUS_1 );
err_t init_flag = charger3_init( &charger3, &charger3_cfg );
if ( init_flag == I2C_MASTER_ERROR ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
Delay_ms ( 100 );
charger3_default_cfg ( &charger3 );
log_info( &logger, " Application Task " );
log_printf( &logger, " ------------------------------------\r\n" );
Delay_ms ( 100 );
}
Task consists of two operations. First, the desired battery charging current is set by the user. Since setting the current doesn't implicitly reveals the resistance, the value of AD5175 digipot is directly read from the RDAC register, calculated and displayed on the uart log.
void application_task ( void ) {
float result;
charger3_set_current( &charger3, 0.4 );
Delay_ms ( 1000 );
result = charger3_calc_digipot_res( &charger3 );
log_printf( &logger, " Digipot res value: %.2f ohm\r\n", result );
log_printf( &logger, " ------------------------------------\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
While the resistance of the AD5175 can be directly set and read, the total resistance value on the PROG pin should be accounted for ( this means an additional 1kohm in series ) setting of the battery charging current.
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:
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.