34#ifndef __PQLIB_EXAMPLE_H__
35#define __PQLIB_EXAMPLE_H__
39#include "adi_pqlib_memory.h"
40#include "adi_pqlib_profile.h"
47#define PQLIB_MAX_CHANNELS 7
48#define ADI_PQLIB_NUM_WAVEFORM_BLOCKS 4
49#define PQLIB_MAX_HARMONICS 50
50#define PQLIB_MAX_INTER_HARMONICS 50
51#define SIZE_OF_INPUT_RTC 19
176 ADI_PQLIB_RESULT pqlibStatus);
242 ADI_PQLIB_CORR_COEF *pCorrCoef);
258 ADI_PQLIB_RESULT pqlibStatus);
Header file of ADE9430 Driver.
CALIBRATION_TYPE
Calibration type (gain or offset)
Definition afe_calibration.h:71
Circular buffer library header.
PQLIB_EXAMPLE pqlibExample
Definition pqlib_example.c:39
VCONSEL_CONFIG
VCONSEL H/W config selection.
Definition pqlib_example.h:68
@ VCONSEL_4W_WYE
Definition pqlib_example.h:69
@ VCONSEL_4W_WYE_VB_NEGVA_NEGVC
Definition pqlib_example.h:71
@ VCONSEL_4W_DELTA_VA_VB_VC
Definition pqlib_example.h:73
@ VCONSEL_4W_DELTA_VB_NEGVA
Definition pqlib_example.h:72
@ VCONSEL_3W_DELTA_VB_VA_NEGVC
Definition pqlib_example.h:70
int process_and_prepare_output()
The function gets AFE input and calls main processing APIs of the library. This also gets the measure...
Definition pqlib_example.c:232
PQLIB_STATE
PQLIB Example states.
Definition pqlib_example.h:57
@ PQLIB_STATE_CALIBRATING
Definition pqlib_example.h:61
@ PQLIB_STATE_WAITING_FOR_START_CMD
Definition pqlib_example.h:58
@ PQLIB_STATE_RUNNING
Definition pqlib_example.h:60
@ PQLIB_STATE_WAITING_FOR_TRIGGER
Definition pqlib_example.h:59
void SyncToDip(PQLIB_EXAMPLE *pExample, ADI_PQLIB_RESULT pqlibStatus)
Sync the time to a dip or interruption event. Serves as an example how to sync to an external time ev...
Definition pqlib_example.c:585
int cpy_correction_coeffs(ADI_PQLIB_NOMINAL_FREQUENCY nominalFrequency, ADI_PQLIB_CORR_COEF *pCorrCoef)
Copies the user provided correction factors to the interface structure. This shows how floating point...
Definition pqlib_example.c:316
void populate_event_config(EXAMPLE_CONFIG *pExampleConfig)
Populates event configuration using user configuration Serves as an example on how to convert thresho...
Definition pqlib_example.c:395
int wait_for_zero_crossing(PQLIB_EXAMPLE *pExample, ADI_PQLIB_RESULT pqlibStatus)
Looks at the return code from library and checks whether there is a zero crossing timeout....
Definition pqlib_example.c:431
#define PQLIB_MAX_CHANNELS
Definition pqlib_example.h:47
int pqm_start_measurement(bool waitingForSync)
Starts Power Quality measurement as per configured cycles.
Definition pqlib_example.c:66
#define PQLIB_MAX_INTER_HARMONICS
Definition pqlib_example.h:50
int pqm_measurement_init(void)
Initializes Power Quality Measurement.
Definition pqlib_example.c:43
int open_pqlib(PQLIB_EXAMPLE *pExample)
Call adi_pqlib_Open with required buffers. Serves as an example how to call adi_pqlib_Open API.
Definition pqlib_example.c:141
void set_default_config(EXAMPLE_CONFIG *pConfig)
Sets default configuration of the example as floating points Note that this function doesn't configur...
Definition pqlib_example.c:497
int SyncLibTime(PQLIB_EXAMPLE *pExample, bool checkRtcTime)
Sets library internal time using RTC time. Serves as an example how to call the APIs....
Definition pqlib_example.c:557
int config_measurement(PQLIB_EXAMPLE *pExample)
Configures AFE and the library . This serves as an example on how to call APIs adi_pqlib_SetConfig an...
Definition pqlib_example.c:158
#define SIZE_OF_INPUT_RTC
Definition pqlib_example.h:51
#define PQLIB_MAX_HARMONICS
Definition pqlib_example.h:49
int process_pqlib_error(PQLIB_EXAMPLE *pExample, ADI_PQLIB_RESULT pqlibStatus)
Prints error message for errors from the library. Serves as an examples on how to handle the errors f...
Definition pqlib_example.c:480
int pqm_one_cycle(void)
One complete cycle for IIO callback function.
Definition pqlib_example.c:115
Definition pqlib_example.h:79
float calNominalVoltage
Definition pqlib_example.h:125
float voltagePgaGain
Definition pqlib_example.h:129
float dipHysteresis
Definition pqlib_example.h:100
CALIBRATION_TYPE calibrationType
Definition pqlib_example.h:123
float msvRecordingLength
Definition pqlib_example.h:109
float calOffsetVoltage
Definition pqlib_example.h:127
uint32_t cyclesToRun
Definition pqlib_example.h:94
uint32_t correction
Definition pqlib_example.h:96
uint8_t harmonics[PQLIB_MAX_HARMONICS]
Definition pqlib_example.h:83
uint16_t currentCorrCoef[PQLIB_MAX_HARMONICS]
Definition pqlib_example.h:88
float inputCurrentCorrCoef60Hz[PQLIB_MAX_HARMONICS]
Definition pqlib_example.h:115
ADI_PQLIB_REF_CHANNEL refChannel
Definition pqlib_example.h:118
char * pEnabledChannels[PQLIB_MAX_CHANNELS]
Definition pqlib_example.h:117
uint16_t numCorrCoefVoltage50Hz
Definition pqlib_example.h:91
uint32_t zeroCrossingCheck
Definition pqlib_example.h:97
uint8_t maxInterHarmonics
Definition pqlib_example.h:86
float intrpThreshold
Definition pqlib_example.h:103
ADI_PQLIB_PHASE_MAP phaseMap
Definition pqlib_example.h:121
float rvcThreshold
Definition pqlib_example.h:105
uint32_t nominalFrequency
Definition pqlib_example.h:95
float rvcHysteresis
Definition pqlib_example.h:106
float intrpHysteresis
Definition pqlib_example.h:104
uint64_t syncTime
Definition pqlib_example.h:98
float dipThreshold
Definition pqlib_example.h:99
ADI_PQLIB_CORR_COEF correctionData
Definition pqlib_example.h:119
VCONSEL_CONFIG vconsel
Definition pqlib_example.h:122
float currentScale
Definition pqlib_example.h:111
uint16_t numCorrCoefCurrent50Hz
Definition pqlib_example.h:90
float swellThreshold
Definition pqlib_example.h:101
float inputVoltageCorrCoef60Hz[PQLIB_MAX_HARMONICS]
Definition pqlib_example.h:116
float swellHysteresis
Definition pqlib_example.h:102
float inputVoltageCorrCoef50Hz[PQLIB_MAX_HARMONICS]
Definition pqlib_example.h:114
float msvThreshold
Definition pqlib_example.h:107
float nominalVoltage
Definition pqlib_example.h:112
float msvCarrierFrequency
Definition pqlib_example.h:108
uint16_t numCorrCoefVoltage60Hz
Definition pqlib_example.h:93
bool enableIconsel
Definition pqlib_example.h:81
uint8_t maxHarmonics
Definition pqlib_example.h:85
uint16_t numCorrCoefCurrent60Hz
Definition pqlib_example.h:92
uint16_t voltageCorrCoef[PQLIB_MAX_HARMONICS]
Definition pqlib_example.h:89
uint8_t interHarmonics[PQLIB_MAX_INTER_HARMONICS]
Definition pqlib_example.h:84
float inputCurrentCorrCoef50Hz[PQLIB_MAX_HARMONICS]
Definition pqlib_example.h:113
bool enableRTCSync
Definition pqlib_example.h:80
bool useExternalTimestamp
Definition pqlib_example.h:82
float currentPgaGain
Definition pqlib_example.h:128
float calNominalCurrent
Definition pqlib_example.h:124
float voltageScale
Definition pqlib_example.h:110
float calOffsetCurrent
Definition pqlib_example.h:126
ADI_PQLIB_FLICKER_MODEL flickerModel
Definition pqlib_example.h:120
uint8_t rtcBuff[SIZE_OF_INPUT_RTC]
Definition pqlib_example.h:87
Definition pqlib_example.h:133
ADI_PQLIB_OUTPUT * output
Definition pqlib_example.h:153
ADI_PQLIB_HANDLE hDevice
Definition pqlib_example.h:147
uint32_t pqlibStateMemory[ADI_PQLIB_STATE_MEM_NUM_BYTES/4]
Definition pqlib_example.h:143
bool waitingForSync
Definition pqlib_example.h:136
uint32_t processedCycles
Definition pqlib_example.h:140
uint16_t syncCycles
Definition pqlib_example.h:139
uint32_t timeOutCount
Definition pqlib_example.h:142
float calExpectedRms
Definition pqlib_example.h:145
ADI_PQLIB_1012_CYCLE_INPUT input1012Cycles
Definition pqlib_example.h:150
bool calibrationRequested
Definition pqlib_example.h:138
uint32_t pqlibTempMemory[ADI_PQLIB_TEMP_MEM_NUM_BYTES/4]
Definition pqlib_example.h:144
char * pChannel
Definition pqlib_example.h:146
bool readyToDisplay
Definition pqlib_example.h:135
ADI_PQLIB_WAVEFORM inputWaveform
Definition pqlib_example.h:151
struct no_os_circular_buffer * no_os_cb_desc
Definition pqlib_example.h:156
PQLIB_STATE state
Definition pqlib_example.h:155
EXAMPLE_CONFIG exampleConfig
Definition pqlib_example.h:152
ADI_PQLIB_CYCLE_INPUT inputCycle
Definition pqlib_example.h:149
uint32_t zeroCrossingCount
Definition pqlib_example.h:141
bool calibration
Definition pqlib_example.h:137
ADI_PQLIB_PHASE_MAP channelMap
Definition pqlib_example.h:154
ADI_PQLIB_CONFIG config
Definition pqlib_example.h:148
Circular buffer descriptor.
Definition no_os_circular_buffer.h:59