SynchroPMU
C implementation of the Phasor Measurement Unit Estimator based on the Iterative Interpolated DFT Synchrophasor Estimation Algorithm
Loading...
Searching...
No Matches
pmu_estimator.h File Reference

PMU (Phasor Measurement Unit) Estimator Header File. More...

#include <stdio.h>
#include "func_stubs.h"
Include dependency graph for pmu_estimator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  estimator_config
 Configuration structure for the PMU estimator. More...
 
struct  phasor
 Represents a synchrophasor (complex voltage/current measurement) More...
 
struct  pmu_frame
 Complete PMU output frame. More...
 
struct  SynchrophasorEstimatorParams
 Internal parameters for synchrophasor estimation. More...
 
struct  InternalBuffers
 Dynamically allocated internal buffers. More...
 
struct  HanningTransformConstants
 Precomputed constants for Hanning window Fourier Transform. More...
 
struct  RocoFEstimationStates
 State variables for ROCOF (Rate of Change of Frequency) estimation. More...
 
struct  pmu_context
 PMU estimator context structure. More...
 

Macros

#define CONFIG_FROM_INI   1
 Configuration source: Load configuration from INI file.
 
#define CONFIG_FROM_STRUCT   0
 Configuration source: Load configuration from structure.
 

Typedefs

typedef struct pmu_context pmu_context
 

Functions

int pmu_init (pmu_context *ctx, void *cfg, bool_p config_from_ini)
 Initialize a PMU estimator instance.
 
int pmu_estimate (pmu_context *ctx, float_p *in_signal_windows, float_p mid_fracsec, pmu_frame *out_frame)
 Estimate synchrophasor, frequency, and ROCOF from input signal.
 
int pmu_deinit (pmu_context *ctx)
 Deinitialize and free resources of PMU estimator instance.
 
int pmu_dump_frame (pmu_frame *frame, FILE *stream)
 Print PMU frame data to output stream.
 

Detailed Description

PMU (Phasor Measurement Unit) Estimator Header File.

This header file provides the interface for the PMU estimator library, which implements the Iterative Enhanced Interpolated DFT (Discrete Fourier Transform) Synchrophasor Estimation Algorithm.

The library provides functionality for:

  • Synchrophasor estimation (amplitude, phase, frequency)
  • Rate of Change of Frequency (ROCOF) estimation
  • Multi-channel signal processing
  • Configurable estimation parameters
Author
Chemseddine Allioua, Brahim Mazighi
Version
1.7.0

Macro Definition Documentation

◆ CONFIG_FROM_INI

#define CONFIG_FROM_INI   1

Configuration source: Load configuration from INI file.

◆ CONFIG_FROM_STRUCT

#define CONFIG_FROM_STRUCT   0

Configuration source: Load configuration from structure.

Typedef Documentation

◆ pmu_context

typedef struct pmu_context pmu_context

Function Documentation

◆ pmu_deinit()

int pmu_deinit ( pmu_context * ctx)

Deinitialize and free resources of PMU estimator instance.

Releases all dynamically allocated memory associated with the PMU context and resets the initialization flag. After calling this function, the context can be reinitialized with pmu_init() if needed.

Parameters
[in,out]ctxPointer to the PMU context to deinitialize
Returns
0 on success, -1 on error
Note
Always call this function when finished with a PMU context to prevent memory leaks.
See also
pmu_init()

◆ pmu_dump_frame()

int pmu_dump_frame ( pmu_frame * frame,
FILE * stream )

Print PMU frame data to output stream.

Outputs the contents of a pmu_frame structure in a human-readable format to the specified output stream (e.g., stdout, stderr, or a file).

Parameters
[in]framePointer to the PMU frame to dump
[in]streamOutput stream (e.g., stdout, stderr, or FILE pointer from fopen)
Returns
0 on success, -1 on error
See also
pmu_frame

◆ pmu_estimate()

int pmu_estimate ( pmu_context * ctx,
float_p * in_signal_windows,
float_p mid_fracsec,
pmu_frame * out_frame )

Estimate synchrophasor, frequency, and ROCOF from input signal.

This is the main estimation function that processes a window of input samples and produces synchrophasor and ROCOF estimates using the Iterative Enhanced Interpolated DFT algorithm.

Parameters
[in]ctxPointer to initialized PMU context
[in]in_signal_windowsPointer to input signal samples. For multi-channel: array of pointers to signal windows for each channel. Array size must match NUM_CHANLS configuration.
[in]mid_fracsecFractional second timestamp (relative to PPS) of the midpoint of the observation window. Used for phase correction.
[out]out_framePointer to output PMU frame structure where results are stored
Returns
0 on success, -1 on error
Warning
The size of in_signal_windows must match the NUM_CHANLS setting used during compilation. Mismatch will cause segmentation fault.
Note
The context must be initialized with pmu_init() before calling this function.
See also
pmu_init()
pmu_frame

◆ pmu_init()

int pmu_init ( pmu_context * ctx,
void * cfg,
bool_p config_from_ini )

Initialize a PMU estimator instance.

Initializes a PMU estimator context with the specified configuration. The configuration can be loaded from an INI file or passed as a structure.

Parameters
[in,out]ctxPointer to the PMU context structure to initialize
[in]cfgConfiguration: either a filename (char*) if config_from_ini=1, or a pointer to an estimator_config structure if config_from_ini=0
[in]config_from_iniConfiguration source flag:
  • CONFIG_FROM_INI (1): Load from INI file
  • CONFIG_FROM_STRUCT (0): Use structure
Returns
0 on success, -1 on error
Note
The context should not be already initialized. Call pmu_deinit() first if reinitializing an existing context.
See also
pmu_deinit()
estimator_config