TOP Contributors

  1. MIKROE (2653 codes)
  2. Alcides Ramos (351 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136668 times)
  2. FAT32 Library (69905 times)
  3. Network Ethernet Library (55921 times)
  4. USB Device Library (46250 times)
  5. Network WiFi Library (41882 times)
  6. FT800 Library (41128 times)
  7. GSM click (28973 times)
  8. PID Library (26406 times)
  9. mikroSDK (26345 times)
  10. microSD click (25350 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

BattMon click

Rating:

5

Author: MIKROE

Last Updated: 2019-09-06

Package Version: 1.0.0.0

mikroSDK Library: 1.0.0.0

Category: Battery Charger

Downloaded: 2257 times

Not followed.

License: MIT license  

BATT-MON Click is a very versatile, high accuracy, multiple-chemistry battery gauge for applications single-cell batteries.

No Abuse Reported

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".

  • mikroSDK Library 2.0.0.0
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

BATT-MON Click

BATT-MON Click

Native view of the BATT-MON Click board.

View full image
BATT-MON Click

BATT-MON Click

Front and back view of the BATT-MON Click board.

View full image

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 :

  • System Initialization - Initializes peripherals and pins.
  • Application Initialization - Initializes I2C serial interface, reads the part ID and performs a device configuration and alarm setting.
  • Application Task - (code snippet) - Checks the conversion counter value and when conversion was done reads data calculated to the properly unit and checks the alarm status. All results will be sent to the uart terminal. Note: Voltage and current conversion will be done after 4 seconds. Temperature conversion will be done after 16 seconds. After temperature reading the conversion counter will be cleared. Clearing the alarm while the corresponding low-voltage or low-SOC condition is still in progress does not generate another interrupt. This condition must disappear first and must be detected again before another interrupt (ALM pin driven low or alarm interrupt bits are set high) is generated for this alarm. Another alarm condition, if not yet triggered, can still generate an interrupt. Input voltage must be in the range from 2.7V to 4.5V. Maximal battery current is 5A.
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 :

  • floatCut - Allows to real values be rounded on two decimal places.
  • alarmPlay - Makes sound on buzzer for alarm detection.

Other mikroE Libraries used in the example:

  • Conversions
  • I2C
  • Sound
  • UART

Additional notes and informations

Depending on the development board you are using, you may need USB UART clickUSB 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.

ALSO FROM THIS AUTHOR

Mosaic click

0

Mosaic Click is a compact add-on board for precision navigation and location-based applications. This board features the Mosaic-X5, a compact global navigation satellite system (GNSS) receiver from Septentrio. The Mosaic-X5 stands out for its multi-band and multi-constellation tracking ability, ensuring robust and comprehensive global coverage. It features Septentrio's AIM+ technology for superior interference mitigation, enabling it to counteract a wide range of signal disruptions.

[Learn More]

Temp-Log 4 click

0

Temp-Log 4 Click is a temperature measuring Click board™ featuring the SE97B IC, an accurate temperature sensor IC with integrated EEPROM.

[Learn More]

Secure 4 Click

0

Secure 4 click includes the ATECC608A, a secure CryptoAuthenticatio device from Microchip, which is equipped with an EEPROM array which can be used for storing of up to 16 keys, certificates, consumption logging, security configurations and other types of secure data.

[Learn More]