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 (136806 times)
  2. FAT32 Library (69983 times)
  3. Network Ethernet Library (55951 times)
  4. USB Device Library (46274 times)
  5. Network WiFi Library (41892 times)
  6. FT800 Library (41191 times)
  7. GSM click (28990 times)
  8. PID Library (26420 times)
  9. mikroSDK (26376 times)
  10. microSD click (25382 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

PAC1954 click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.8

mikroSDK Library: 2.0.0.0

Category: Measurements

Downloaded: 83 times

Not followed.

License: MIT license  

PAC1954 Click is a compact add-on board that contains an energy monitoring solution. This board features the PAC1954, a four-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 "PAC1954 click" changes.

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

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

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


PAC1954 click

PAC1954 Click is a compact add-on board that contains an energy monitoring solution. This board features the PAC1954, a four-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.

pac1954_click.png

click Product page


Click library

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

Software Support

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

Standard key functions :

  • pac1954_cfg_setup Config Object Initialization function.

    void pac1954_cfg_setup ( pac1954_cfg_t *cfg );
  • pac1954_init Initialization function.

    err_t pac1954_init ( pac1954_t *ctx, pac1954_cfg_t *cfg );
  • pac1954_default_cfg Click Default Configuration function.

    err_t pac1954_default_cfg ( pac1954_t *ctx );

Example key functions :

  • pac1954_refresh_cmd This function updates the readable registers for the VBUS, VSENSE, Power, accumulator outputs and accumulator count by issuing the REFRESH command. The values will be static until the next REFRESH command.

    err_t pac1954_refresh_cmd ( pac1954_t *ctx );
  • pac1954_get_calc_measurement This function calls the function for getting the selected measurement data and performs all the necessary calculations to get the measurement value in standard unit.

    err_t pac1954_get_calc_measurement ( pac1954_t *ctx, uint8_t meas_sel, uint8_t ch_sel, uint8_t avg_sel, uint8_t meas_mode, float *data_out );
  • pac1954_generic_write This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

    err_t pac1954_generic_write ( pac1954_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );

Example Description

This example demonstrates the use of PAC1954 click board.

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. */
    pac1954_cfg_t pac1954_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.
    pac1954_cfg_setup( &pac1954_cfg );
    PAC1954_MAP_MIKROBUS( pac1954_cfg, MIKROBUS_1 );
    err_t init_flag = pac1954_init( &pac1954, &pac1954_cfg );
    if ( I2C_MASTER_ERROR == init_flag ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

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

Application Task

Reads the voltage, current, and power from Channel 1 and displays all values on the USB UART once per second.


void application_task ( void )
{
    float vsource = 0;
    float isense = 0;
    float power = 0;

    pac1954_refresh_cmd ( &pac1954 );

    pac1954_get_calc_measurement ( &pac1954, PAC1954_MEAS_SEL_V_SOURCE, 
                                             PAC1954_CH_SEL_CH_1, 
                                             PAC1954_AVG_SEL_ENABLE, 
                                             PAC1954_MEAS_MODE_BIPOLAR_FSR,
                                             &vsource );
    pac1954_get_calc_measurement ( &pac1954, PAC1954_MEAS_SEL_I_SENSE, 
                                             PAC1954_CH_SEL_CH_1, 
                                             PAC1954_AVG_SEL_ENABLE, 
                                             PAC1954_MEAS_MODE_BIPOLAR_FSR, 
                                             &isense );
    pac1954_get_calc_measurement ( &pac1954, PAC1954_MEAS_SEL_P_SENSE, 
                                             PAC1954_CH_SEL_CH_1, 
                                             0, 
                                             PAC1954_MEAS_MODE_BIPOLAR_FSR, 
                                             &power );

    log_printf( &logger, " Voltage: %.3f V\r\n", vsource );
    log_printf( &logger, " Current: %.3f A\r\n", isense );
    log_printf( &logger, " Power: %.3f W\r\n", power );
    log_printf( &logger, "---------------------------\r\n" );
    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.PAC1954

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

Multi Stepper TB62261 click

0

Multi Stepper Click is a compact add-on board that contains a bipolar stepper motor driver. This board features the TB62261FTG, a PHASE-in controlled bipolar stepping motor driver from Toshiba Semiconductor. It supports a PWM constant-current control drive and full-, half-, and quarter-step operation for less motor noise and smoother control. It has a wide operating voltage range of 10V to 38V with an output current capacity of 1.2A in addition to several built-in error detection circuits.

[Learn More]

Inclinometer 2 click

0

Inclinometer 2 Click is a compact add-on board that measures the orientation angle of an object with respect to the force of gravity. This board features the IIS2ICLX, high accuracy, and resolution two-axis inclinometer from STMicroelectronics. It allows selectable full-scale measurements in ranges of ±0.5/±1/±2/±3g in two axes with a configurable host interface that supports both SPI and I2C serial communication. The sensing element is manufactured using a dedicated micromachining process developed by STMicroelectronics to produce inertial sensors and actuators on silicon wafers.

[Learn More]

Thermo 8 click

5

Thermo 8 click is a very accurate thermometer Click board, with a very high typical measurement accuracy of ±0.25°C, and great data repeatability of ±0.0625°C. Besides measuring the temperature, this Click board offers a set of very useful features, such as the thermostat function, interrupt event and critical temperature alert function.

[Learn More]