C2000Ware Digital Power SDK  5.03.00.00
POWER_MEAS_SINE_ANALYZER

Introduction

Data Structures

struct  POWER_MEAS_SINE_ANALYZER
 Defines the POWER_MEAS_SINE_ANALYZER structure. More...
 

Functions

static void POWER_MEAS_SINE_ANALYZER_reset (POWER_MEAS_SINE_ANALYZER *v)
 Resets internal data to zero. More...
 
static void POWER_MEAS_SINE_ANALYZER_config (POWER_MEAS_SINE_ANALYZER *v, float32_t isrFrequency, float32_t threshold, float32_t gridMaxFreq, float32_t gridMinFreq)
 Configures the power measurment module. More...
 
static void POWER_MEAS_SINE_ANALYZER_run (POWER_MEAS_SINE_ANALYZER *v)
 Perform calculations using the POWER_MEAS_SINE_ANALYZER module. More...
 

Typedefs

typedef float float32_t
 
typedef long double float64_t
 

Macros

#define C2000_IEEE754_TYPES
 

Sine Analyzer with Power Measurement (POWER_MEAS_SINE_ANALYZER) Module

Introduction

The Sine Analyzer with Power Measurement (POWER_MEAS_SINE_ANALYZER) API provides a set of functions that accumulates the sampled sine wave inputs, checks for threshold crossing point and calculates the RMS, Average, and EMA values of the input sine wave. This module can also calculate the Frequency of the sine wave and indicate zero (or threshold) crossing point.

Sine Analyzer with Power Measurement Model

This module expects the following key inputs:

  1. Voltage in PU (v), Current in PU (i): This is the signal sampled by ADC and ADC result converted to pu format. The offset is subtracted from the reading, hence for a max scale signal the value will vary from -1 to 1.
  2. Threshold Value (threshold): Threshold value is used for detecting the cross over of the input signal across the threshold value set, in pu format. By default threshold is set to Zero.
  3. Sampling Frequency (sampleFreq): This is set to the Frequency at which the input sine wave is sampled, the sine analyzer block is called.
  4. Minimum and maximum number of samples in a sine cycle (nSamplesMin, nSamplesMax): These values are used to discard any noisy samples which can generate erroneous values on rms and avg signal.
    This module generates the following key outputs:
  5. Voltage, Current and Power RMS values (vRms, iRms, pRms): Output reflects the RMS value of the input signal in pu format. RMS value is calculated and updated at every threshold crossover point for the voltage and current, the power RMS value is filtered further to provide a more stable output.
  6. Power Factor (powerFactor): This value represents the PF of the input current and voltage signals.
  7. AC Frequency (acFreq): This value represents the AC frequency of the input signal.




API Usage

The following is a sequence of steps that can be followed to use the POWER_MEAS_SINE_ANALYZER API library functions in an existing C program. For a set of code examples that illustrates the use of this library, see the examples in the Digial Power SDK.

Before you can using the library you must add the libraries directory path as a searchable directory in the project include options. This can be done by right-clicking on the project in the Project Explorer window, selecting "Properties". In the window that opens, navigate to "Build, C2000 Compiler, Include Options". In the include path
window, click on the green add directory path button on the right and enter the path to the Digital Power SDK libraries directory.

This allows CCS to search the entire directory for library files.

Once that is done you should follow these steps incorporate this library into your project:

  1. Specify the include file(s)
  2. Create and add module structure to project source file
  3. Initialize module
    Note: The ISR_FREQUENCY is the rate at which this module is called. This value is used to implement a jitter filter which prevents spurious events from corrupting the RMS value.
    POWER_MEAS_SINE_ANALYZER_config(&sine_mains, ISR_FREQUENCY, (float32_t)(0.25));

  4. Using the module
    sine_mains.i = ac_cur_sensed;
    sine_mains.v = ac_vol_sensed;
    guiIrms=sine_mains.iRms*I_MAX_SENSE;
    guiVrms=sine_mains.vRms*VAC_MAX_SENSE;
    guiPrms=sine_mains.pRms*VAC_MAX_SENSE*I_MAX_SENSE;

    Note: The functions are typically called in an interrupt source routine (ISR) which is called at the defined rate, ISR_FREQUENCY.

