Go to the documentation of this file.
40 #ifndef __PQLIB_EXAMPLE_H__
41 #define __PQLIB_EXAMPLE_H__
48 #include "adi_pqlib.h"
49 #include "adi_pqlib_memory.h"
50 #include "adi_pqlib_profile.h"
60 #define PQLIB_MAX_CHANNELS 7
61 #define ADI_PQLIB_NUM_WAVEFORM_BLOCKS 4
62 #define PQLIB_MAX_HARMONICS 50
63 #define PQLIB_MAX_INTER_HARMONICS 50
64 #define SIZE_OF_INPUT_RTC 19
147 uint32_t pqlibStateMemory[ADI_PQLIB_STATE_MEM_NUM_BYTES / 4];
148 uint32_t pqlibTempMemory[ADI_PQLIB_TEMP_MEM_NUM_BYTES / 4];
184 ADI_PQLIB_RESULT pqlibStatus);
250 ADI_PQLIB_CORR_COEF *pCorrCoef);
266 ADI_PQLIB_RESULT pqlibStatus);
float msvCarrierFrequency
Definition: pqlib_example.h:120
float msvThreshold
Definition: pqlib_example.h:119
ADI_PQLIB_WAVEFORM inputWaveform
Definition: pqlib_example.h:155
float dipThreshold
Definition: pqlib_example.h:111
bool useExternalTimestamp
Definition: pqlib_example.h:94
int pqm_start_measurement(bool waitingForSync)
Starts Power Quality measurement as per configured cycles.
Definition: pqlib_example.c:74
uint16_t voltageCorrCoef[PQLIB_MAX_HARMONICS]
Definition: pqlib_example.h:101
uint32_t correction
Definition: pqlib_example.h:108
Header file of ADE9430 Driver.
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:484
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:303
bool enableRTCSync
Definition: pqlib_example.h:92
ADI_PQLIB_1012_CYCLE_INPUT input1012Cycles
Definition: pqlib_example.h:154
int pqm_one_cycle(void)
One complete cycle for IIO callback function.
Definition: pqlib_example.c:123
#define SYS_STATUS_PQLIB_RUNNING
Definition: status.h:50
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:152
ADI_PQLIB_REF_CHANNEL refChannel
Definition: pqlib_example.h:130
uint16_t numCorrCoefVoltage60Hz
Definition: pqlib_example.h:105
float rvcHysteresis
Definition: pqlib_example.h:118
uint16_t numCorrCoefCurrent50Hz
Definition: pqlib_example.h:102
@ VCONSEL_4W_DELTA_VA_VB_VC
Definition: pqlib_example.h:85
int afe_read_version(uint32_t *pVersion)
reads AFE version.
Definition: afe_config.c:305
Definition: pqlib_example.h:138
uint32_t cyclesToRun
Definition: pqlib_example.h:106
float intrpHysteresis
Definition: pqlib_example.h:116
int get_afe_input()
Definition: pqlib_afe.c:53
struct no_os_circular_buffer * no_os_cb_desc
Definition: pqlib_example.h:160
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:303
ADI_PQLIB_PHASE_MAP channelMap
Definition: pqlib_example.h:158
uint16_t currentCorrCoef[PQLIB_MAX_HARMONICS]
Definition: pqlib_example.h:100
ADI_PQLIB_CORR_COEF correctionData
Definition: pqlib_example.h:131
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:135
PQLIB_STATE
PQLIB Example states.
Definition: pqlib_example.h:70
ADI_PQLIB_FLICKER_MODEL flickerModel
Definition: pqlib_example.h:132
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:382
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:219
int pqm_one_cycle(void)
One complete cycle for IIO callback function.
Definition: pqlib_example.c:123
uint64_t syncTime
Definition: pqlib_example.h:110
#define PQLIB_MAX_CHANNELS
Definition: pqlib_example.h:60
float inputVoltageCorrCoef50Hz[PQLIB_MAX_HARMONICS]
Definition: pqlib_example.h:126
#define PQLIB_MAX_INTER_HARMONICS
Definition: pqlib_example.h:63
float swellThreshold
Definition: pqlib_example.h:113
uint8_t interHarmonics[PQLIB_MAX_INTER_HARMONICS]
Definition: pqlib_example.h:96
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:467
volatile bool configChanged
Definition: iio_pqm.c:68
#define SYS_STATUS_SUCCESS
Definition: status.h:47
float intrpThreshold
Definition: pqlib_example.h:115
float rvcThreshold
Definition: pqlib_example.h:117
float currentScale
Definition: pqlib_example.h:123
int afe_start(void)
Starts the AFE.
Definition: afe_config.c:137
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:566
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:538
uint16_t numCorrCoefVoltage50Hz
Definition: pqlib_example.h:103
PQLIB_STATE state
Definition: pqlib_example.h:159
uint32_t zeroCrossingCount
Definition: pqlib_example.h:145
int pqm_measurement_init(void)
Initializes Power Quality Measurement.
Definition: pqlib_example.c:59
@ VCONSEL_4W_DELTA_VB_NEGVA
Definition: pqlib_example.h:84
bool calibration
Definition: pqlib_example.h:142
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:418
float inputCurrentCorrCoef50Hz[PQLIB_MAX_HARMONICS]
Definition: pqlib_example.h:125
@ PQLIB_STATE_RUNNING
Definition: pqlib_example.h:73
ADI_PQLIB_CONFIG config
Definition: pqlib_example.h:152
VCONSEL_CONFIG vconsel
Definition: pqlib_example.h:134
bool enableIconsel
Definition: pqlib_example.h:93
ADI_PQLIB_PCT_TYPE convert_to_pct_type(float val)
Converts val to percentage.
Definition: pqlib_convert.c:79
Circular buffer library header.
volatile bool processData
Definition: iio_pqm.c:69
uint8_t maxHarmonics
Definition: pqlib_example.h:97
float swellHysteresis
Definition: pqlib_example.h:114
float inputCurrentCorrCoef60Hz[PQLIB_MAX_HARMONICS]
Definition: pqlib_example.h:127
#define SYS_STATUS_PQLIB_CONFIG_ERROR
Definition: status.h:51
bool readyToDisplay
Definition: pqlib_example.h:140
ADI_PQLIB_PHASE_MAP phaseMap
Definition: pqlib_example.h:133
uint16_t numCorrCoefCurrent60Hz
Definition: pqlib_example.h:104
uint8_t maxInterHarmonics
Definition: pqlib_example.h:98
char * pChannel
Definition: pqlib_example.h:150
ADI_PQLIB_HANDLE hDevice
Definition: pqlib_example.h:151
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:566
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:538
uint32_t timeOutCount
Definition: pqlib_example.h:146
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:484
PQLIB_EXAMPLE pqlibExample
Definition: pqlib_example.c:51
char * pEnabledChannels[PQLIB_MAX_CHANNELS]
Definition: pqlib_example.h:129
@ PQLIB_STATE_WAITING_FOR_TRIGGER
Definition: pqlib_example.h:72
float msvRecordingLength
Definition: pqlib_example.h:121
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:418
ADI_PQLIB_COEF_TYPE convert_to_coef_fract_type(float val)
Converts val to correction coefficient.
Definition: pqlib_convert.c:95
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:152
uint32_t nominalFrequency
Definition: pqlib_example.h:107
int afe_set_ref_channel(uint16_t refChannel)
sets refChannel.
Definition: afe_config.c:495
void afe_wait_settling(uint32_t cycles)
Waits for passed number of cycles.
Definition: afe_config.c:448
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:382
bool waitingForSync
Definition: pqlib_example.h:141
float inputVoltageCorrCoef60Hz[PQLIB_MAX_HARMONICS]
Definition: pqlib_example.h:128
#define NULL
Definition: wrapper.h:64
float voltageScale
Definition: pqlib_example.h:122
@ PQLIB_STATE_WAITING_FOR_START_CMD
Definition: pqlib_example.h:71
uint32_t processedCycles
Definition: pqlib_example.h:144
VCONSEL_CONFIG
VCONSEL H/W config selection.
Definition: pqlib_example.h:80
uint32_t pqlibTempMemory[ADI_PQLIB_TEMP_MEM_NUM_BYTES/4]
Definition: pqlib_example.h:148
@ VCONSEL_4W_WYE
Definition: pqlib_example.h:81
#define PQLIB_MAX_HARMONICS
Definition: pqlib_example.h:62
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:467
Circular buffer descriptor.
Definition: no_os_circular_buffer.h:73
int pqm_start_measurement(bool waitingForSync)
Starts Power Quality measurement as per configured cycles.
Definition: pqlib_example.c:74
uint8_t harmonics[PQLIB_MAX_HARMONICS]
Definition: pqlib_example.h:95
#define SIZE_OF_INPUT_RTC
Definition: pqlib_example.h:64
int afe_set_acc_mode(uint16_t frequency, uint16_t vconsel, uint16_t iconsel)
sets ACCMODE register for nominal frequency, ICONSEL, VCONSEL.
Definition: afe_config.c:464
EXAMPLE_CONFIG exampleConfig
Definition: pqlib_example.h:156
int pqm_measurement_init(void)
Initializes Power Quality Measurement.
Definition: pqlib_example.c:59
@ VCONSEL_4W_WYE_VB_NEGVA_NEGVC
Definition: pqlib_example.h:83
float calExpectedRms
Definition: pqlib_example.h:149
PQLIB_EXAMPLE pqlibExample
Definition: pqlib_example.c:51
float nominalVoltage
Definition: pqlib_example.h:124
ADI_PQLIB_CYCLE_INPUT inputCycle
Definition: pqlib_example.h:153
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:135
ADI_PQLIB_OUTPUT * output
Definition: pqlib_example.h:157
uint32_t convert_to_time_ms(float timesec)
Converts time in sec to time in ms.
Definition: pqlib_convert.c:102
ADI_PQLIB_FREQ_TYPE convert_to_freq_type(float val)
Converts val to freq in mhz.
Definition: pqlib_convert.c:87
Definition: pqlib_example.h:91
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:219
uint32_t zeroCrossingCheck
Definition: pqlib_example.h:109
uint16_t syncCycles
Definition: pqlib_example.h:143
@ VCONSEL_3W_DELTA_VB_VA_NEGVC
Definition: pqlib_example.h:82
volatile uint8_t newSyncTimeAvailable
Definition: intrpt_handler.c:53
#define SYS_STATUS_PQLIB_ERROR
Definition: status.h:48
uint32_t pqlibStateMemory[ADI_PQLIB_STATE_MEM_NUM_BYTES/4]
Definition: pqlib_example.h:147
float dipHysteresis
Definition: pqlib_example.h:112
#define SYS_STATUS_NO_SIGNAL
Definition: status.h:49