pac1720  2.0.0.0
Main Page

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.

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 :

Example key functions :

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;
pac1720_cfg_t pac1720_cfg;
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.


PAC1720_OK
@ PAC1720_OK
Definition: pac1720.h:220
pac1720_cfg_t
PAC1720 Click configuration object.
Definition: pac1720.h:203
pac1720_set_vsource_config
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 vsource config function.
pac1720_cs_rng_t
pac1720_cs_rng_t
PAC1720 current sensing range setting.
Definition: pac1720.h:272
application_task
void application_task(void)
Definition: main.c:65
pac1720_get_measurements
err_t pac1720_get_measurements(pac1720_t *ctx, pac1720_ch_sel_t ch, float *voltage, float *current, float *power)
PAC1720 get measurements function.
pac1720_avg_t
pac1720_avg_t
PAC1720 averaging setting.
Definition: pac1720.h:259
pac1720_sample_time_t
pac1720_sample_time_t
PAC1720 sample time setting.
Definition: pac1720.h:242
pac1720_set_vsense_config
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 set vsense config function.
PAC1720_CHANNEL_2
@ PAC1720_CHANNEL_2
Definition: pac1720.h:232
pac1720_init
err_t pac1720_init(pac1720_t *ctx, pac1720_cfg_t *cfg)
PAC1720 initialization function.
PAC1720_MAP_MIKROBUS
#define PAC1720_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: pac1720.h:167
application_init
void application_init(void)
Definition: main.c:29
pac1720_cfg_setup
void pac1720_cfg_setup(pac1720_cfg_t *cfg)
PAC1720 configuration object setup function.
pac1720_t
PAC1720 Click context object.
Definition: pac1720.h:180
PAC1720_CHANNEL_1
@ PAC1720_CHANNEL_1
Definition: pac1720.h:231
PAC1720_ERROR
@ PAC1720_ERROR
Definition: pac1720.h:221
pac1720_default_cfg
err_t pac1720_default_cfg(pac1720_t *ctx)
PAC1720 default configuration function.
pac1720_ch_sel_t
pac1720_ch_sel_t
PAC1720 channel selection.
Definition: pac1720.h:230