TOP Contributors

  1. MIKROE (2656 codes)
  2. Alcides Ramos (353 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 (136871 times)
  2. FAT32 Library (70000 times)
  3. Network Ethernet Library (55999 times)
  4. USB Device Library (46303 times)
  5. Network WiFi Library (41910 times)
  6. FT800 Library (41206 times)
  7. GSM click (29012 times)
  8. PID Library (26423 times)
  9. mikroSDK (26394 times)
  10. microSD click (25385 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

Charger click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.2

mikroSDK Library: 2.0.0.0

Category: Battery Charger

Downloaded: 12 times

Not followed.

License: MIT license  

Charger Click is a compact add-on board providing a standalone battery charger and monitor. This board features Microchip's MCP73831, a miniature single-cell, fully integrated Li-Ion, Li-Polymer charge management controller. The charge voltage of the MCP73831 is set to 4.20V, and a charge current to 250mA with an external resistor. In addition, this Click board™ features the DS2438, a smart battery monitor that monitors the total amount of current going into and out of the battery.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Charger click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Charger click" changes.

Do you want to report abuse regarding "Charger click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


Charger click

Charger Click is a compact add-on board providing a standalone battery charger and monitor. This board features Microchip's MCP73831, a miniature single-cell, fully integrated Li-Ion, Li-Polymer charge management controller. The charge voltage of the MCP73831 is set to 4.20V, and a charge current to 250mA with an external resistor. In addition, this Click board™ features the DS2438, a smart battery monitor that monitors the total amount of current going into and out of the battery.

charger_click.png

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Feb 2024.
  • Type : One Wire type

Software Support

We provide a library for the Charger Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for Charger Click driver.

Standard key functions :

  • charger_cfg_setup Config Object Initialization function.

    void charger_cfg_setup ( charger_cfg_t *cfg );
  • charger_init Initialization function.

    err_t charger_init ( charger_t *ctx, charger_cfg_t *cfg );
  • charger_default_cfg Click Default Configuration function.

    err_t charger_default_cfg ( charger_t *ctx );

Example key functions :

  • charger_read_temperature This function reads the chip internal temperature measurement in degrees Celsius.

    err_t charger_read_temperature ( charger_t *ctx, float *temperature );
  • charger_read_batt_vdd This function reads the battery input voltage.

    err_t charger_read_batt_vdd ( charger_t *ctx, float *voltage );
  • charger_read_current This function reads the battery charging current.

    err_t charger_read_current ( charger_t *ctx, float *current );

Example Description

This example demonstrates the use of Charger click board by monitoring the battery charging status.

The demo application is composed of two sections :

Application Init

Initializes the driver, performs the click default configuration, calibrates the zero current charging offset, and resets the elapsed time counter.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    charger_cfg_t charger_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    charger_cfg_setup( &charger_cfg );
    CHARGER_MAP_MIKROBUS( charger_cfg, MIKROBUS_1 );
    if ( ONE_WIRE_ERROR == charger_init( &charger, &charger_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( CHARGER_ERROR == charger_default_cfg ( &charger ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_printf( &logger, "\r\n Zero current calibration process\r\n" );
    log_printf( &logger, " Keep the battery disconnected in the next 5 seconds\r\n" );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    if ( CHARGER_ERROR == charger_calibrate_current ( &charger ) )
    {
        log_error( &logger, " Calibration." );
        for ( ; ; );
    }
    log_printf( &logger, " Calibration done!\r\n\n" );

    if ( CHARGER_OK == charger_write_elapsed_time ( &charger, 0 ) )
    {
        log_printf( &logger, " Elapsed time reset done!\r\n\n" );
    }

    log_info( &logger, " Application Task " );
}

Application Task

Reads the chip internal temperature, battery and system VDD, battery charging current, and the elapsed time counter, approximately once per second. All data are displayed on the USB UART where you can track their changes.

void application_task ( void )
{
    float temperature = 0;
    float batt_vdd = 0;
    float system_vdd = 0;
    float current = 0;
    uint32_t elapsed_time = 0;
    if ( CHARGER_OK == charger_read_temperature ( &charger, &temperature ) )
    {
        log_printf( &logger, " Temperature: %.2f degC\r\n", temperature );
    }
    if ( CHARGER_OK == charger_read_batt_vdd ( &charger, &batt_vdd ) )
    {
        log_printf( &logger, " Battery VDD: %.3f V\r\n", batt_vdd );
    }
    if ( CHARGER_OK == charger_read_system_vdd ( &charger, &system_vdd ) )
    {
        log_printf( &logger, " System VDD: %.3f V\r\n", system_vdd );
    }
    if ( CHARGER_OK == charger_read_current ( &charger, &current ) )
    {
        log_printf( &logger, " Charging current: %.3f A\r\n", current );
    }
    if ( CHARGER_OK == charger_read_elapsed_time ( &charger, &elapsed_time ) )
    {
        log_printf( &logger, " Elapsed time: %lu s\r\n\n", elapsed_time );
    }
    Delay_ms ( 1000 );
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Charger

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. UART terminal is available in all MikroElektronika compilers.


ALSO FROM THIS AUTHOR

GSM 3 click

5

GSM3 click carries SIM800H, a quad-band (850/900/1800/1900MHz) GSM/GPRS module that transmits voice, sms and data information. Utilizing the module’s full potential, GSM3 click also has an audio input/output connection pad (for a microphone and earphones, which can also be used as an FM antenna).

[Learn More]

SMS home alarm system

16

Build your own home-made SMS alarm system, with minimum expenses using StartUSB for PIC, Smart GM862 with Telit GM862 module and antenna, Motion Sensor and a wire jumpers.

[Learn More]

V to Hz 3 click

0

V to Hz 3 Click is a compact add-on board that converts an analog voltage input signal into a specific frequency pulse wave signal. This board features the AD7740, an ultrasmall synchronous voltage-to-frequency converter from Analog Devices. The AD7740 has a linear response, so applying a voltage from 3V up to 5V on its VIN terminal will generate the pulse with a frequency linearly proportional to the input voltage. It contains an integrated 2.5V bandgap reference defining the span of the VFC and can be overdriven using an external reference. The full-scale output frequency is synchronous with the input clock signal provided by the LTC6903 programmable oscillator, with a maximum input frequency of 1MHz. Based on the analog input value, the output frequency goes from 10% to 90% of the input frequency.

[Learn More]