TOP Contributors

  1. MIKROE (2664 codes)
  2. Alcides Ramos (358 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 (137152 times)
  2. FAT32 Library (70288 times)
  3. Network Ethernet Library (56158 times)
  4. USB Device Library (46480 times)
  5. Network WiFi Library (42146 times)
  6. FT800 Library (41450 times)
  7. GSM click (29144 times)
  8. mikroSDK (26593 times)
  9. PID Library (26518 times)
  10. microSD click (25527 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: 2319 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

Thunder EMU click

0

Thunder EMU Click is a compact add-on board that can be used to emulate lightning. This board features circuits that generate an RF signal that mimics lightning strikes. It is a thunder emulator board that allows you to mimic lightning signals that can represent different distances, thus enabling you to debug your lightning detector application for all kinds of scenarios. The RF signal has an effective range of about 5 – 15cm from the emulator antenna of this Click board™ to the sensor antenna.

[Learn More]

Charger 8 click

0

Charger 8 Click is an intelligent Li-Ion battery charger, system power manager, and a battery fuel gauge Click board™.

[Learn More]

Charger 18 click

0

Charger 18 Click is a compact add-on board representing a single-cell battery charger. This board features the LTC3553, a micropower, highly integrated power management, and battery charger for single-cell Li-Ion/Polymer battery applications from Analog Devices. Designed specifically for USB applications, it also includes a PowerPath manager with automatic load prioritization and input current limit, a battery charger, and numerous internal protection features. It also indicates a battery charge state, and it comes with a synchronous 200mA buck regulator and a 150mA low dropout linear regulator (LDO).

[Learn More]