TOP Contributors

  1. MIKROE (2751 codes)
  2. Alcides Ramos (372 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (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 (139059 times)
  2. FAT32 Library (71589 times)
  3. Network Ethernet Library (56988 times)
  4. USB Device Library (47330 times)
  5. Network WiFi Library (43006 times)
  6. FT800 Library (42297 times)
  7. GSM click (29777 times)
  8. mikroSDK (27874 times)
  9. PID Library (26858 times)
  10. microSD click (26129 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: 2618 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

CANculator

5

CANculator is a software development tool used for easier CAN baud rate calculation and manipulation of the CAN bus parameters.

[Learn More]

Environment 2 Click

0

Environment 2 Click is a compact add-on board containing best-in-class SHT humidity and SGP air-quality sensing solutions from Sensirion. This board features SHT40 and SGP40, a high-accuracy ultra-low-power relative humidity, and a temperature sensor combined with MOx based gas sensor. The SHT40 sensor offers linearized digital output, provides constant temperature accuracy, up to 0.1°C, and shows the best performance when operated within the temperature and humidity range of 5-60°C and 20-80%RH, while the SGP40, a digital gas sensor, features a temperature-controlled micro hot-plate providing a humidity-compensated VOC-based indoor air quality signal. This Click board™ is suitable for indoor air quality and various temperature and humidity-related applications

[Learn More]

Index Counter click

5

Index Counter Click is a simple prototyping high precision Hall-Effect switch solution with direction detection.

[Learn More]