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-09-06
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Battery Charger
Downloaded: 2656 times
Not followed.
License: MIT license
BATT-MON Click is a very versatile, high accuracy, multiple-chemistry battery gauge for applications single-cell batteries.
Do you want to subscribe in order to receive notifications regarding "BattMon click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "BattMon click" changes.
Do you want to report abuse regarding "BattMon click".
Library Description
This library allows user to perform a battery monitoring. User can get battery voltage, battery current, temperature, SOC, OCV value from the device. This library offers a choice to set SOC and voltage alarm value and to check alarm interrupt status. For more details check documentation.
Key functions:
T_BATTMON_RETVAL battmon_readBytes( uint8_t regAddr, uint8_t *dataOut, uint8_t nBytes )
- This function reads the desired number of bytes starting from the selected register.T_BATTMON_RETVAL battmon_writeByte( uint8_t regAddr, uint8_t dataIn )
- This function writes one byte data to the selected register.float battmon_getData( uint8_t data_addr )
- This function allows user to get the desired data calculated to the properly unit.Examples description
The application is composed of three sections :
void applicationTask()
{
conv_cnt = battmon_getData( _BATTMON_REG_COUNTER );
if (((conv_cnt % 4) == 0) && (conv_cnt > 0))
{
data_read = battmon_getData( _BATTMON_REG_SOC );
FloatToStr( data_read, text );
floatCut();
mikrobus_logWrite( "** Gas Gauge Relative SOC : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_TEXT );
mikrobus_logWrite( " %", _LOG_LINE );
data_read = battmon_getData( _BATTMON_REG_CURRENT );
FloatToStr( data_read, text );
floatCut();
mikrobus_logWrite( "** Battery Current : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_TEXT );
mikrobus_logWrite( " mA", _LOG_LINE );
data_read = battmon_getData( _BATTMON_REG_VOLTAGE );
FloatToStr( data_read, text );
floatCut();
mikrobus_logWrite( "** Battery Voltage : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_TEXT );
mikrobus_logWrite( " mV", _LOG_LINE );
if ((conv_cnt % 16) == 0)
{
data_read = battmon_getData( _BATTMON_REG_TEMPERATURE );
battmon_reset_conv_cnt();
FloatToStr( data_read, text );
floatCut();
mikrobus_logWrite( "** Temperature : ", _LOG_TEXT );
mikrobus_logWrite( text, _LOG_TEXT );
mikrobus_logWrite( cels_symbol, _LOG_LINE );
}
reg_read = battmon_check_clear_alarm();
if ((reg_read & _BATTMON_ALM_SOC_DET_MASK) != _BATTMON_LOG_LOW)
{
mikrobus_logWrite( "** Low-SOC Condition!", _LOG_LINE );
alarmPlay();
}
if ((reg_read & _BATTMON_ALM_VOLT_DET_MASK) != _BATTMON_LOG_LOW)
{
mikrobus_logWrite( "** Low-Voltage Condition!", _LOG_LINE );
alarmPlay();
}
mikrobus_logWrite( "*********************************", _LOG_LINE );
Delay_ms( 1000 );
}
else
{
Delay_ms( 200 );
}
}
Additional Functions :
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.