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 (139566 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57256 times)
  4. USB Device Library (47631 times)
  5. Network WiFi Library (43220 times)
  6. FT800 Library (42566 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26933 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

PAC1944 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.14

mikroSDK Library: 2.0.0.0

Category: Measurements

Downloaded: 201 times

Not followed.

License: MIT license  

PAC1944 Click is a compact add-on board that contains an energy monitoring solution. This board features the PAC1944, a multi-channel DC power/energy monitor from Microchip Technology. It uses real-time calibration to minimize offset and gain errors with no input filters required for this device.

No Abuse Reported

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

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

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

  • Information
  • Comments (0)

mikroSDK Library Blog


PAC1944 Click

PAC1944 Click is a compact add-on board that contains an energy monitoring solution. This board features the PAC1944, a multi-channel DC power/energy monitor from Microchip Technology. It uses real-time calibration to minimize offset and gain errors with no input filters required for this device.

pac1944_click.png

Click Product page


Click library

  • Author : Stefan Nikolic
  • Date : dec 2020.
  • Type : I2C type

Software Support

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

Standard key functions :

  • pac1944_cfg_setup Config Object Initialization function.

    void pac1944_cfg_setup ( pac1944_cfg_t *cfg );
  • pac1944_init Initialization function.

    PAC1944_RETVAL pac1944_init ( pac1944_t *ctx, pac1944_cfg_t *cfg );
  • pac1944_default_cfg Click Default Configuration function.

    void pac1944_default_cfg ( pac1944_t *ctx );

Example key functions :

  • pac1944_setup_config PAC1944 setup config function.

    void pac1944_setup_config ( pac1944_t *ctx, pac1944_setup_t cfg_data );
  • pac1944_refresh_cmd PAC1944 refresh command.

    void pac1944_refresh_cmd ( pac1944_t *ctx );
  • pac1944_get_calc_measurement PAC1944 get calculated measurement function.

    float pac1944_get_calc_measurement ( pac1944_t *ctx, uint8_t meas_sel, uint8_t ch_sel, uint8_t avg_sel, uint8_t meas_mode );

Examples Description

This demo application shows an example of measuring voltage, current and power in a selected part of the circuit. Note that PAC1944 is a high side power monitor, therefore the desired channel should be connected accordingly.

The demo application is composed of two sections :

Application Init

Initialization of I2C module, log UART and additional pins. In addition, a default configuration is performed as followed:

  • Sample mode is 1024, adaptive accumulation;
  • INT pin is set as an alert;
  • SLW pin is set as slow sampling rate control;
  • All channels are on;
  • Channel 1 is set for bipolar measurements;
  • Channel 2 is set for bipolar measurements reduced by half;
  • Channel 3 and 4 are set for unipolar measurements.
void application_init ( void ) {
    log_cfg_t log_cfg;  /**< Logger config object. */
    pac1944_cfg_t pac1944_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.

    pac1944_cfg_setup( &pac1944_cfg );
    PAC1944_MAP_MIKROBUS( pac1944_cfg, MIKROBUS_1 );
    err_t init_flag = pac1944_init( &pac1944, &pac1944_cfg );
    if ( init_flag == I2C_MASTER_ERROR ) {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    pac1944_device_state( &pac1944, PAC1944_DEV_ENABLE );
    Delay_ms ( 100 );
    pac1944_default_cfg ( &pac1944 );
    log_info( &logger, " Application Task " );
    log_printf( &logger, "-----------------------------\r\n" );
    Delay_ms ( 100 );
}

Application Task

The application sends a refresh command which stores the measurement data in registers. Measurements are acquired for voltage, current and power on channel 1 of PAC1944 Click board. The last 8 measurements are averaged and calculated in bipolar mode. Process is repeated every two seconds.

void application_task ( void ) {
    float voltage_sens;
    float current_sens;
    float power_sens;

    pac1944_refresh_cmd( &pac1944 );

    voltage_sens = pac1944_get_calc_measurement( &pac1944, PAC1944_MEAS_SEL_V_SOURCE,
                                                           PAC1944_CH_SEL_CH_1,
                                                           PAC1944_AVG_SEL_ENABLE,
                                                           PAC1944_MEAS_MODE_BIPOLAR_FSR );

    current_sens = pac1944_get_calc_measurement( &pac1944, PAC1944_MEAS_SEL_I_SENSE,
                                                           PAC1944_CH_SEL_CH_1,
                                                           PAC1944_AVG_SEL_ENABLE,
                                                           PAC1944_MEAS_MODE_BIPOLAR_FSR );

    power_sens = pac1944_get_calc_measurement( &pac1944,   PAC1944_MEAS_SEL_P_SENSE,
                                                           PAC1944_CH_SEL_CH_1,
                                                           PAC1944_AVG_SEL_ENABLE,
                                                           PAC1944_MEAS_MODE_BIPOLAR_FSR );


    log_printf( &logger, "  Voltage :  %.6f   V \r\n", voltage_sens );
    log_printf( &logger, "  Current :  %.6f   A \r\n", current_sens );
    log_printf( &logger, "  Power   :  %.6f   W \r\n", power_sens );
    log_printf( &logger, "-----------------------------\r\n" );
    Delay_ms ( 1000 );
    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.PAC1944

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

G2C 3G click

5

Go to Cloud (G2C) 3G click is a gateway Click boardâ„¢ which provides a simple and reliable connection to the Click Cloud platform, a cloud-based rapid prototyping environment, hosted by Mikroe.

[Learn More]

ECG GSR Click

0

ECG GSR Click is a complete solution for PPG, ECG and GSR application development, utilizing a specialized IC with a clinical-grade analog front-end (AFE) and electrical front-end. ECG GSR Click uses the AS7030B IC, an ultra-low power, multi-channel bio-sensor, which features a wide range of different options, making it an ideal solution for development of blood oxygen level, heart rate and galvanic skin response monitoring applications, fitness applications, for the ECG bio-authentication, and similar applications related to heart monitoring. ECG GSR Click is also equipped with the 3.5mm electrodes connectors, making it ready to be used out of the box.

[Learn More]

VREG 2 Click

0

VREG 2 Click is a voltage regulator Click, with outstanding performances.

[Learn More]