Our groundbreaking power monitoring solution is designed to provide unrivaled accuracy in measuring and monitoring voltage and current values, ensuring optimal performance and efficiency in your electrical systems.
A
A
Hardware Overview
How does it work?
PWR Meter 2 Click is based on the MCP3910, an integrated two-channel analog front-end (AFE) device from Microchip. This IC is composed of several sections, aimed at accurate capturing of the input voltage. Two sigma-delta input A/D converters used with the internal reference voltage of 1.2V with very low thermal drift, reducing the measurement noise at a minimum, yielding Signal to Noise ratio (SNR) up to 96dB. The input ADCs are fully configurable and can be set to work in 16-bit or 24-bit mode, can use oversampling ratio from 32 X up to 4096 X, gain ratio from 1 X to 32 X, and 24-bit digital offset and gain error correction for each ADC channel. The Click board™ is clocked by a 20MHz crystal. However, it is up to the user to set the pre-scalers correctly, according to the datasheet of the MCP3910. However, the included library offers functions which take care about correct settings. High clock speed allows maximum oversampling rate (OSR) to be used, allowing the best performance to be achieved, but consuming more power at the same time. The voltage and current readings are performed over two differential ADC input channels of the MCP3910 itself. The CH0 (Channel 0) is connected to a resistor voltage
divider, allowing it to measure up to 0.6V when the input voltage is 24V, which is the maximum voltage at the input terminal. Although the voltage across a differential input on the ADC channel can go up to ±2V, it is recommended by the manufacturer to stay within the ±0.6V margin to achieve optimal harmonic distortion and noise ratios, which might affect the measurement accuracy. The CH1 (Channel 1) differential input is connected to the shunt resistor of 0.03 Ω. A small voltage drop is measured by the ADC, allowing up to 5A of current to be measured. More of 5A might destroy the shunt resistor so it is not recommended going over 5A. The current measurement is done by connecting the load in series with the Click board™, so the shunt value of 0.03Ω will not introduce significant error or influence the current through the load. The measurement is performed using so-called Kelvin connections, where the main trace carries the majority of the current, while thin traces are used to measure the voltage across the shunt, reducing the current running through the ADC section of the IC itself. Additional 270 Ω resistors reduce the current through the ADC even further. The MCP3910 contains several additional pins, which
are used to simplify the implementation and reduce the bulkiness of the firmware application. The Data Ready pin can be used to trigger an interrupt event on the host MCU when there is conversion data ready to be read. This simplifies the MCU performance greatly, saving it from having to poll status bits in order to determine if the data is ready for reading. The Data Ready pin is routed to the mikroBUS™ INT pin, labeled as the DR. Two Modulator Output pins are also routed to the mikroBUS™. These pins offer direct 1-bit data output directly from the delta-sigma modulators for a user-defined MCU or DSP filtering, overriding the internal SINC filter, which is turned off if these pins are activated. The DR pin is also disabled when these pins are enabled. MDAT0 and MDAT1 pins offer modulator output from ADC channel 0 and ADC channel 1. These pins are routed to mikroBUS™ pins PWM and AN and are labeled as MDT0 and MDT1, respectively. As already mentioned, the Click board™ offers measurement of either internal power supply from the mikroBUS™, or the externally with up to 24V and 5A. To select the measurement target, the SMD jumper labeled INPUT SEL should be switched to the desired position.
Features overview
Development board
Clicker 2 for PIC18FK is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 8-bit PIC microcontroller, the PIC18F67K40 from Microchip, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a mikroProg connector, and two 26-pin headers for interfacing with external electronics. Its compact design with clear and easily recognizable silkscreen markings allows you to build gadgets with unique functionalities and features quickly.
Each part of the Clicker 2 for PIC18FK development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the Clicker 2 for PIC18FK programming method: using UART mikroBootloader, an external mikroProg connector for PIC18FK programmer, or through Xpress bootloader, the Clicker 2 board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Micro-B cable, where onboard voltage regulators provide the appropriate voltage levels to each component
on the board, or using a Li-Polymer battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several user-configurable buttons and LED indicators. Clicker 2 for PIC18FK is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU
Architecture
PIC
MCU Memory (KB)
128
Silicon Vendor
Microchip
Pin count
64
RAM (Bytes)
3562
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output
After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.
After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.
Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.
Software Support
Library Description
This library contains API for PWR Meter 2 Click driver.
Key functions:
pwrmeter2_get_data
- This function gets the calculated voltage( V ), current( A ) and power( W ) datapwrmeter2_write_reg
- This function writes 24-bit data to the registerpwrmeter2_read_reg
- This function reads the desired number of 24-bit data from the register/registers.
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* \file
* \brief PwrMeter2 Click example
*
* # Description
* This app measuring and monitoring voltage up to 24V and current up to 5A.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes device.
*
* ## Application Task
* Gets calculated voltage, current and power data every 500 milliseconds
* and shows results on UART.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "pwrmeter2.h"
// ------------------------------------------------------------------ VARIABLES
static pwrmeter2_t pwrmeter2;
static log_t logger;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
pwrmeter2_cfg_t pwrmeter2_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.
pwrmeter2_cfg_setup( &pwrmeter2_cfg );
PWRMETER2_MAP_MIKROBUS( pwrmeter2_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == pwrmeter2_init( &pwrmeter2, &pwrmeter2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( PWRMETER2_ERROR == pwrmeter2_default_cfg ( &pwrmeter2 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
float voltage = 0;
float current = 0;
float power = 0;
if ( PWRMETER2_OK == pwrmeter2_get_data( &pwrmeter2, &voltage, ¤t, &power ) )
{
log_printf( &logger, " U = %.3f V\r\n", voltage );
log_printf( &logger, " I = %.3f A\r\n", current );
log_printf( &logger, " P = %.3f W\r\n\n", power );
Delay_ms ( 500 );
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END