Experience the future of power management with our DC energy monitor, designed to simplify energy tracking and optimize your lifestyle
A
A
Hardware Overview
How does it work?
PAC1944 Click is based on the PAC1944, a four-channel, bidirectional, high-side current-sensing solution with precision voltage measurement capabilities, DSP for power calculation, and a power accumulator from Microchip Technology. Its real-time calibration minimizes offset and gain errors. Four current sense shunt resistors are connected to PAC1944’s integrated current sense amplifier. Electricity is brought to shunts via screw terminals where the middle screw connector represents GND used for bus voltage monitoring. Bus voltage, sense resistor voltage, and accumulated proportional power are stored in registers for retrieval by the MCU. One major feature of the PAC1944 design is a set of digital comparators that allows the user to detect over/under voltage, over/undercurrent, and overpower against user-programmed limits for each channel and generate an alert when the threshold is exceeded. The digital circuitry of the PAC1944 performs power calculations and energy accumulation, which enables energy monitoring with integration periods of up to one year or longer. After the Start-Up sequence, the
PAC1944 is Active and begins sampling the inputs sequentially. Voltage and current are sampled for all active channels at 1024 samples/second by default, and power is calculated and accumulated. PAC1944 Click communicates with MCU using the standard I2C 2-Wire interface to read data and configure settings, supporting Fast Mode operation with a clock frequency up to 1MHz and High-Speed Mode up to 3.4MHz. Besides, it also allows the choice of the least significant bit of its I2C slave address by positioning the SMD jumper labeled ADDR SEL to an appropriate position marked as 0 and 1. The Power-Down pin, labeled as EN and routed to the CS pin of the mikroBUS™ socket, optimizes power consumption and is used for power on/off purposes. All circuits, including the interface pins, are inactive in this state, and the PAC1944 is in the form of minimum power dissipation. The SLW pin, routed to the RST pin of the mikroBUS™ socket, serves as the conversion rate control. If the SLW pin is asserted, the sample rate is eight samples per second. For sampling rates lower than 1024 samples/second, the PAC1944 is in Sleep mode for a portion of the
conversion cycle, which results in lower power dissipation. No matter the programmed sample rate, this new sample rate will affect the following conversion cycle. The alert functionality, routed to the INT pin of the mikroBUS™ socket, has multiple purposes: to notify the system that a conversion cycle for all active channels is complete, or to inform the system that the accumulator or accumulator count has overflowed, or that an electrical parameter is outside the programmed limit. Besides the INT pin, the SLW pin can function as another alert feature by attaching a pull-up resistor to it, which is done via an onboard SMD jumper labeled as SLW PULL by positioning a 10k resistor to an appropriate position marked as DOWN or UP. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.
Features overview
Development board
Curiosity PIC32 MZ EF development board is a fully integrated 32-bit development platform featuring the high-performance PIC32MZ EF Series (PIC32MZ2048EFM) that has a 2MB Flash, 512KB RAM, integrated FPU, Crypto accelerator, and excellent connectivity options. It includes an integrated programmer and debugger, requiring no additional hardware. Users can expand
functionality through MIKROE mikroBUS™ Click™ adapter boards, add Ethernet connectivity with the Microchip PHY daughter board, add WiFi connectivity capability using the Microchip expansions boards, and add audio input and output capability with Microchip audio daughter boards. These boards are fully integrated into PIC32’s powerful software framework, MPLAB Harmony,
which provides a flexible and modular interface to application development a rich set of inter-operable software stacks (TCP-IP, USB), and easy-to-use features. The Curiosity PIC32 MZ EF development board offers expansion capabilities making it an excellent choice for a rapid prototyping board in Connectivity, IOT, and general-purpose applications.
Microcontroller Overview
MCU Card / MCU
Architecture
PIC32
MCU Memory (KB)
2048
Silicon Vendor
Microchip
Pin count
100
RAM (Bytes)
524288
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic
Step by step
Project assembly
Track your results in real time
Application Output
This Click board can be interfaced and monitored in two ways:
Application Output
- Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
UART Terminal
- Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Software Support
Library Description
This library contains API for PAC1944 Click driver.
Key functions:
pac1944_setup_config
- PAC1944 setup config functionpac1944_refresh_cmd
- PAC1944 refresh commandpac1944_get_calc_measurement
- PAC1944 get calculated measurement function.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* @file main.c
* @brief PAC1944 Click example
*
* # 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.
*
* ## 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.
*
* @author Stefan Nikolic
*
*/
#include "board.h"
#include "log.h"
#include "pac1944.h"
static pac1944_t pac1944;
static log_t logger;
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 );
}
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( 2000 );
}
void main ( void ) {
application_init( );
for ( ; ; ) {
application_task( );
}
}
// ------------------------------------------------------------------------ END