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: 2019-11-20
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Battery Charger
Downloaded: 3461 times
Not followed.
License: MIT license
Balancer 5 Click is an intelligent 2-cell Li-Ion battery charger, system power manager, and a battery fuel gauge Click board.
Do you want to subscribe in order to receive notifications regarding "Balancer 5 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "Balancer 5 click" changes.
Do you want to report abuse regarding "Balancer 5 click".
Library Description
Library provides functions for controling pin state and reading it from device, and reading and writing data to device.
Key functions:
void balancer5_charge ( uint8_t state )
- Control device charging sateuint8_t balancer5_read_data ( uint8_t reg_addr )
- Reads and returns one Byte of data from registarvoid balancer5_write_data ( uint8_t reg_addr, uint8_t write_data )
- Writes one Byte of data to registarExamples description
The application is composed of three sections :
void application_task ( )
{
temp_data = balancer5_read_data( BALANCER5_REG_IBUS_ADC1 );
temp_uint_data = temp_data;
temp_uint_data <<= 8;
temp_data = balancer5_read_data( BALANCER5_REG_IBUS_ADC0 );
temp_uint_data |= temp_data;
IntToStr( temp_uint_data, demo_txt );
mikrobus_logWrite( "- IBUS:", _LOG_TEXT );
mikrobus_logWrite( demo_txt, _LOG_TEXT );
mikrobus_logWrite( " mA", _LOG_LINE );
temp_data = balancer5_read_data( BALANCER5_REG_ICHG_ADC1 );
temp_uint_data = temp_data;
temp_uint_data <<= 8;
temp_data = balancer5_read_data( BALANCER5_REG_ICHG_ADC0 );
temp_uint_data |= temp_data;
WordToStr( temp_uint_data, demo_txt );
mikrobus_logWrite( "- ICHG:", _LOG_TEXT );
mikrobus_logWrite( demo_txt, _LOG_TEXT );
mikrobus_logWrite( " mA", _LOG_LINE );
temp_data = balancer5_read_data( BALANCER5_REG_VBAT_ADC1 );
temp_uint_data = temp_data;
temp_uint_data <<= 8;
temp_data = balancer5_read_data( BALANCER5_REG_VBAT_ADC0 );
temp_uint_data |= temp_data;
IntToStr( temp_uint_data, demo_txt );
mikrobus_logWrite( "- VBAT:", _LOG_TEXT );
mikrobus_logWrite( demo_txt, _LOG_TEXT );
mikrobus_logWrite( " mV", _LOG_LINE );
temp_data = balancer5_read_data( BALANCER5_REG_VBUS_ADC1 );
temp_uint_data = temp_data;
temp_uint_data <<= 8;
temp_data = balancer5_read_data( BALANCER5_REG_VBUS_ADC0 );
temp_uint_data |= temp_data;
IntToStr( temp_uint_data, demo_txt );
mikrobus_logWrite( "- VBUS:", _LOG_TEXT );
mikrobus_logWrite( demo_txt, _LOG_TEXT );
mikrobus_logWrite( " mV", _LOG_LINE );
temp_data = balancer5_read_data( BALANCER5_REG_VCELLTOP_ADC1 );
temp_uint_data = temp_data;
temp_uint_data <<= 8;
temp_data = balancer5_read_data( BALANCER5_REG_VCELLTOP_ADC0 );
temp_uint_data |= temp_data;
IntToStr( temp_uint_data, demo_txt );
mikrobus_logWrite( "- VCELLTOP:", _LOG_TEXT );
mikrobus_logWrite( demo_txt, _LOG_TEXT );
mikrobus_logWrite( " mV", _LOG_LINE );
temp_data = balancer5_read_data( BALANCER5_REG_VCELLBOT_ADC1 );
temp_uint_data = temp_data;
temp_uint_data <<= 8;
temp_data = balancer5_read_data( BALANCER5_REG_VCELLBOT_ADC0 );
temp_uint_data |= temp_data;
IntToStr( temp_uint_data, demo_txt );
mikrobus_logWrite( "- VCELLBOT:", _LOG_TEXT );
mikrobus_logWrite( demo_txt, _LOG_TEXT );
mikrobus_logWrite( " mV", _LOG_LINE );
temp_data = balancer5_read_data( BALANCER5_REG_TS_ADC1 );
temp_uint_data = temp_data;
temp_uint_data <<= 8;
temp_data = balancer5_read_data( BALANCER5_REG_TS_ADC0 );
temp_uint_data |= temp_data;
temp_float_data = temp_uint_data;
temp_float_data *= 0.098;
FloatToStr( temp_float_data, demo_txt );
mikrobus_logWrite( "- TS:", _LOG_TEXT );
mikrobus_logWrite( demo_txt, _LOG_TEXT );
mikrobus_logWrite( " %", _LOG_LINE );
temp_data = balancer5_read_data( BALANCER5_REG_TDIE_ADC1 );
temp_uint_data = temp_data;
temp_uint_data <<= 8;
temp_data = balancer5_read_data( BALANCER5_REG_TDIE_ADC0 );
temp_uint_data |= temp_data;
temp_float_data = temp_uint_data;
temp_float_data *= 0.5;
FloatToStr( temp_float_data, demo_txt );
mikrobus_logWrite( "- TDIE:", _LOG_TEXT );
mikrobus_logWrite( demo_txt, _LOG_TEXT );
mikrobus_logWrite( log_degree, _LOG_LINE );
mikrobus_logWrite( "____________________", _LOG_LINE );
Delay_ms( 5000 );
}
Additional Functions :
The full application code, and ready to use projects can be found on our LibStock page.
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. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.