TOP Contributors

  1. MIKROE (2665 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 (137160 times)
  2. FAT32 Library (70288 times)
  3. Network Ethernet Library (56159 times)
  4. USB Device Library (46482 times)
  5. Network WiFi Library (42150 times)
  6. FT800 Library (41450 times)
  7. GSM click (29146 times)
  8. mikroSDK (26595 times)
  9. PID Library (26519 times)
  10. microSD click (25529 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: 2337 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

STSPIN233 click

0

STSPIN233 click is a complete solution for a 3-phase integrated motor driver, based on the STSPIN233, Low voltage 3-phase integrated motor driver.

[Learn More]

AD-SWIO 2 click

5

AD-SWIO 2 Click is a Click board equipped with the AD74413R, from Analog Devices. The AD74413R is a quad-channel software configurable input/output solution for building and process control applications. The device provides a fully integrated single chip solution for input and output operation.

[Learn More]

LTE Cat.1-EU click

0

LTE Cat.1-EU click is a Click board™ based on Thales Cinterion® ELS61 wireless module that delivers highly efficient Cat 1 LTE connectivity for M2M IoT solutions offering seamless fall back to 2G and 3G networks. The best in class solution enables M2M optimized speeds of 10Mbit/s download and 5Mbit/s uplink making it ideal for the vast number of M2M and industrial IoT applications that are not dependent on speed but that requires the longevity of LTE networks, while still providing 3G and 2G connectivity to ensure complete population and geographic coverage as LTE rolls out.

[Learn More]