no-OS
Loading...
Searching...
No Matches
iio_pqm.h
Go to the documentation of this file.
1/*******************************************************************************
2 * @file iio_pqm.h
3 * @brief IIO pqm interfacing header file
4 * @author Robert Budai (robert.budai@analog.com)
5 ********************************************************************************
6 * Copyright (c) 2024 Analog Devices, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 *
18 * 3. Neither the name of Analog Devices, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
25 * EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
28 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *******************************************************************************/
33#ifndef __IIO_PQM_H__
34#define __IIO_PQM_H__
35
36#include "common_data.h"
37#include "pqlib_afe.h"
38#include "pqlib_convert.h"
39#include "pqlib_example.h"
40#include "afe_calibration.h"
41#include "status.h"
42#include <inttypes.h>
43
44// Device specific attributes
45#define NEG_UNB_VOLTAGE_RATIO 0
46#define ZERO_UNB_VOLTAGE_RATIO 1
47#define SNEG_VOLTAGE 2
48#define SPOS_VOLTAGE 3
49#define SZRO_VOLTAGE 4
50#define NEG_UNB_CURRENT_RATIO 5
51#define ZERO_UNB_CURRENT_RATIO 6
52#define SNEG_CURRENT 7
53#define SPOS_CURRENT 8
54#define SZRO_CURRENT 9
55#define NOMINAL_VOLTAGE 10
56#define VOLTAGE_SCALE 11
57#define CURRENT_SCALE 12
58#define I_CONSEL_ENABLE 13
59#define DIP_THRESHOLD 14
60#define DIP_HYSTERESIS 15
61#define SWELL_THRESHOLD 16
62#define SWELL_HYSTERESIS 17
63#define INTERP_THRESHOLD 18
64#define INTERP_HYSTERESIS 19
65#define RVC_THRESHOLD 20
66#define RVC_HYSTERESIS 21
67#define MSV_CARRIER_FREQUENCY 22
68#define MSV_RECORDING_LENGTH 23
69#define MSV_THRESHOLD 24
70#define SAMPLING_FREQUENCY 25
71#define V_CONSEL 26
72#define V_CONSEL_AVAILABLE 27
73#define FLICKER_MODEL 28
74#define FLICKER_MODEL_AVAILABLE 29
75#define NOMINAL_FREQUENCY 30
76#define NOMINAL_FREQUENCY_AVAILABLE 31
77#define PROCESS_DATA 32
78#define FW_VERSION_NR 33
79#define SNEG_VOLTAGE_ANGLE 34
80#define SPOS_VOLTAGE_ANGLE 35
81#define SZRO_VOLTAGE_ANGLE 36
82#define SNEG_CURRENT_ANGLE 37
83#define SPOS_CURRENT_ANGLE 38
84#define SZRO_CURRENT_ANGLE 39
85
86// Calibration attributes
87#define CAL_TYPE 40
88#define CAL_TYPE_AVAILABLE 41
89#define CAL_STATUS 42
90#define CAL_PHASE 43
91#define CAL_NOMINAL_CURRENT 44
92#define CAL_NOMINAL_VOLTAGE 45
93#define CAL_OFFSET_CURRENT 46
94#define CAL_OFFSET_VOLTAGE 47
95#define CAL_PHASE_AVAILABLE 48
96#define CAL_START 49
97// Gain calibration errors
98#define CAL_GAIN_I_ERROR_BEFORE 50
99#define CAL_GAIN_V_ERROR_BEFORE 51
100#define CAL_GAIN_I_ERROR_AFTER 52
101#define CAL_GAIN_V_ERROR_AFTER 53
102// Offset calibration errors
103#define CAL_OFFSET_I_ERROR_BEFORE 54
104#define CAL_OFFSET_V_ERROR_BEFORE 55
105#define CAL_OFFSET_I_ERROR_AFTER 56
106#define CAL_OFFSET_V_ERROR_AFTER 57
107
108// Flash storage attributes
109#define FLASH_CAL_SAVE 58
110#define FLASH_CAL_LOAD 59
111#define FLASH_CAL_ERASE 60
112#define FLASH_STAT 61
113#define FLASH_CAL_DATA 62
114
115// Channel specific attributes
116#define CHAN_RMS 0
117#define CHAN_ANGLE 1
118#define CHAN_HARMONICS 2
119#define CHAN_INTER_HARMONICS 3
120#define CHAN_SCALE 4
121#define CHAN_OFFSET 5
122#define CHAN_THD 6
123#define CHAN_RAW 7
124#define CHAN_VOLTAGE_UNDER_DEV 8
125#define CHAN_VOLTAGE_OVER_DEV 9
126#define CHAN_VOLTAGE_PINST 10
127#define CHAN_VOLTAGE_PST 11
128#define CHAN_VOLTAGE_PLT 12
129#define CHAN_EVENT_COUNT 13
130#define CHAN_EVENT_START_TIME 14
131#define CHAN_EVENT_END_TIME 15
132#define CHAN_EVENT_DURATION_IN_CYCL 16
133#define CHAN_EVENT_MIN_MAG 17
134#define CHAN_EVENT_MAX_MAG 18
135#define CHAN_EVENT_DELTA_U_MAX 19
136#define CHAN_EVENT_DELTA_U_SS 20
137#define CHAN_VOLTAGE_MAGNITUDE1012 21
138#define CHAN_VOLTAGE_MAX_MAGNITUDE 22
139
140#define RESAMPLED_WAVEFORM_FULL_SCALE 18196
141
142extern struct iio_device pqm_iio_descriptor;
143extern volatile bool configChanged;
144extern volatile bool processData;
145
146#endif
volatile bool processData
Definition iio_pqm.c:82
volatile bool configChanged
Definition iio_pqm.c:81
struct iio_device pqm_iio_descriptor
Definition iio_pqm.c:1553
Structure holding channels and attributes of a device.
Definition iio_types.h:239