API Integration Information

There is only one module in this package, the APIs can be referenced at POWER_MEAS_SINE_ANALYZER. The module headers are located at power_meas_sine_analyzer.h.

Macro Definition Documentation

◆ C2000_IEEE754_TYPES

#define C2000_IEEE754_TYPES

Definition at line 49 of file power_meas_sine_analyzer.h.

Typedef Documentation

◆ float32_t

typedef float float32_t

Definition at line 54 of file power_meas_sine_analyzer.h.

◆ float64_t

typedef long double float64_t

Definition at line 55 of file power_meas_sine_analyzer.h.

Function Documentation

◆ POWER_MEAS_SINE_ANALYZER_reset()

static void POWER_MEAS_SINE_ANALYZER_reset ( POWER_MEAS_SINE_ANALYZER v)
inlinestatic

Resets internal data to zero.

Parameters
*vThe POWER_MEAS_SINE_ANALYZER structure pointer
Returns
None

Definition at line 106 of file power_meas_sine_analyzer.h.

◆ POWER_MEAS_SINE_ANALYZER_config()

static void POWER_MEAS_SINE_ANALYZER_config ( POWER_MEAS_SINE_ANALYZER v,
float32_t  isrFrequency,
float32_t  threshold,
float32_t  gridMaxFreq,
float32_t  gridMinFreq 
)
inlinestatic

Configures the power measurment module.

Parameters
*vThe POWER_MEAS_SINE_ANALYZER structure pointer
isrFrequencyFrequency at which SPLL module is run
thresholdThreshold value to avoid zero crossing issues
gridMaxFreqMax grid frequency
gridMinFreqMin grid frequency
Returns
None

Definition at line 146 of file power_meas_sine_analyzer.h.

◆ POWER_MEAS_SINE_ANALYZER_run()

static void POWER_MEAS_SINE_ANALYZER_run ( POWER_MEAS_SINE_ANALYZER v)
inlinestatic

Perform calculations using the POWER_MEAS_SINE_ANALYZER module.

Parameters
*vThe POWER_MEAS_SINE_ANALYZER structure pointer
Returns
None

Definition at line 163 of file power_meas_sine_analyzer.h.

power_meas_sine_analyzer.h
POWER_MEAS_SINE_ANALYZER::pRms
float32_t pRms
Output: RMS Value of input power.
Definition: power_meas_sine_analyzer.h:76
POWER_MEAS_SINE_ANALYZER_reset
static void POWER_MEAS_SINE_ANALYZER_reset(POWER_MEAS_SINE_ANALYZER *v)
Resets internal data to zero.
Definition: power_meas_sine_analyzer.h:106
POWER_MEAS_SINE_ANALYZER_run
static void POWER_MEAS_SINE_ANALYZER_run(POWER_MEAS_SINE_ANALYZER *v)
Perform calculations using the POWER_MEAS_SINE_ANALYZER module.
Definition: power_meas_sine_analyzer.h:163
float32_t
float float32_t
Definition: power_meas_sine_analyzer.h:54
POWER_MEAS_SINE_ANALYZER::v
float32_t v
Input: Voltage Sine Signal.
Definition: power_meas_sine_analyzer.h:66
POWER_MEAS_SINE_ANALYZER_config
static void POWER_MEAS_SINE_ANALYZER_config(POWER_MEAS_SINE_ANALYZER *v, float32_t isrFrequency, float32_t threshold, float32_t gridMaxFreq, float32_t gridMinFreq)
Configures the power measurment module.
Definition: power_meas_sine_analyzer.h:146
POWER_MEAS_SINE_ANALYZER::vRms
float32_t vRms
Output: RMS Value.
Definition: power_meas_sine_analyzer.h:70
POWER_MEAS_SINE_ANALYZER
Defines the POWER_MEAS_SINE_ANALYZER structure.
Definition: power_meas_sine_analyzer.h:65
POWER_MEAS_SINE_ANALYZER::i
float32_t i
Input Current Signal.
Definition: power_meas_sine_analyzer.h:67
POWER_MEAS_SINE_ANALYZER::iRms
float32_t iRms
Output: RMS Value of current.
Definition: power_meas_sine_analyzer.h:75