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 "status.h"
41#include <inttypes.h>
42
43// Device specific attributes
44#define NEG_UNB_VOLTAGE_RATIO 0
45#define ZERO_UNB_VOLTAGE_RATIO 1
46#define SNEG_VOLTAGE 2
47#define SPOS_VOLTAGE 3
48#define SZRO_VOLTAGE 4
49#define NEG_UNB_CURRENT_RATIO 5
50#define ZERO_UNB_CURRENT_RATIO 6
51#define SNEG_CURRENT 7
52#define SPOS_CURRENT 8
53#define SZRO_CURRENT 9
54#define NOMINAL_VOLTAGE 10
55#define VOLTAGE_SCALE 11
56#define CURRENT_SCALE 12
57#define I_CONSEL_ENABLE 13
58#define DIP_THRESHOLD 14
59#define DIP_HYSTERESIS 15
60#define SWELL_THRESHOLD 16
61#define SWELL_HYSTERESIS 17
62#define INTERP_THRESHOLD 18
63#define INTERP_HYSTERESIS 19
64#define RVC_THRESHOLD 20
65#define RVC_HYSTERESIS 21
66#define MSV_CARRIER_FREQUENCY 22
67#define MSV_RECORDING_LENGTH 23
68#define MSV_THRESHOLD 24
69#define SAMPLING_FREQUENCY 25
70#define V_CONSEL 26
71#define V_CONSEL_AVAILABLE 27
72#define FLICKER_MODEL 28
73#define FLICKER_MODEL_AVAILABLE 29
74#define NOMINAL_FREQUENCY 30
75#define NOMINAL_FREQUENCY_AVAILABLE 31
76#define PROCESS_DATA 32
77#define FW_VERSION_NR 33
78#define SNEG_VOLTAGE_ANGLE 34
79#define SPOS_VOLTAGE_ANGLE 35
80#define SZRO_VOLTAGE_ANGLE 36
81#define SNEG_CURRENT_ANGLE 37
82#define SPOS_CURRENT_ANGLE 38
83#define SZRO_CURRENT_ANGLE 39
84
85// Channel specific attributes
86#define CHAN_RMS 0
87#define CHAN_ANGLE 1
88#define CHAN_HARMONICS 2
89#define CHAN_INTER_HARMONICS 3
90#define CHAN_SCALE 4
91#define CHAN_OFFSET 5
92#define CHAN_THD 6
93#define CHAN_RAW 7
94#define CHAN_VOLTAGE_UNDER_DEV 8
95#define CHAN_VOLTAGE_OVER_DEV 9
96#define CHAN_VOLTAGE_PINST 10
97#define CHAN_VOLTAGE_PST 11
98#define CHAN_VOLTAGE_PLT 12
99#define CHAN_EVENT_COUNT 13
100#define CHAN_EVENT_START_TIME 14
101#define CHAN_EVENT_END_TIME 15
102#define CHAN_EVENT_DURATION_IN_CYCL 16
103#define CHAN_EVENT_MIN_MAG 17
104#define CHAN_EVENT_MAX_MAG 18
105#define CHAN_EVENT_DELTA_U_MAX 19
106#define CHAN_EVENT_DELTA_U_SS 20
107#define CHAN_VOLTAGE_MAGNITUDE1012 21
108#define CHAN_VOLTAGE_MAX_MAGNITUDE 22
109
110#define RESAMPLED_WAVEFORM_FULL_SCALE 18196
111
112extern struct iio_device pqm_iio_descriptor;
113extern volatile bool configChanged;
114extern volatile bool processData;
115
116#endif
volatile bool processData
Definition iio_pqm.c:81
volatile bool configChanged
Definition iio_pqm.c:80
struct iio_device pqm_iio_descriptor
Definition iio_pqm.c:1160
Structure holding channels and attributes of a device.
Definition iio_types.h:238