TOP Contributors

  1. MIKROE (2779 codes)
  2. Alcides Ramos (376 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 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 (139563 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57254 times)
  4. USB Device Library (47615 times)
  5. Network WiFi Library (43219 times)
  6. FT800 Library (42556 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26930 times)
  10. microSD click (26309 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

PAC1720 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.12

mikroSDK Library: 2.0.0.0

Category: Measurements

Downloaded: 146 times

Not followed.

License: MIT license  

PAC1720 Click is a compact add-on board that contains an energy monitoring solution. This board features the PAC1720, an I2C configurable dual high-side bidirectional current sensing monitor with precision voltage measurement capabilities from Microchip Technology. The PAC1720 measures the voltage developed across external sense resistors to represent the high-side current of a battery or voltage regulator.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "PAC1720 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "PAC1720 Click" changes.

Do you want to report abuse regarding "PAC1720 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


PAC1720 Click

PAC1720 Click is a compact add-on board that contains an energy monitoring solution. This board features the PAC1720, an I2C configurable dual high-side bidirectional current sensing monitor with precision voltage measurement capabilities from Microchip Technology. The PAC1720 measures the voltage developed across external sense resistors to represent the high-side current of a battery or voltage regulator.

pac1720_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Oct 2021.
  • Type : I2C type

Software Support

We provide a library for the PAC1720 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 PAC1720 Click driver.

Standard key functions :

  • pac1720_cfg_setup Config Object Initialization function.

    void pac1720_cfg_setup ( pac1720_cfg_t *cfg );
  • pac1720_init Initialization function.

    err_t pac1720_init ( pac1720_t *ctx, pac1720_cfg_t *cfg );
  • pac1720_default_cfg Click Default Configuration function.

    err_t pac1720_default_cfg ( pac1720_t *ctx );

Example key functions :

  • pac1720_set_vsource_config This function sets the Voltage Source configuration (sample time and average samples) for the selected channel.

    err_t pac1720_set_vsource_config ( pac1720_t *ctx, pac1720_ch_sel_t ch, pac1720_sample_time_t stime, pac1720_avg_t avg );
  • pac1720_set_vsense_config This function sets the Voltage Sense configuration (sample time, average samples, and sampling range) for the selected channel.

    err_t pac1720_set_vsense_config ( pac1720_t *ctx, pac1720_ch_sel_t ch, pac1720_sample_time_t stime, pac1720_avg_t avg, pac1720_cs_rng_t cs_rng );
  • pac1720_get_measurements This function reads voltage, current, and power from the selected channel.

    err_t pac1720_get_measurements ( pac1720_t *ctx, pac1720_ch_sel_t ch, float *voltage, float *current, float *power );

Example Description

This example demonstrates the use of PAC1720 Click board by reading the voltage, current, and power from both available channels.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    pac1720_cfg_t pac1720_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.
    pac1720_cfg_setup( &pac1720_cfg );
    PAC1720_MAP_MIKROBUS( pac1720_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == pac1720_init( &pac1720, &pac1720_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( PAC1720_ERROR == pac1720_default_cfg ( &pac1720 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

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

Application Task

Reads the voltage, current, and power from both channels and displays the results on the USB UART approximately once per second.


void application_task ( void )
{
    float voltage = 0, current = 0, power = 0;

    if ( PAC1720_OK == pac1720_get_measurements ( &pac1720, PAC1720_CHANNEL_1, &voltage, &current, &power ) )
    {
        log_printf( &logger, " Channel 1:\r\n" );
        log_printf( &logger, " U: %.3fV, I: %.3fA, P: %.3fW\r\n", voltage, current, power );
    }

    if ( PAC1720_OK == pac1720_get_measurements ( &pac1720, PAC1720_CHANNEL_2, &voltage, &current, &power ) )
    {
        log_printf( &logger, " Channel 2:\r\n" );
        log_printf( &logger, " U: %.3fV, I: %.3fA, P: %.3fW\r\n\n", voltage, current, power  );
    }

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

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

Temp-Hum 13 click

10

Temp&amp;Hum 13 Click is a Click board which is perfectly suited for measuring the relative humidity (RH) and temperature. The Click boardâ„¢ is equipped with the HTU21DF, an accurate and reliable sensor IC, packed in a miniature 3x3mm DFN package.

[Learn More]

Altitude 6 Click

0

Altitude 6 Click is a compact add-on board that allows height measurement of an object or point related to sea level or ground level. This board features the MS5611-01BA03, a high-resolution barometric pressure sensor optimized for altimeter applications with an altitude resolution of 10 cm from TE Connectivity. It consists of a high linearity pressure sensor and an ultra-low power 24 bit ΔΣ ADC with internal factory calibrated coefficients. Also, it provides a precise digital 24-bit pressure and temperature value, different operation modes, and a configurable host interface that supports both SPI and I2C serial communication allowing the user to optimize for conversion speed and current consumption. The high accuracy and stability of both pressure and temperature signal of the MS5611-01BA03 make this Click board™ suitable for height sensing in medical and consumer applications, indoor navigation, mobile altimeter or barometer systems, and many more.

[Learn More]

SPI Extend Click

0

SPI Extend Click is a compact add-on board for applications that require extending the SPI communication bus over a long distance. This board features the LTC4332, an SPI slave extender device, from Analog Devices. Using a ±60V fault protected differential transceiver, the LTC4332 can transmit SPI data, including an interrupt signal, up to 2MHz over two twisted-pair cables.

[Learn More]