-
Notifications
You must be signed in to change notification settings - Fork 70
/
KauraPLL.jl
89 lines (80 loc) · 3.05 KB
/
KauraPLL.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#=
This file is auto-generated. Do not edit.
=#
#! format: off
"""
mutable struct KauraPLL <: FrequencyEstimator
ω_lp::Float64
kp_pll::Float64
ki_pll::Float64
ext::Dict{String, Any}
states::Vector{Symbol}
n_states::Int
end
Parameters of a Phase-Locked Loop (PLL) based on Kaura, Vikram, and Vladimir Blasko.
"Operation of a phase locked loop system under distorted utility conditions."
IEEE Transactions on Industry applications 33.1 (1997): 58-63.
# Arguments
- `ω_lp::Float64`: PLL low-pass filter frequency (rad/sec), validation range: `(0, nothing)`
- `kp_pll::Float64`: PLL proportional gain, validation range: `(0, nothing)`
- `ki_pll::Float64`: PLL integral gain, validation range: `(0, nothing)`
- `ext::Dict{String, Any}`
- `states::Vector{Symbol}`: The states of the KauraPLL model are:
vd_pll: d-axis of the measured voltage in the PLL synchronous reference frame (SRF),
vq_pll: q-axis of the measured voltage in the PLL SRF,
ε_pll: Integrator state of the PI controller,
θ_pll: Phase angle displacement in the PLL SRF
- `n_states::Int`: KauraPLL has 4 states
"""
mutable struct KauraPLL <: FrequencyEstimator
"PLL low-pass filter frequency (rad/sec)"
ω_lp::Float64
"PLL proportional gain"
kp_pll::Float64
"PLL integral gain"
ki_pll::Float64
ext::Dict{String, Any}
"The states of the KauraPLL model are:
vd_pll: d-axis of the measured voltage in the PLL synchronous reference frame (SRF),
vq_pll: q-axis of the measured voltage in the PLL SRF,
ε_pll: Integrator state of the PI controller,
θ_pll: Phase angle displacement in the PLL SRF"
states::Vector{Symbol}
"KauraPLL has 4 states"
n_states::Int
end
function KauraPLL(ω_lp, kp_pll, ki_pll, ext=Dict{String, Any}(), )
KauraPLL(ω_lp, kp_pll, ki_pll, ext, [:vd_pll, :vq_pll, :ε_pll, :θ_pll], 4, )
end
function KauraPLL(; ω_lp, kp_pll, ki_pll, ext=Dict{String, Any}(), states=[:vd_pll, :vq_pll, :ε_pll, :θ_pll], n_states=4, )
KauraPLL(ω_lp, kp_pll, ki_pll, ext, states, n_states, )
end
# Constructor for demo purposes; non-functional.
function KauraPLL(::Nothing)
KauraPLL(;
ω_lp=0,
kp_pll=0,
ki_pll=0,
ext=Dict{String, Any}(),
)
end
"""Get [`KauraPLL`](@ref) `ω_lp`."""
get_ω_lp(value::KauraPLL) = value.ω_lp
"""Get [`KauraPLL`](@ref) `kp_pll`."""
get_kp_pll(value::KauraPLL) = value.kp_pll
"""Get [`KauraPLL`](@ref) `ki_pll`."""
get_ki_pll(value::KauraPLL) = value.ki_pll
"""Get [`KauraPLL`](@ref) `ext`."""
get_ext(value::KauraPLL) = value.ext
"""Get [`KauraPLL`](@ref) `states`."""
get_states(value::KauraPLL) = value.states
"""Get [`KauraPLL`](@ref) `n_states`."""
get_n_states(value::KauraPLL) = value.n_states
"""Set [`KauraPLL`](@ref) `ω_lp`."""
set_ω_lp!(value::KauraPLL, val) = value.ω_lp = val
"""Set [`KauraPLL`](@ref) `kp_pll`."""
set_kp_pll!(value::KauraPLL, val) = value.kp_pll = val
"""Set [`KauraPLL`](@ref) `ki_pll`."""
set_ki_pll!(value::KauraPLL, val) = value.ki_pll = val
"""Set [`KauraPLL`](@ref) `ext`."""
set_ext!(value::KauraPLL, val) = value.ext = val