pwrmeter 2.0.0.0
main.c File Reference

PwrMeter Click example. More...

#include "board.h"
#include "log.h"
#include "pwrmeter.h"
#include "string.h"
#include "math.h"

Functions

void check_response ()
 
void application_init (void)
 
void application_task (void)
 
int main (void)
 

Variables

PWRMETER_RETVAL response_byte
 
uint16_t voltage_rms
 
uint32_t current_rms
 
uint32_t active_power
 
uint32_t reactive_power
 
uint32_t apparent_power
 
int32_t power_factor
 
uint8_t status_byte
 
float meas_data [6]
 

Detailed Description

PwrMeter Click example.

Description

This click is capable of measuring voltage and current through the load, connected to either AC or DC power source. It is used to calculate all the measurement parameters, returning values of multiple power parameters directly, over the UART interface, reducing the processing load on the host MCU. These parameters include active, reactive, and apparent power, current and voltage RMS, line frequency, and power factor.

The demo application is composed of two sections :

Application Init

Initializes UART interface, puts output of regulator in active state and configures gain channel and uart baud rate.

Application Task

Reads voltage, current and power measurements from data registers, then converts this values to determined units and logs all results on uart terminal each second.

Additional Function

  • void check_response ( ) - Displays an appropriate message on USB UART if there's an error occurred in the last response from the module.

Note

Do not apply higher voltage than 60V to this board! This click is designed for lower voltage monitoring and evaluation of the MCP39F511A and its basic functionalities.

Author
MikroE Team

Function Documentation

◆ application_init()

void application_init ( void )

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 LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void )

◆ check_response()

void check_response ( )

◆ main()

int main ( void )

Variable Documentation

◆ active_power

uint32_t active_power

◆ apparent_power

uint32_t apparent_power

◆ current_rms

uint32_t current_rms

◆ meas_data

float meas_data[6]

◆ power_factor

int32_t power_factor

◆ reactive_power

uint32_t reactive_power

◆ response_byte

PWRMETER_RETVAL response_byte

◆ status_byte

uint8_t status_byte

◆ voltage_rms

uint16_t voltage_rms