TOP Contributors

  1. MIKROE (2762 codes)
  2. Alcides Ramos (374 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (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 (139254 times)
  2. FAT32 Library (71751 times)
  3. Network Ethernet Library (57122 times)
  4. USB Device Library (47430 times)
  5. Network WiFi Library (43082 times)
  6. FT800 Library (42404 times)
  7. GSM click (29835 times)
  8. mikroSDK (28078 times)
  9. PID Library (26885 times)
  10. microSD click (26198 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

PWR Meter click

Rating:

5

Author: MIKROE

Last Updated: 2018-09-27

Package Version: 1.0.0.0

mikroSDK Library: 1.0.0.0

Category: Measurements

Downloaded: 5026 times

Not followed.

License: MIT license  

PWR Meter click is a power measurement Click board, capable of measuring voltage and current through the load, connected to either AC or DC power source.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "PWR Meter click" changes.

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

Do you want to report abuse regarding "PWR Meter click".

  • mikroSDK Library 2.0.0.0
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

PWR Meter click

PWR Meter click

Native view of the PWR Meter click board.

View full image
PWR Meter click

PWR Meter click

Front and back view of the PWR Meter click board.

View full image

Library Description

Library performs the communication with the device via uart interface by sending commands and checking response from the device to the host. Commands perform writting to the registers, reading from the registers (data can be 8bit, 16bit, or 32bit), calibration, writting to the EEPROM and reading from the EEPROM. By using functions for reading user can read measurements that include voltage RMS, current RMS, power data (active, reactive, apparent) and many other things. For more details check documentation.

Key functions:

  • T_PWRMETER_RETVAL pwrmeter_readRegBytes( uint16_t regAddr, uint8_t nBytes, uint8_t *dataOut ) - Function reads data bytes from registers.
  • T_PWRMETER_RETVAL pwrmeter_writeRegWORD( uint16_t registerAddr, uint16_t dataIn ) - Function writes 16-bit data to the register.
  • T_PWRMETER_RETVAL pwrmeter_sendCommand( uint8_t commandByte ) - Function sends and performs a determined command.

Example description

The application is composed of three sections :

  • System Initialization - Initializes peripherals and pins.
  • Application Initialization - Initializes UART interface, puts output of regulator in active state and configures gain channel and uart baud rate.
  • Application Task - (code snippet) - Reads voltage, current and power measurements from data registers, converts this values to determined units and all results on uart terminal. Repeats operation every second.
void applicationTask()
{
 responseByte = pwrmeter_readRegWORD( _PWRMETER_VOLT_RMS_REG, &voltageRMS );
 checkResponse();
 responseByte = pwrmeter_readRegDWORD( _PWRMETER_CURR_RMS_REG, ¤tRMS );
 checkResponse();
 responseByte = pwrmeter_readRegDWORD( _PWRMETER_ACTIVE_PWR_REG, &activePower );
 checkResponse();
 responseByte = pwrmeter_readRegDWORD( _PWRMETER_REACTIVE_PWR_REG, &reactivePower );
 checkResponse();
 responseByte = pwrmeter_readRegDWORD( _PWRMETER_APPARENT_PWR_REG, &apparentPower );
 checkResponse();
 responseByte = pwrmeter_readRegSigned( _PWRMETER_PWR_FACTOR_REG, _PWRMETER_16BIT_DATA, &powerFactor );
 checkResponse();

 measData[ 0 ] = (float)voltageRMS / 100;
 measData[ 1 ] = (float)currentRMS / 1000;
 measData[ 2 ] = (float)activePower / 100000;
 measData[ 3 ] = (float)reactivePower / 100000;
 measData[ 4 ] = (float)apparentPower / 100000;
 measData[ 5 ] = (float)powerFactor / 32767;

 responseByte = pwrmeter_getStatus( &statusByte );
 checkResponse();

 if ((statusByte & _PWRMETER_DCMODE_MASK) != 0)
 {
 mikrobus_logWrite( "DC mode", _LOG_LINE );
 }
 else
 {
 mikrobus_logWrite( "AC mode", _LOG_LINE );
 }

 FloatToStr( measData[ 0 ], text );
 floatConv();
 mikrobus_logWrite( "RMS voltage: ", _LOG_TEXT );
 if (((statusByte & _PWRMETER_DCMODE_MASK) != 0) && ((statusByte & _PWRMETER_DCVOLT_SIGN_MASK) == 0))
 {
 mikrobus_logWrite( "-", _LOG_TEXT );
 }
 mikrobus_logWrite( text, _LOG_TEXT );
 mikrobus_logWrite( "[V]", _LOG_LINE );

 FloatToStr( measData[ 1 ], text );
 floatConv();
 mikrobus_logWrite( "RMS current: ", _LOG_TEXT );
 if (((statusByte & _PWRMETER_DCMODE_MASK) != 0) && ((statusByte & _PWRMETER_DCCURR_SIGN_MASK) == 0))
 {
 mikrobus_logWrite( "-", _LOG_TEXT );
 }
 mikrobus_logWrite( text, _LOG_TEXT );
 mikrobus_logWrite( "[mA]", _LOG_LINE );

 FloatToStr( measData[ 2 ], text );
 floatConv();
 mikrobus_logWrite( "Active power: ", _LOG_TEXT );
 if ((statusByte & _PWRMETER_PA_SIGN_MASK) == 0)
 {
 mikrobus_logWrite( "-", _LOG_TEXT );
 }
 mikrobus_logWrite( text, _LOG_TEXT );
 mikrobus_logWrite( "[W]", _LOG_LINE );

 FloatToStr( measData[ 3 ], text );
 floatConv();
 mikrobus_logWrite( "Reactive power: ", _LOG_TEXT );
 if ((statusByte & _PWRMETER_PR_SIGN_MASK) == 0)
 {
 mikrobus_logWrite( "-", _LOG_TEXT );
 }
 mikrobus_logWrite( text, _LOG_TEXT );
 mikrobus_logWrite( "[VAr]", _LOG_LINE );

 FloatToStr( measData[ 4 ], text );
 floatConv();
 mikrobus_logWrite( "Apparent power: ", _LOG_TEXT );
 mikrobus_logWrite( text, _LOG_TEXT );
 mikrobus_logWrite( "[VA]", _LOG_LINE );

 FloatToStr( measData[ 5 ], text );
 floatConv();
 mikrobus_logWrite( "Power factor: ", _LOG_TEXT );
 mikrobus_logWrite( text, _LOG_LINE );
 mikrobus_logWrite( "", _LOG_LINE );

 Delay_ms( 1000 );
}

Additional Functions :

  • void checkResponse() - Checks response from the device to the host and logs message if error occurred.
  • void floatConv() - Makes the float values be rounded to two decimal places.


Other mikroE Libraries used in the example:

  • Conversions
  • UART

Additional notes and information

Depending on the development board you are using, you may need USB UART clickUSB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.

ALSO FROM THIS AUTHOR

Altitude 2 Click

0

Altitude 2 Click is a high-resolution barometric pressure sensor Click board™. It provides very accurate measurements of temperature and atmospheric pressure, which can be used to calculate the altitude with a very high resolution of 20cm per step. Besides that, the device also includes features such as the ultra-low noise delta-sigma 24bit ADC, low power consumption, fast conversion times, pre-programmed unique compensation values, and more.

[Learn More]

Magneto 14 Click

0

Magneto 14 Click is a compact add-on board with an accurate and reliable magnetic device. This board features the MA735, a contactless angle sensor with ABZ, and PWM output from Monolithic Power Systems. The MA735 sensor has a 9-bit to 13-bit resolution of the absolute angle encoder.

[Learn More]

Accel 29 Click

0

Accel 29 Click is a compact add-on board that contains an acceleration sensor. This board features the ADXL314, a three-axis ±200g accelerometer from Analog Devices. The ADXL314 offers 16-bit digital output data with a configurable host interface that supports SPI and I2C serial communication. An integrated memory management system with a 32-level FIFO buffer can store data to minimize host processor activity and lower overall system power consumption. Low power modes enable intelligent motion-based power management with threshold sensing and active acceleration measurement at low power dissipation.

[Learn More]