DslMacroReference 2022 en
DslMacroReference 2022 en
Technical Reference
Contents
1 General Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.1 a(x-c1)(x-c2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.2 axˆ2 + bx + c . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.3 mx + n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Comparators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.1 yi equals C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.1 -C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.3 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.4 1/SQRT2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.5 2PI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.6 Bias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.7 C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.8 C1/C2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.9 E. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.10 PI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.11 PI/2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.12 SQRT(2/3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.13 SQRT(3/2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.14 SQRT(C1/C2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.15 SQRT2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.16 SQRT3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.1 aflipflop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.2 balanced . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.3 delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.4 flipflop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.5 gradlim_const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.6 invlapprox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.7 lapprox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.8 lapprox2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.9 lapproxext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.10 lastvalue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.11 lim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.12 lim_const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.13 movingavg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.14 picdro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.15 picdro_const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.16 rms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.17 sapprox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.18 sapprox2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.19 select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.20 select_const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.21 selfix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.22 selfix_const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.23 time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6 Deadbands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.1 Backlash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.2 Deadband . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7 Delays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7.11 lastvalue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8 Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.1 s/(1+sT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.2 sK/(1+0.01s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
8.3 sK/(1+sT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
9 Electric Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
9.2 PQ Calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
9.3 Power_base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
10 Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
10.1.1 (H0w0/Q)s/(w0ˆ2+sw0/Q+sˆ2) . . . . . . . . . . . . . . . . . . . 41
10.1.2 s/(w0ˆ2+sˆ2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
10.2.1 -sT/(1+sT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
10.2.3 sKT/(1+sT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
10.2.4 sKTd/(1+sT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
10.5.1 (sˆ2+wnˆ2)/(sˆ2+sBw+wnˆ2) . . . . . . . . . . . . . . . . . . . . 66
10.6.1 ((1+sTz)/(1+sTp)ˆM)ˆN . . . . . . . . . . . . . . . . . . . . . . . 67
11 Gains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
11.5 Multiply 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
11.11 Multiply K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
11.13 Multiply K1 K2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
11.14 Multiply K1 K2 / K3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
11.15 Multiply K1 K2 K3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
11.17 Multiply PI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
12.3 (1+b1s+b2ss)/(1+a1s+a2ss) . . . . . . . . . . . . . . . . . . . . . . . . . 76
12.5 (1+sT3+ssT4)/(1+sT1+ssT2) . . . . . . . . . . . . . . . . . . . . . . . . . 76
12.6 (1+sTb)(sTa)ˆ2/(1+sTa)ˆ4 . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
12.15 e(-sTd)/((1+sT1)(1+sT1)) . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
12.16 sˆ2K/(1+sT)ˆ2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
13 Integrators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
15 Limiters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
17.1.6 LN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
18 Mechanical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
20 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
22 Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
23 Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
1 General Description
A general naming convention is adopted for the global library macros in PowerFactory . The
naming convention of DSL macro objects is as follows:
F {z ame} {s\p\v;
| unctionN |
s\p\v}[s\p\v; s\p\v](s\p\v; s\p\v) _opt1_opt2_opt3. . .
{z } | {z }
function identifier Limits section Options section
In the above, “s” stand for input signals, “p” for parameters and “v” for internal variables. The
DSL macro object name (object parameter loc_name) is split in three main parts, as described
below:
• the FunctionName (mandatory) - identifies the main functionality implemented in the macro
(e.g. “1/sT”).
• the Limits section (optional) - contains a compact description of limits existing within the
macro (e.g. “[p;p]” refers to an upper and lower output limiter).
• the Options section (optional) - provides a listing of various macro options or implementa-
tion details which have been programmed into the DSL macro (e.g. “_bypass” refers to a
function which contains a parameter bypass implementation).
The syntax for limits applied to output signals uses square brackets, as defined below:
• [s\p\v; - limiter, lower side (signal/parameter/internal variable), e.g. “1/s [s;” - Integrator
macro, lower output limitation with one signal, no upper output limitation;
• ;s\p\v] - limiter, upper side (signal/parameter/internal variable), e.g. “1/s ;p]” - Integrator
macro, upper output limitation with one parameter, no lower output limitation;
• [s\p\v;s\p\v] - upper and lower limiter, asymmetrical(i.e. with separate parameters/signals/variables),
e.g. “1/s [p;p]” - Integrator macro, lower and upper output limitation with two different pa-
rameters (asymmetrical);
• [s\p\v] - upper and lower limiter (symmetrical i.e. with single parameter/signal/variable)
output limitation, e.g. “1/sT [p]” - Integrator macro, lower and upper limitation with single
parameter (symmetrical)
The syntax for limits applied to state variables (e.g. anti-windup limiters) uses round paranthe-
ses, as defined below:
• (s\p\v; - state variable, low limit (signal/parameter/internal variable), e.g. “1/s (p;” - Inte-
grator macro, state variable low limit with one parameter, no upper state variable limitation;
• ;s\p\v) - state variable, upper limit (using signal/parameter/internal variable), e.g. “1/s ;p)”
- Integrator macro, state variable upper limit with one parameter,no lower state variable
limitation;
• (s\p\v;s\p\v) - upper and lower state variable limits, asymmetrical(i.e. with separate sig-
nals/parameters/internal variables), e.g. “1/s (p;pv)” - Integrator macro, state variable low
limit depending on a parameter, state variable upper limit depending on parameter and
internal variable;
• (s\p\v) - upper and lower state variable limit, symmetrical i.e. with a single parame-
ter/signal/variable, e.g. “1/sT (p)” - Integrator macro, state variable upper and lower limit
with single parameter (symmetrical)
The syntax for gradient limits applied to output signals or state variables uses curly braces, as
defined below:
• {s\p\v; - gradient upon value decrease (using signal/parameter/internal variable), e.g. “1/s
{p;” - Integrator macro, gradient function upon value decrease using one slope parameter,
no limitation upon value increase;
• ;s\p\v} - gradient upon value increase (using signal/parameter/internal variable), e.g. “1/s
;p}” - Integrator macro, gradient function upon value increase using one slope parameter,
no limitation upon value decrease;
• {s\p\v;s\p\v} - gradient upon increase/decrease, asymmetrical(i.e. with separate sig-
nals/parameters/variables), e.g. “1/s {p;p}” - Integrator macro, gradient function upon value
increase/decrease using two gradient parameters;
• {s\p\v} - gradient upon increase/decrease, symmetrical i.e. with a single slope signal/parameter/internal
variable, e.g. “1/sT {p}” - Integrator macro, gradient function upon value increase/decrease
using a single gradient parameter;
• _bypass - This macro contains a bypass activated by on one of the (input) parameters.
• _reset - This macro includes a state/internal variable reset (based on an input signal).
• _enable - This macro includes an enable flag (based either on parameter or signal).
• _incbackward - This macro contains already initialisation statements (of states, inputs or
outputs). Initialisation occurs from output to input (backward initialisation).
• _incfreeze - This macro disables parts of its functionality for the duration of the calculation
of initial conditions and a short period afterwards (typically defined by a parameter). This
is used to avoid dx/dt<>0 messages.
• _eps - This macro contains a user defined epsilon parameter for various purposes.
• _ip - This macro uses picdro (instead of select or select_const) for logic evaluation (or
comparator) in order to avoid toggling effects by internally applying interpolation and re-
evaluation.
The limits and the options may appear in various combinations within practical DSL macros, for
example:
• 1/sT {s}[p] _bypass - Integrator macro with gradient limiter using one signal (symmetri-
cal); lower and upper limitation using one parameter (symmetrical), function implements a
bypass
• 1/sT [(p;p)] - Integrator macro with lower/upper asymetrical limit on output signal and on
state variable, using the same parameter for state variable and the output limit
• 1/sT [p;p] _bypass_reset_trigger - Integrator macro, lower and upper output limitation
with two parameters (asymmetrical); with bypass, reset and trigger functions
• 1/sT [(p)] - Integrator macro, symmetrical limiter on output signal and state variable using
a single parameter
• 1/sT {s}[pv; _bypass - Integrator macro, gradient limiter up/down with one signal (sym-
metrical); lower output limitation depending on one parameter and one internal variable;
with bypass function
Transfer functions shown throughout this document are in their standard form (monic numera-
tor/denominator polynomials and an optional gain). In some cases, for easier notation, a more
simplified form has been used.
2 Characteristics
This section provides a complete listing of the existing DSL macros within the Characteristics
folder. Their functionality is explained along with a list of the input and output signals, state
variables and parameters.
2.1.1 a(x-c1)(x-c2)
2.1.2 axˆ2 + bx + c
2.1.3 mx + n
Functionality: Lookup table function based on internal array, linear approximation. When in-
put is outside pre-defined range, output values are kept constant (characteristic clipping).
Identifies the corresponding value of the function y=f(x), where y and x are provided in the two-
column array "array\_K".
Uses the internal common model array definition (refer to lapprox() description in the User Man-
ual).
This macro has a non-linear behaviour.
Functionality: Lookup table function based on internal array, linear approximation and extrapo-
lation outside range. When "x" values are outside range of pre-defined characteristic, a linear
extrapolation is done based on the last two characteristic points of the upper or lower side, de-
pending on the situation.
Identifies the corresponding value of the function y=f(x), where y and x are provided in the two-
column array "array\_K".
Uses the internal common model array definition (refer to lapprox() description in the User Man-
ual).
This macro has a non-linear behaviour.
Functionality: Lookup table function based on internal array, spline approximation. When in-
put is outside pre-defined range, output values are kept constant (characteristic clipping).
Identifies the corresponding value of the function y=f(x), where y and x are provided in the two-
column array "array\_K".
Uses the internal common model array definition (refer to sapprox() description in the User Man-
ual).
This macro has a non-linear behaviour.
Parameters: vClip
Internal variables: m,n,m1,m2
Functionality: Lookup table function based on external array, linear approximation. When in-
put is outside pre-defined range, output values are kept constant (characteristic clipping).
Identifies the corresponding value of the function y=f(x), where y and x are provided in the two-
column array "oarray\_K".
Uses the external object IntMat (refer to lapprox description in the User Manual).
This macro has a non-linear behaviour.
Functionality: Lookup table function based on external array, linear approximation and extrapo-
lation outside range. When "x" values are outside range of pre-defined characteristic, a linear
extrapolation is done based on the last two characteristic points of the upper or lower side, de-
pending on the situation.
Identifies the corresponding value of the function y=f(x), where y and x are provided in the two-
column array "oarray\_K".
Uses the external object IntMat (refer to lapprox description in the User Manual).
This macro has a non-linear behaviour.
Functionality: Lookup table function based on external array, spline approximation. When input
is outside pre-defined range, output values are kept constant (characteristic clipping).
Identifies the corresponding value of the function y=f(x), where y and x are provided in the two-
column external array "oarray\_K".
Uses the external object IntMat (refer to sapprox description in the User Manual).
This macro has a non-linear behaviour.
3 Comparators
This section provides a complete listing of the existing DSL macros within the Comparators
folder. Their functionality is explained along with a list of the input and output signals, state
variables and parameters.
3.1.1 yi equals C
Function: (
1 if yi > C
yo =
0 otherwise
Function: (
1 if yi >= C
yo =
0 otherwise
Function: (
1 if yi < C
yo =
0 otherwise
Function: (
1 if yi <= C
yo =
0 otherwise
Functionality: Checks if the input is not equal with a constant (real numbers)
This macro has a non-linear behaviour.
Functionality: Returns 1 if first input is greater or equal than the second. Returns 0 other-
wise.
Function based on select\_const().
This macro has a non-linear behaviour.
Function: (
1 if yi1 >= yi2
yo =
0 otherwise
Functionality: Returns 1 if first input is greater than the second. Returns 0 otherwise.
Function based on select\_const().
This macro has a non-linear behaviour.
Function: (
1 if yi1 > yi2
yo =
0 otherwise
Functionality: Returns 1 if first input is less or equal than the second. Returns 0 otherwise.
Function based on select\_const().
This macro has a non-linear behaviour.
Function: (
1 if yi1 <= yi2
yo =
0 otherwise
Functionality: Returns 1 if first input is less than the second. Returns 0 otherwise.
Function based on select\_const().
This macro has a non-linear behaviour.
Function: (
1 if yi1 < yi2
yo =
0 otherwise
Checks if two real valued inputs are not equal (real numbers)
Functionality: Returns 1 if absolute value of input is greater than parameter C. Returns 0 other-
wise.
Logic function based on picdro() that avoids toggling effects but introduces step re-evaluation.
This macro has a non-linear behaviour.
Function:
1
if |yi| > C for Tpick seconds
yo = 0 if |yi| <= C for Tdrop seconds
unchanged otherwise
Input signals: yi
Parameters: C,Tpick,Tdrop
Functionality: Returns 1 if absolute value of input is smaller than parameter C. Returns 0 other-
wise.
Logic function based on picdro() that avoids toggling effects but introduces step re-evaluation.
This macro has a non-linear behaviour.
Function:
1
if |yi| < C for Tpick seconds
yo = 0 if |yi| >= C for Tdrop seconds
unchanged otherwise
Function:
1
if yi > C for Tpick seconds
yo = 0 if yi <= C for Tdrop seconds
unchanged otherwise
Function:
1
if yi >= C for Tpick seconds
yo = 0 if yi < C for Tdrop seconds
unchanged otherwise
Function:
1
if yi < C for Tpick seconds
yo = 0 if yi >= C for Tdrop seconds
unchanged otherwise
Parameters: C,Tpick,Tdrop
Function:
1
if yi <= C for Tpick seconds
yo = 0 if yi > C for Tdrop seconds
unchanged otherwise
Checks if two real valued inputs are equal (real numbers, picdro implementation)
Functionality: Returns 1 if first input is greater or equal than the second. Returns 0 other-
wise.
Logic function based on picdro() that avoids toggling effects but introduces step re-evaluation.
This macro has a non-linear behaviour.
Function:
1
if yi1 >= yi2 for Tpick seconds
yo = 0 if yi1 < yi2 for Tdrop seconds
unchanged otherwise
Functionality: Returns 1 if first input is greater than the second. Returns 0 otherwise.
Logic function based on picdro() that avoids toggling effects but introduces step re-evaluation.
This macro has a non-linear behaviour.
Function:
1
if yi1 > yi2 for Tpick seconds
yo = 0 if yi1 <= yi2 for Tdrop seconds
unchanged otherwise
Functionality: Returns 1 if first input is smaller or equal than the second. Returns 0 other-
wise.
Logic function based on picdro() that avoids toggling effects but introduces step re-evaluation.
This macro has a non-linear behaviour.
Function:
1
if yi1 <= yi2 for Tpick seconds
yo = 0 if yi1 > yi2 for Tdrop seconds
unchanged otherwise
Functionality: Returns 1 if first input is smaller than the second. Returns 0 otherwise.
Logic function based on picdro() that avoids toggling effects but introduces step re-evaluation.
This macro has a non-linear behaviour.
Function:
1
if yi1 < yi2 for Tpick seconds
yo = 0 if yi1 >= yi2 for Tdrop seconds
unchanged otherwise
Function:
1
if yi > (C + eps)
yo = 0 if yi < (C − eps)
unchanged otherwise
Functionality: Returns 1 if input is less than parameter C. Returns 0 otherwise. Function in-
cludes a small threshold upon switching around the constant C.
This block avoids toggling behaviour when the input signal value is close to the constant param-
eter C.
The threshold is defined by parameter eps and it is usually set to a small user defined value.
If set=rst=1 (at within deadband condition) then output is undefined.
If eps=0, then this block is a simple logic function without switching threshold.
This macro has a non-linear behaviour.
Function:
1
if yi < (C − eps)
yo = 0 if yi > (C + eps)
unchanged otherwise
Function:
1
if yi1 > (yi2 + eps)
yo = 0 if yi1 < (yi2 − eps)
unchanged otherwise
Function:
1
if yi1 < (yi2 − eps)
yo = 0 if yi1 > (yi2 + eps)
unchanged otherwise
4 Constants
This section provides a complete listing of the existing DSL macros within the Constants folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
4.1 -C
Functionality: Outputs a constant value equal to -C. This macro has a linear behaviour.
4.2 0
Functionality: Outputs a constant zero value. This macro has a linear behaviour.
Output signals: yo
4.3 1
Outputs 1
Output signals: yo
4.4 1/SQRT2
Outputs 1/SQRT2
Output signals: yo
4.5 2PI
Outputs 2*PI
Output signals: yo
4.6 Bias
Functionality: Outputs a constant value defined by the value of the output at initialisation. This
block requires that the macro’s output is initialised externally. This macro has a linear behaviour.
4.7 C
Functionality: Outputs a constant value, defined by parameter C. This macro has a linear be-
haviour.
4.8 C1/C2
Functionality: Outputs a constant value, defined by parameter C1 and C2, equal to C1/C2. This
macro has a linear behaviour.
4.9 E
Outputs e
Functionality: Outputs e, base of the natural logarithm. This macro has a linear behaviour.
Output signals: yo
4.10 PI
Outputs PI
Output signals: yo
4.11 PI/2
Outputs PI/2
Output signals: yo
4.12 SQRT(2/3)
Outputs SQRT(2/3)
Output signals: yo
4.13 SQRT(3/2)
Outputs SQRT(3/2)
Output signals: yo
4.14 SQRT(C1/C2)
4.15 SQRT2
Outputs SQRT2
Output signals: yo
4.16 SQRT3
Outputs SQRT3
Output signals: yo
This section provides a complete listing of the existing DSL macros within the DSL Special
Functions folder. Their functionality is explained along with a list of the input and output signals,
state variables and parameters.
5.1 aflipflop
Function aflipflop(yi,set,rst)
Functionality: Implements the DSL special function aflipflop(), using input signals yi, set and rst.
This macro has a non-linear behaviour.
5.2 balanced
Function balanced()
Output signals: yo
5.3 delay
Function delay()
Functionality: Applies a time delay of duration T on the input. The output is the delayed value of
the input. This macro has a non-linear behaviour.
5.4 flipflop
Function flipflop(set,rst)
Functionality: Implements the DSL special function flipflop() based on the input signals set and
rst. This macro has a non-linear behaviour.
5.5 gradlim_const
Function gradlim_const()
Functionality: Implements the DSL special function gradlim_const(). This macro has a non-
linear behaviour.
Output signals: yo Input signals: yi Lower limitation parameters: gradmin Upper limitation
parameters: gradmax
5.6 invlapprox
Function invlapprox()
Functionality: Implements the DSL special function invlapprox(). This macro has a non-linear
behaviour.
5.7 lapprox
Function lapprox()
Functionality: Implements the DSL special function lapprox(). This macro has a non-linear
behaviour.
5.8 lapprox2
Function lapprox2()
Functionality: Implements the DSL special function lapprox2(). This macro has a non-linear
behaviour.
5.9 lapproxext
Function lapproxext()
Functionality: Implements the DSL special function lapproxext(). This macro has a non-linear
behaviour.
5.10 lastvalue
Function lastvalue()
Functionality: Implements the DSL special function lastvalue(). This macro has a non-linear
behaviour.
5.11 lim
Function lim(yi,y_min,y_max)
Functionality: Implements the DSL special function lim(). Limits input yi based on input signals
y_min and y_max. This macro has a non-linear behaviour.
5.12 lim_const
Function lim_const(yi,y_min,y_max)
Functionality: Implements the DSL special function lim_const(). Limits the input yi based on the
parameters y_min and y_max. This macro has a non-linear behaviour.
Output signals: yo Input signals: yi Lower limitation parameters: y_min Upper limitation
parameters: y_max
5.13 movingavg
Functionality: Implements a buffer based moving average filter. The function includes a delay
or a buffer based DSL function in the input-output path. This macro has a non-linear behaviour.
5.14 picdro
Function picdro(condition,Tpick,Tdrop)
Functionality: Implements the DSL special function picdro(). Sets the output yo to HIGH if
condition is TRUE for at least Tpick seconds. If the output is HIGH, then it sets the output yo to
LOW if condition is FALSE for at least Tdrop seconds. Tpick and Tdrop are input signals. output
can be 1 = HIGH or 0 = LOW if condition >= 0.5 then evaluate to TRUE if condition < 0.5 then
evaluate to FALSE This macro has a non-linear behaviour.
5.15 picdro_const
Function picdro_const(condition,Tpick,Tdrop)
Functionality: Implements the DSL special function picdro(). Sets the output yo to HIGH if
condition is TRUE for at least Tpick seconds. If the output is HIGH, then it sets the output yo to
LOW if condition is FALSE for at least Tdrop seconds. Tpick and Tdrop are parameters. output
can be 1 = HIGH or 0 = LOW if condition >= 0.5 then evaluate to TRUE if condition < 0.5 then
evaluate to FALSE This macro has a non-linear behaviour.
5.16 rms
Function rms()
Functionality: Returns the dynamic simulation type (RMS=1 or EMT=0). This macro has a
non-linear behaviour.
Output signals: yo
5.17 sapprox
Function sapprox()
Functionality: Implements the DSL special function sapprox(). This macro has a non-linear
behaviour.
5.18 sapprox2
Function sapprox2()
Functionality: Implements the DSL special function sapprox2(). This macro has a non-linear
behaviour.
5.19 select
Function select(condition,y_true,y_false)
Functionality: Implements the DSL special function select(). Sets the output yo to y_true if
condition is TRUE. Sets the output yo to y_false if condition is FALSE. output can be y_true OR
y_false. Both y_true and y_false are input signals. if condition >= 0.5 then evaluate to TRUE if
condition < 0.5 then evaluate to FALSE This macro has a non-linear behaviour.
5.20 select_const
Function select_const(condition,K_true,K_false)
Functionality: Implements the DSL special function select_const(). Sets the output yo to K_true
if condition is TRUE. Sets the output yo to K_false if condition is FALSE. output can be K_true
OR K_false. Both K_true and K_false are parameters. if condition >= 0.5 then evaluate to TRUE
if condition < 0.5 then evaluate to FALSE This macro has a non-linear behaviour.
5.21 selfix
Function selfix(condition,y_true,y_false)
Functionality: Implements the DSL special function selfix(). Sets the output yo to y_true if con-
dition is TRUE at initialisation. Sets the output yo to y_false if condition is FALSE at initialisation.
output can be y_true OR y_false. Both y_true and y_false are input signals. if condition >= 0.5
then evaluate to TRUE if condition < 0.5 then evaluate to FALSE This macro has a non-linear
behaviour.
5.22 selfix_const
Function selfix_const(condition,K_true,K_false)
Functionality: Implements the DSL special function selfix_const(). Sets the output yo to K_true
if condition is TRUE at initialisation. Sets the output yo to K_false if condition is FALSE at
initialisation. output can be K_true OR K_false. Both K_true and K_false are parameters. if
condition >= 0.5 then evaluate to TRUE if condition < 0.5 then evaluate to FALSE This macro
has a non-linear behaviour.
5.23 time
Function time()
Functionality: Returns the current simulation time. This macro has a non-linear behaviour.
Output signals: yo
6 Deadbands
This section provides a complete listing of the existing DSL macros within the Deadbands folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
6.1 Backlash
Backlash function
Functionality: This macro implements a backlash function. Bypass option: if the deadband db
is <=0 then yo is constant throughout the simulation. This macro has a non-linear behaviour.
6.2 Deadband
Continuos deadband
Functionality: This macro implements a continuous deadband block Returns: yi-db if yi > db
(outside deadband, positive side) yi+db if yi <-db (outside deadband, negative side) 0 if -db < yi
< db (within deadband)
Functionality: This macro implements a continuous deadband with limits and bypass Bypass
option: A bypass function is also included if the deadband db is zero. yi-db if yi > db (outside
deadband, positive side) yi+db if yi <-db (outside deadband, negative side) 0 if -db < yi < db
(within deadband) Output yo is limited between y_min and y_max This macro has a non-linear
behaviour.
Functionality: This macro implements a continuous deadband blockwith bypass Returns: yi-db
if |yi| > db (outside deadband, positive side) yi+db if |yi| <-db (outside deadband, negative side)
0 if -db < yi < db (within deadband) Bypass option: A bypass function is also included if the
deadband db is zero. if db<=0, then yo=yi This macro has a non-linear behaviour.
Discontinuous deadband
Functionality: This macro implements a discontinuous deadband This macro has a non-linear
behaviour.
Functionality: This macro implements a continuous deadband with offset and limits. Bypass
option: A bypass function is also included if the deadband db<=0. This macro has a non-linear
behaviour.
Functionality: This macro implements a continuous deadband with offset. Bypass option: A
bypass function is also included if the deadband db<=0. This macro has a non-linear behaviour.
Functionality: This macro implements a stepped deadband with limits. Bypass option: A bypass
function is also included if the deadband db<=0. This macro has a non-linear behaviour.
Functionality: This macro implements a stepped deadband. Bypass option: A bypass function
is also included if the deadband db<=0. This macro has a non-linear behaviour.
7 Delays
This section provides a complete listing of the existing DSL macros within the Delays folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
Transport delay with gain and initial condition for output, T>=0 (bypass)
Functionality: This macro implements a transport delay with gain and initial condition for output.
The function includes a delay or a buffer based DSL function in the input-output path. Parameter
T must be non-negative. Otherwise a message is printed to the output window. Bypass option:
If T<=0 then yo=K*yi (gain block) Forward initial condition option: Output is initialised based on
the input This macro has a non-linear behaviour.
Function:
H(s) = K e−sT
Transport delay with gain and initial condition for output, T>0
Functionality: This macro implements a transport delay with gain and initial condition for output.
The function includes a delay or a buffer based DSL function in the input-output path. Parameter
T must be positive. Otherwise a message is printed to the output window. Forward initial
condition option: Output is initialised based on the input This macro has a non-linear behaviour.
Function:
H(s) = K e−sT
Pade Second Order Approximation (one zero, two poles; bacward initialisation yi<-yo)
Functionality: Implements the time continuous Pade approximation for delays, 2nd order (R1,2):
one zero, two poles.
Parameters: Td - time delay in seconds A time delay Td smaller than 0.1 ms is not allowed, for
robust operation. Backward initial condition option: Initialisation occurs from the output to the
input.
Function:
Td T d2 2
1− 2 s + 12 s
H(s) = Td T d2 2
1+ 2 s + 12 s
Pade Second Order Approximation (one zero, two poles; forward initialisation yi->yo)
Functionality: Implements the time continuous Pade approximation for delays, 2nd order (R1,2):
one zero, two poles.
Parameters: Td - time delay in seconds A time delay Td smaller than 0.1 ms is not allowed, for
robust operation. Forward initial condition option: Output is initialised based on the input.
Function:
Td T d2 2
1− 2 s + 12 s
H(s) = Td T d2 2
1+ 2 s + 12 s
Functionality: This macro implements a transport delay of 10 ms with initial condition for output.
The function includes a delay or a buffer based DSL function in the input-output path. Forward
initial condition option: Output is initialised based on the input. Note: The delay function should
be provided with a corresponding initial condition on either its input or output. In the case of
forward initialisation, the output should be initialised with the value of the input. In the case of
backward initialisation, the input should be initialised based on the value of the output. This
macro has a non-linear behaviour.
Function:
H(s) = e−s0.01
Functionality: This macro implements a transport delay. The function includes a delay or a buffer
based DSL function in the input-output path. Parameter T must be non-negative. Otherwise a
message is printed to the output window. Note: The delay function should be provided with a
corresponding initial condition on either its input or output. In the case of forward initialisation,
the output should be initialised with the value of the input. In the case of backward initialisation,
the input should be initialised based on the value of the output. Bypass option: If T<=0 then
yo=yi (feedthrough block) This macro has a non-linear behaviour.
Function:
H(s) = e−sT
Functionality: This macro implements a transport delay with initial condition for output. The
function includes a delay or a buffer based DSL function in the input-output path. Parameter T
must be non-negative. Otherwise a message is printed to the output window. Note: The delay
function should be provided with a corresponding initial condition on either its input or output.
In the case of forward initialisation, the output should be initialised with the value of the input.
In the case of backward initialisation, the input should be initialised based on the value of the
output. Bypass option: If T<=0 then yo=yi (feedthrough block) Backward initial condition option:
Input is initialised based on the output. This macro has a non-linear behaviour.
Function:
H(s) = e−sT
Functionality: This macro implements a transport delay with initial condition for output. The
function includes a delay or a buffer based DSL function in the input-output path. Parameter T
must be non-negative. Otherwise a message is printed to the output window. Note: The delay
function should be provided with a corresponding initial condition on either its input or output.
In the case of forward initialisation, the output should be initialised with the value of the input.
In the case of backward initialisation, the input should be initialised based on the value of the
output. Bypass option: If T<=0 then yo=yi (feedthrough block) Forward initial condition option:
Output is initialised based on the input. This macro has a non-linear behaviour.
Function:
H(s) = e−sT
Functionality: This macro implements a transport delay with initial condition for output. The
function includes a delay or a buffer based DSL function in the input-output path. Parameter
T must be positive. Otherwise a message is printed to the output window. Backward initial
condition option: Input is initialised based on the output. This macro has a non-linear behaviour.
Function:
H(s) = e−sT
Functionality: This macro implements a transport delay with initial condition for output. The
function includes a delay or a buffer based DSL function in the input-output path. Parameter
T must be positive. Otherwise a message is printed to the output window. Note: The delay
function should be provided with a corresponding initial condition on either its input or output.
In the case of forward initialisation, the output should be initialised with the value of the input.
In the case of backward initialisation, the input should be initialised based on the value of the
output. Forward initial condition option: Output is initialised based on the input. This macro has
a non-linear behaviour.
Function:
H(s) = e−sT
7.11 lastvalue
Functionality: Outputs the value of the input at the previous simulation time step. The function
includes a delay or a buffer based DSL function in the input-output path. Note: The lastvalue
function should be provided with a corresponding initial condition on either its input or output.
In the case of forward initialisation, the output should be initialised with the value of the input.
In the case of backward initialisation, the input should be initialised based on the value of the
output. This macro has a non-linear behaviour.
Functionality: Outputs the value of the input at the previous simulation time step. The function
includes a delay or a buffer based DSL function in the input-output path. Note: The lastvalue
function should be provided with a corresponding initial condition on either its input or output.
In the case of forward initialisation, the output should be initialised with the value of the input.
In the case of backward initialisation, the input should be initialised based on the value of the
output. Backward initial condition option: Input is initialised based on the output. This macro
has a non-linear behaviour.
Functionality: Outputs the value of the input at the previous simulation time step. The function
includes a delay or a buffer based DSL function in the input-output path. Note: The lastvalue
function should be provided with a corresponding initial condition on either its input or output.
In the case of forward initialisation, the output should be initialised with the value of the input.
In the case of backward initialisation, the input should be initialised based on the value of the
output. This macro has a non-linear behaviour.
8 Derivatives
This section provides a complete listing of the existing DSL macros within the Derivatives folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
8.1 s/(1+sT)
Functionality: This block implements a first order lag differentiator. Parameter T must be posi-
tive. Otherwise, a message is printed to the output window. This macro has a linear behaviour.
Function:
s 1 s
H(s) = = 1
1 + sT T T +s
8.2 sK/(1+0.01s)
Functionality: This block implements a derivative with gain and first order lag (time constant is
0.01 s) This macro has a linear behaviour.
Function:
sK K s
H(s) = = 1
1 + s0.01 0.01 0.01+s
8.3 sK/(1+sT)
Functionality: This block implements a first order lag differentiator block with gain K and time
constant T Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
sK K s
H(s) = = 1
1 + sT T T +s
Output signals: yo Input signals: yi Continuous states: x Parameters: K,T Internal vari-
ables: dx
Functionality: This block implements a first order lag differentiator block with gain K and time
constant T Parameter T must be non-negative. Otherwise, a message is printed to the output
window. Fallback option: If T<=0, the use T=0.01 This macro has a linear behaviour.
Function:
sK K s
H(s) = = 1
1 + sT T T +s
Output signals: yo Input signals: yi Continuous states: x Parameters: K,T Internal vari-
ables: dx
9 Electric Power
This section provides a complete listing of the existing DSL macros within the Electric Power
folder. Their functionality is explained along with a list of the input and output signals, state
variables and parameters.
Functionality: This macro outputs the generator electrical power in generator MVA base (IPB=1).
or in generator MW base (IPB=0)
9.2 PQ Calculator
Functionality: Computes the active and reactive power of complex current and voltage. This
macro has a linear behaviour.
9.3 Power_base
Functionality: This macro tranforms the p.u. generator electrical power in the base defined by
parameter PN. If PN =0, then no conversion is performed. This macro has a linear behaviour.
10 Filters
This section provides a complete listing of the existing DSL macros within the Filters folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
10.1.1 (H0w0/Q)s/(w0ˆ2+sw0/Q+sˆ2)
Function:
H0 · ω0 s
H(s) = 2 ω0
Q ω0 + Q s + s2
10.1.2 s/(w0ˆ2+sˆ2)
Function:
s
H(s) =
ω02 + s2
10.2.1 -sT/(1+sT)
Functionality: This macro implements a first order differentiator with time constant T and gain
-1.
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
−sT s
H(s) = = −1 1
1 + sT T +s
Functionality: This macro implements a first order differentiator with time constant T and gain
-1.
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Bypass option: if T<=0, then output is zero.
This macro has a linear behaviour.
Function:
−sT s
H(s) = = −1 1
1 + sT T +s
10.2.3 sKT/(1+sT)
First order lag differentiator with gain and derivative time constant
Functionality: This block implements a first order lag differentiator with gain and derivative time
constant
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
sKT s
H(s) = =K 1
1 + sT T +s
10.2.4 sKTd/(1+sT)
First order lag differentiator with gain, derivative and lag time constant
Functionality: This block implements a first order lag differentiator with gain, derivative and
lag time constant
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
sKTd Td s
H(s) = =K 1
1 + sT T T +s
Functionality: This block implements a first order lag differentiator block with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Bypass option: if T<=0, then block is a feedthrough (output is equal to input).
This macro has a linear behaviour.
Function:
sT s
H(s) = = 1
1 + sT T +s
Functionality: This block implements a first order lag differentiator block with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Enable option:
if T>0, then output is enabled (normal transfer function)
if T<=0, then output is 0 and state variable is frozen
This macro has a linear behaviour.
Function:
sT s
H(s) = = 1
1 + sT T +s
Functionality: This block implements a first order lag differentiator, time constant Ta (bypass)
Parameter Ta must be non-negative. Otherwise, a message is printed to the output window.
Fallback option: if Ta<=0, then assign Ta=0.01
This macro has a linear behaviour.
Function:
sTb Tb s
H(s) = = 1
1 + sTa Ta Ta +s
Functionality: This block implements a first order lag differentiator with time constant Tlg and
derivative time constant Tld
Parameter Tlg must be non-negative. Otherwise, a message is printed to the output window.
Fallback option: If Tlg<=0, then assign Tlg=0.01
Function:
sTld Tld s
H(s) = = 1
1 + sTlg Tlg Tlg +s
First order lag, anti-windup limiter, symmetrical, with reset and hold
Functionality: This macro implements a first order lag, state variable limit, symmetrical,
with reset to initial value and output hold capability.
Time constant T must be positive for correct operation
Upper limitation y\_max parameter must be non-negative for correct operation. Otherwise, a
message is printed to the output window.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
First order lag, state and derivative rate limit, with reset and hold
Functionality: This macro implements a first order lag, state and derivative rate limit,
with reset to initial value and output hold capability.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
First order lag, state limit, symmetrical, with reset and hold
Functionality: This macro implements a first order lag, state limit based on signal, symmetri-
cal,
with reset to initial value and output hold capability.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a first order lag, state limit based on signals (asymmetri-
cal),
with reset to initial value and output hold capability.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
First order lag, state limit based on parameters (asymmetrical), with reset and hold
Functionality: This macro implements a first order lag, state limit based on parameters (asym-
metrical),
with reset to initial value and output hold capability.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a first order lag block with time constant T,
with reset to initial value and output hold capability.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: Implements second order Butterworth low pass filter, with reset and hold
Normalised denominator polynomial (from table): 1+1.414s+s\ˆ2
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1
H(s) = s 2
1 + 1.414 wsc + wc
Functionality: Implements third order Butterworth low pass filter, with reset and hold
Normalised denominator polynomial (from table): 1 + 2*s + 2*s\ˆ2 + s\ˆ3
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a linear behaviour.
Function:
1
H(s) =
1+ 2 wsc + 2 wsc 2 + s 3
wc
First order lag, anti-windup limiter, symmetrical, with reset and hold
Functionality: This macro implements a first order lag, state variable limit, symmetrical,
with reset to value of input x\_rst and output hold capability.
Time constant T must be positive for correct operation
Upper limitation y\_max parameter must be non-negative for correct operation. Otherwise, a
message is printed to the output window.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Macro location: Macros\Filters\Low Pass Filters\with reset (to input signal value)
Macro DSL level: 7
Output signals: yo
Input signals: yi,hold,x\_rst
Upper limitation input signals: rst
Continuous states: x
Parameters: T
Upper limitation parameters: y\_max
First order lag, state and derivative rate limit, with reset and hold
Functionality: This macro implements a first order lag, state and derivative rate limit,
with reset to value of input x\_rst and output hold capability.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Macro location: Macros\Filters\Low Pass Filters\with reset (to input signal value)
Macro DSL level: 7
Output signals: yo
Input signals: yi,hold,x\_rst
Upper limitation input signals: rst
Continuous states: x
Parameters: T
Lower limitation parameters: y\_min,r\_min
Upper limitation parameters: y\_max,r\_max
First order lag, state limit, symmetrical, with reset and hold
Functionality: This macro implements a first order lag, state limit based on signal, symmetri-
cal,
with reset to value of input x\_rst and output hold capability.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Macro location: Macros\Filters\Low Pass Filters\with reset (to input signal value)
Macro DSL level: 7
Output signals: yo
Input signals: yi,hold,x\_rst
Upper limitation input signals: y\_max,rst
Continuous states: x
Parameters: T
Functionality: This macro implements a first order lag, state limit based on signals (asymmetri-
cal),
with reset to value of input x\_rst and output hold capability.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Macro location: Macros\Filters\Low Pass Filters\with reset (to input signal value)
Macro DSL level: 7
Output signals: yo
Input signals: yi,hold,x\_rst
Lower limitation input signals: y\_min
Upper limitation input signals: y\_max,rst
Continuous states: x
Parameters: T
First order lag, state limit based on parameters (asymmetrical), with reset and hold
Functionality: This macro implements a first order lag, state limit based on parameters (asym-
metrical),
with reset to value of input x\_rst and output hold capability.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Macro location: Macros\Filters\Low Pass Filters\with reset (to input signal value)
Macro DSL level: 7
Output signals: yo
Input signals: yi,hold,x\_rst
Upper limitation input signals: rst
Continuous states: x
Parameters: T
Lower limitation parameters: y\_min
Upper limitation parameters: y\_max
Functionality: This macro implements a first order lag block with time constant T,
with reset to value of input x\_rst and output hold capability.
Parameter T must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Macro location: Macros\Filters\Low Pass Filters\with reset (to input signal value)
Macro DSL level: 7
Output signals: yo
Input signals: yi,hold,x\_rst
Upper limitation input signals: rst
Continuous states: x
Parameters: T
10.3.3.1 (1-K)/(1+sT)
Functionality: This macro implements a first order lag with 1-K gain and time constant T.
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
1−K 1−K 1
H(s) = = 1
1 + sT T T +s
First order lag with 1-K gain and time constant (bypass)
Functionality: This macro implements a first order lag with 1-K gain and time constant. It also
includes a bypass function.
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Bypass option: if T<=0 then block is a gain, yo=(1-K)*yi
This macro has a linear behaviour.
Function:
1−K 1−K 1
H(s) = = 1
1 + sT T T +s
10.3.3.3 1/(1+sT)
Functionality: This macro implements a first order lag block with time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a first order lag, state variable limit, symmetrical
Time constant T must be positive for correct operation
Upper limitation y\_max parameter must be non-negative for correct operation. Otherwise, a
message is printed to the output window.
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a first order lag, state and derivative rate limit
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a first order lag, state limit based on signal, symmetri-
cal
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a first order lag, state limit based on signals (asymmetri-
cal)
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a first order lag, state limit based on parameters (asym-
metrical)
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a first order lag block with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Bypass option: if T<=0, block is bypassed (yo=yi)
This macro has a linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: This block implements a first order lag block with time constant T and enable
signal.
Parameter T must be positive. Otherwise, a message is printed to the output window.
Enable option:
If enable < 0.5 then output and state are frozen
If enable >= 0.5 then filter is enabled.
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a first order lag with derivative rate limits (bypass)
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Bypass option: if T<=0 then yo = yi
This macro has a non-linear behaviour.
Function:
1 1 1
H(s) = = 1
1 + sT T T +s
10.3.3.13 1/(1+sT/2)
Functionality: This macro implements a first order lag variant (T/2 time constant)
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
1 2 1
H(s) = = 2
1 + sT /2 T T +s
10.3.3.14 1/(K+sT)
First order lag with 1/T gain and T/K time constant
Functionality: This macro implements a first order delay with gain 1/K and time constant T/K
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
1 1 1
H(s) = = K
K + sT T T +s
First order lag with 1/T gain and T/K time constant (bypass)
Functionality: This macro implements a first order delay with gain 1/K and time constant T/K
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Bypass option: if T<=0 then yo = yi/K
Function:
1 1 1
H(s) = = K
K + sT T T +s
10.3.3.16 1/K(T1/T2-1)(1/(1+sT2))
Function:
T1 T1
T2 −1 1 −1 1
H(s) = = T2 1
K 1 + sT2 KT2 T2 +s
Functionality: This macro implements a first order lag with gain 1/K.
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Parameter K must be positive. Otherwise, a message is printed to the output window.
Bypass option: If T<=0, block is a gain 1/K
This macro has a linear behaviour.
Function:
1 1 1 1
H(s) = = 1
K 1 + sT KT T +s
Output signals: yo
Input signals: yi
Continuous states: x
Parameters: K,T
Function:
1
H(s) = s 2
1 + 1.414 wsc + wc
Function:
1
H(s) =
1+ 2 wsc + 2 wsc 2 + s 3
wc
10.3.3.20 K/(1+sT)
Functionality: This macro implements a first order lag block with gain K/T and time constant
T.
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
K K 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a state limited first order lag block with gain K/T and
time constant T.
Upper limit is an input signal, lower limit a parameter.
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Bypass option: if T<=0, then block is a gain (yo=K*yi) with limited output.
This macro has a non-linear behaviour.
Function:
K K 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a state limited first order lag block with gain K/T and
time constant T.
Upper and lower limit is an input signal.
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Bypass option: if T<=0, then block is a gain (yo=K*yi) with limited output.
This macro has a non-linear behaviour.
Function:
K K 1
H(s) = = 1
1 + sT T T +s
First order lag with gain, state limited, limits proportional to limiter input signal
Functionality: This macro implements a state limited first order lag block with gain K/T and
time constant T
Limits are proportional to limiter signal.
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
K K 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a state limited first order lag block with bypass and gain.
The state variable and the output are limited using parameters "y\_min" and "y\_max".
Function:
K K 1
H(s) = = 1
1 + sT T T +s
Functionality: This macro implements a first order lag block with gain K/T and time constant
T.
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Bypass option: if T<=0, then block is a gain (yo=K*yi) with limited output.
This macro has a linear behaviour.
Function:
K K 1
H(s) = = 1
1 + sT T T +s
10.3.3.26 K1 + K2/(1+sT)
Functionality: This block implements a first order lag in parallel with gain.
This block uses 3 parameters: K1, K2 and T.
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
K1 +K2
K2 K1 T +s
H(s) = K1 + = K1 1
1 + sT T + s
10.3.3.27 KT/(1+sT)
Functionality: This block implements a first order lag with gain K*T.
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
KT 1
H(s) = =K 1
1 + sT T +s
Functionality: Implements a buffer based moving average filter. The function includes a de-
lay or a buffer based DSL function in the input-output path.
This macro has a non-linear behaviour.
Moving Average Filter (time continuous implementation, without buffers, with enable)
Moving average filter with Tavg sliding window and enable signal
Implemented based on a 2nd order Pade approximation, as below
This macro has a linear behaviour.
10.5.1 (sˆ2+wnˆ2)/(sˆ2+sBw+wnˆ2)
Notch filter
Function:
wn2 + s2
H(s) =
wn2 + Bw s + s2
Functionality: Block that implements a notch filter with bypass for Bw parameter.
Bypass: If Bw <= 0 and wn <= 0 then output = input
Function:
wn2 + s2
H(s) =
wn2 + Bw s + s2
10.6.1 ((1+sTz)/(1+sTp)ˆM)ˆN
Ramp-tracking filter
Functionality: This block implements a transfer function as described in IEEE Std 421.5 Rec-
ommended Practice for Excitation System Models For Power System Stability Studies (Models
PSS2A/PSS2B/PSS2C).
Parameter Tp must be positive. Otherwise, a message is printed to the output window.
Parameters M and N must have integer values between 0 and 8 (included). If outside range, a
message is printed to the output window. Furthermore, the product N*M must not be greater
than 8 (included).
This macro has a linear behaviour.
Function:
1 + sTz N
H(s) = [ ]
(1 + sTp )M
11 Gains
This section provides a complete listing of the existing DSL macros within the Gains folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
Sign invert
Functionality: Multiplies the input by -1. This macro has a linear behaviour.
Function:
H(s) = −1
Gain -K
Functionality: Multiplies the input by -K. This macro has a linear behaviour.
Function:
H(s) = −K
Gain 1-K
Functionality: Multiplies the input by (1-K). This macro has a linear behaviour.
Function:
H(s) = 1 − K
Gain 1-K1-K2
Functionality: Multiplies the input by (1-K1-K2). This macro has a linear behaviour.
Function:
H(s) = 1 − K1 − K2
11.5 Multiply 1
Feedthrough block
Function:
H(s) = 1
Inverse Gain
Functionality: Multiplies the input by 1/K. If K=0 then output is zero This macro has a linear
behaviour.
Function:
1
H(s) =
K
Functionality: Multiplies the input by 1/K and limits the output within y_min and y_max. If K=0,
output is zero (upper/lower limits still applicable on 0). This macro has a non-linear behaviour.
Function:
1
H(s) =
K
Functionality: Multiplies the input by 1/(K1*K2) and limits the output within y_min and y_max.
This macro has a non-linear behaviour.
Function:
1
H(s) =
K1 · K2
Functionality: Divides the input by sqrt(2). This macro has a linear behaviour.
Function:
1
H(s) = √
2
Functionality: Divides the input by sqrt(3). This macro has a linear behaviour.
Function:
1
H(s) = √
3
11.11 Multiply K
Gain K
Function:
H(s) = K
Functionality: Multiplies the input by K and limits the output within y_min and y_max values.
This macro has a non-linear behaviour.
Function:
H(s) = K
11.13 Multiply K1 K2
Gain K1 * K2
Functionality: Multiplies the input by K1*K2. This macro has a linear behaviour.
Function:
H(s) = K1 · K2
11.14 Multiply K1 K2 / K3
Gain K1*K2/K3
Functionality: Multiplies the input by K1*K2/K3. This macro has a linear behaviour.
Function:
K1 · K2
H(s) =
K3
11.15 Multiply K1 K2 K3
Gain K1 * K2 * K3
Functionality: Multiplies the input signal with three constant parameters K1, K2 and K3. This
macro has a linear behaviour.
Function:
H(s) = K1 · K2 · K3
Gain K1/K2
Functionality: Multiplies the input by K1/K2. This macro has a linear behaviour.
Function:
K1
H(s) =
K2
11.17 Multiply PI
Gain of PI
Functionality: Multiplies the input by PI. This macro has a linear behaviour.
Function:
H(s) = π
Functionality: Multiplies the input by sqrt(2/3). This macro has a linear behaviour.
Function: r
2
H(s) =
3
Functionality: Multiplies the input by sqrt(3/2). This macro has a linear behaviour.
Function: r
3
H(s) =
2
Functionality: Multiplies the input by sqrt(K1/K2), where K1 and K2 are constant parameters.
This macro has a linear behaviour.
Function: r
K1
H(s) =
K2
Functionality: Multiplies the input by sqrt(2). This macro has a linear behaviour.
Function: √
H(s) = 2
Functionality: Multiplies the input by sqrt(3). This macro has a linear behaviour.
Function: √
H(s) = 3
This section provides a complete listing of the existing DSL macros within the Higher Order
Transfer Functions folder. Their functionality is explained along with a list of the input and output
signals, state variables and parameters.
(1+B1s+B2ss)/(1+A1s+A2ss) (bypass)
Function:
1 + B1 s + B2 s2
H(s) =
1 + A1 s + A2 s2
(1+KsTc)/((1+sTa)(1+sTb)(1+sTc)) (bypass)
Function:
1 + K · Tc s
H(s) =
(1 + sTa )(1 + sTb )(1 + sTc )
12.3 (1+b1s+b2ss)/(1+a1s+a2ss)
(1+b1s+b2ss)/(1+a1s+a2ss)
Function:
1 + b1 s + b2 s2
H(s) =
1 + a1 s + a2 s2
(1+sT3)/(1+sT1+ssT1T2) (bypass)
Function:
1 + sT3
H(s) =
1 + sT1 + s2 T1 T2
Output signals: yo Input signals: yi Continuous states: x1,x2 Parameters: T1,T2,T3 Inter-
nal variables: dx1
12.5 (1+sT3+ssT4)/(1+sT1+ssT2)
(1+sT3+ssT4)/(1+sT1+ssT2)
Function:
1 + sT3 + s2 T4
H(s) =
1 + sT1 + s2 T2
12.6 (1+sTb)(sTa)ˆ2/(1+sTa)ˆ4
(1+sTb)(sTa)_2/(1+sTa)_4
Function:
(1 + sTb )(sTa )2
H(s) =
(1 + sTa )4
(1+ssT3)/(1+sT1+ssT2) (bypass)
Function:
1 + s2 T3
H(s) =
1 + sT1 + s2 T2
Output signals: yo Input signals: yi Continuous states: x1,x2 Parameters: T1,T2,T3 Inter-
nal variables: dx2
(A0+sA1+ssA2)/(B0+sB1+ssB2) (bypass)
Function:
A0 + sA1 + s2 A2
H(s) =
B0 + sB1 + s2 B2
(ss)/(Ass+Bs+1) (bypass)
Function:
s2
H(s) =
As2 + Bs + 1
Output signals: yo Input signals: yi Continuous states: x1,x2 Parameters: A,B Internal
variables: triv,dx1,dx2
(ss+ww)/(ss+sB+ww) (bypass)
Function:
ω 2 + s2
H(s) =
s2 + sB + ω 2
Output signals: yo Input signals: yi Continuous states: x1,x2 Parameters: B,w Internal
variables: triv,dx1,dx2
Second order low pass filter with cutoff frequency wc and damping factor zeta
Functionality: This block implements second order low pass filter with characteristic frequency
wc and damping factor zeta vardef(wc)=’rad/s’;’Cutoff frequency’ vardef(zeta)=’n/a’;’Damping
factor’ This macro has a linear behaviour.
Function:
1 ωc2
H(s) = 2ζ
=
1 + ωc s + 1 2
ωc2 s
ωc2 + 2ζωc s + s2
Function:
1
H(s) =
1 + sT1 + s2 T2
K(1+sT1)(1+sT2)/(s(1+sT3)) [(p;p)]
Function:
(1 + sT1 )(1 + sT2 )
H(s) = K
s(1 + sT3 )
Function:
K(1 + sTd
H(s) =
s(1 + sTa )(1 + sTb )
12.15 e(-sTd)/((1+sT1)(1+sT1))
Functionality: This block implements a second order lag with ideal delay. The function includes
a delay or a buffer based DSL function in the input-output path. Parameter T1, T2 and Td must
be positive. Otherwise, a message is printed to the output window. This macro has a non-linear
behaviour.
Function:
e−sTd
H(s) =
(1 + sT1 )2
12.16 sˆ2K/(1+sT)ˆ2
Functionality: This block implements a second order lag differentiator with gain Parameter T
must be positive. Otherwise, a message is printed to the output window. This macro has a
linear behaviour.
Function:
Ks2
H(s) =
(1 + sT )2
Output signals: yo Input signals: yi Continuous states: x1,x2 Parameters: K,T Internal
variables: dx1,dx2
13 Integrators
This section provides a complete listing of the existing DSL macros within the Integrators folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
Integrator, state limited by parameters and with reset (to initial value)
Function:
1
H(s) =
s
Integrator with signal limits (asymmetrical), hold signal and with reset (to initial value)
Function:
1
H(s) =
s
Integrator with parameter limits (asymmetrical) and reset (to initial value)
Function:
1
H(s) =
s
Integrator with parameter limits (symmetrical) and with reset (to initial value)
Function:
1
H(s) =
s
Integrator with signal limits (asymmetrical) and with reset (to initial value)
Function:
1
H(s) =
s
Integrator with signal limits (symmetrical) and with reset (to initial value)
Function:
1
H(s) =
s
Input signals: yi
Upper limitation input signals: rst,y\_max
Continuous states: x
Internal variables: xinc
Function:
1
H(s) =
s
Integrator with delayed start based on parameter Tincfreeze and with reset (to initial
value)
Function:
1
H(s) =
s
Continuous states: x
Parameters: Tincfreeze
Internal variables: t0,xinc
Functionality: This macro implements a continuous time integrator block and reset.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a linear behaviour.
Function:
1
H(s) =
s
Function:
1
H(s) =
sT
Integrator, state limits, symmetrical, time constant T and with reset (to initial value)
Functionality: This macro implements a state limited integrator with time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state limits, symmetrical, time constant T (fallback) and with reset (to initial
value)
Functionality: This macro implements a state limited integrator with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state lower limit, time constant T and with reset (to initial value)
Functionality: This macro implements an integrator, state lower limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state lower limit, time constant T (fallback) and with reset (to initial value)
Functionality: This macro implements a state lower limited integrator with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state limits, time constant T (fallback) and with reset (to initial value)
Functionality: This macro implements a state limited integrator with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state limits based on parameter/signal, time constant T (fallback) and with re-
set
Function:
1
H(s) =
sT
Integrator, parameter scaled limits, time constant T and with reset (to initial value)
Functionality: This macro implements an integrator, parameter scaled limits, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state limits based on signal/parameter, time constant T (fb) and with reset
Function:
1
H(s) =
sT
Continuous states: x
Parameters: T
Upper limitation parameters: y\_max
Internal variables: xinc
Integrator, state limits by signals, time constant T (fb) and with reset (to initial value)
Functionality: This macro implements an integrator, state limits by signals, time constant T
(bypass)
Lower and upper limits are input signals.
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state lower limit, time constant T (fb) and with reset (to initial value)
Functionality: This macro implements an integrator, state lower limit, time constant T (bypass)
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Input signals: yi
Upper limitation input signals: rst
Continuous states: x
Parameters: T
Upper limitation parameters: y\_max
Internal variables: xinc
Integrator, state lower limit, time constant T and with reset (to initial value)
Functionality: This macro implements an integrator, state lower limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state upper limit, time constant T (fb) and with reset (to initial value)
Functionality: This macro implements an integrator, state upper limit, time constant T (bypass)
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state upper limit, time constant T and with reset (to initial value)
Functionality: This macro implements an integrator, state upper limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state lower limit, time constant T (fb) and with reset (to initial value)
Functionality: This macro implements an integrator, state lower limit, time constant T (bypass)
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Continuous states: x
Parameters: T
Lower limitation parameters: y\_min
Internal variables: xinc
Integrator, state lower limit, time constant T and with reset (to initial value)
Functionality: This macro implements an integrator, state lower limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator with time constant T and delayed start based on parameter Tincfreeze and with
reset
Functionality: Integrator with time constant T and delayed start based on parameter Tincfreeze
Option \_bypass: if time constant T<=0 then block is a feedthrough
Option \_incfreeze: blocks integrator at initialization and afterwards for a duration of Tincfreeze
seconds.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, time constant T (fb) and with reset (to initial value)
Function:
1
H(s) =
sT
Integrator with time constant T and delayed start based on parameter Tincfreeze and with
reset
Functionality: Integrator with time constant T and delayed start based on parameter Tincfreeze
Option \_incfreeze: blocks integrator at initialization and afterwards for a duration of Tincfreeze
seconds.
Option \_reset: The state "x" is reset to its initial value upon "rst" signal crossing 0.5 on rising
flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Continuous states: x
Parameters: T,Tincfreeze
Internal variables: t0,xinc
Integrator, state limited by parameters, with reset (to input signal value)
Function:
1
H(s) =
s
Integrator with signal limits (asymmetrical), hold signal, with reset (to input signal value)
Function:
1
H(s) =
s
Integrator with parameter limits (asymmetrical), with reset (to input signal value)
Function:
1
H(s) =
s
Integrator with parameter limits (symmetrical), with reset (to input signal value)
Function:
1
H(s) =
s
Integrator with signal limits (asymmetrical), with reset (to input signal value)
Function:
1
H(s) =
s
Integrator with signal limits (symmetrical), with reset (to input signal value)
Function:
1
H(s) =
s
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a linear behaviour.
Function:
1
H(s) =
s
Integrator with delayed start based on parameter Tincfreeze, with reset (to input signal
value)
Function:
1
H(s) =
s
Functionality: This macro implements a continuous time integrator block and reset.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a linear behaviour.
Function:
1
H(s) =
s
Function:
1
H(s) =
sT
Integrator, state limits, symmetrical, time constant T, with reset (to input signal value)
Functionality: This macro implements a state limited integrator with time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Output signals: yo
Input signals: yi,xrst
Upper limitation input signals: rst
Continuous states: x
Parameters: T
Upper limitation parameters: y\_max
Integrator, state limits, symmetrical, time constant T (fallback), with reset (to input signal
valu
Functionality: This macro implements a state limited integrator with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state lower limit, time constant T, with reset (to input signal value)
Functionality: This macro implements an integrator, state lower limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state lower limit, time constant T (fallback), with reset (to input signal value)
Functionality: This macro implements a state lower limited integrator with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state limits, time constant T (fallback), with reset (to input signal value)
Functionality: This macro implements a state limited integrator with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Parameters: T
Lower limitation parameters: y\_min
Upper limitation parameters: y\_max
Integrator, state limits based on parameter/signal, time constant T (fallback), with reset
Function:
1
H(s) =
sT
Integrator, parameter scaled limits, time constant T, with reset (to input signal value)
Functionality: This macro implements an integrator, parameter scaled limits, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Parameters: T,K
Lower limitation parameters: y\_min
Upper limitation parameters: y\_max
Integrator, state limits based on signal/parameter, time constant T (fallback) , with reset
Function:
1
H(s) =
sT
Integrator, state limits by signals, time constant T (fallback), with reset (to input signal
value)
Functionality: This macro implements an integrator, state limits by signals, time constant T
(bypass)
Lower and upper limits are input signals.
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state lower limit, time constant T (fallback), with reset (to input signal value)
Functionality: This macro implements an integrator, state lower limit, time constant T (bypass)
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state lower limit, time constant T, with reset (to input signal value)
Functionality: This macro implements an integrator, state lower limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state upper limit, time constant T (fallback), with reset (to input signal value)
Functionality: This macro implements an integrator, state upper limit, time constant T (bypass)
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state upper limit, time constant T, with reset (to input signal value)
Functionality: This macro implements an integrator, state upper limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state lower limit, time constant T (fallback), with reset (to input signal value)
Functionality: This macro implements an integrator, state lower limit, time constant T (bypass)
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Option \_fb: if T<=0, then output keeps initial value.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, state lower limit, time constant T, with reset (to input signal value)
Functionality: This macro implements an integrator, state lower limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator with time constant T and delayed start based on parameter Tincfreeze, with
reset
Functionality: Integrator with time constant T and delayed start based on parameter Tincfreeze
Option \_bypass: if time constant T<=0 then block is a feedthrough
Option \_incfreeze: blocks integrator at initialization and afterwards for a duration of Tincfreeze
seconds.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Integrator, time constant T (fallback), with reset (to input signal value)
Function:
1
H(s) =
sT
Integrator with time constant T and delayed start based on parameter Tincfreeze, with
reset
Functionality: Integrator with time constant T and delayed start based on parameter Tincfreeze
Option \_incfreeze: blocks integrator at initialization and afterwards for a duration of Tincfreeze
seconds.
Option \_reset\_sig: The state "x" is reset to value of "xrst" input signal upon "rst" signal crossing
0.5 on rising flank.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
13.3.1 1/s
Integrator
Function:
1
H(s) =
s
Function:
1
H(s) =
s
Function:
1
H(s) =
s
Function:
1
H(s) =
s
Output signals: yo
Input signals: yi
Continuous states: x
Lower limitation parameters: y\_min
Upper limitation parameters: y\_max
Function:
1
H(s) =
s
Function:
1
H(s) =
s
Function:
1
H(s) =
s
Integrator
Function:
1
H(s) =
s
Function:
1
H(s) =
s
13.3.10 1/sT
Function:
1
H(s) =
sT
Functionality: This macro implements a state limited integrator with time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Functionality: This macro implements a state limited integrator with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Fallback option: if T<=0, then output keeps initial value.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Functionality: This macro implements an integrator, state lower limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Functionality: This macro implements a state lower limited integrator with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Fallback option: if T<=0, then output keeps initial value.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Functionality: This macro implements a state limited integrator with time constant T
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Fallback option: if T<=0, then output keeps initial value.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Function:
1
H(s) =
sT
Functionality: This macro implements an integrator, parameter scaled limits, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Function:
1
H(s) =
sT
Continuous states: x
Parameters: T
Upper limitation parameters: y\_max
Functionality: This macro implements an integrator, state limits by signals, time constant T
(bypass)
Lower and upper limits are input signals.
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Fallback option: if T<=0, then output keeps initial value.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Functionality: This macro implements an integrator, state lower limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Functionality: This macro implements an integrator, state lower limit, time constant T (bypass)
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Fallback option: if T<=0, then output keeps initial value.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Functionality: This macro implements an integrator, state upper limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Functionality: This macro implements an integrator, state upper limit, time constant T (bypass)
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Fallback option: if T<=0, then output keeps initial value.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Functionality: This macro implements an integrator, state lower limit, time constant T
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Functionality: This macro implements an integrator, state lower limit, time constant T (bypass)
Parameter T must be non-negative. Otherwise, a message is printed to the output window.
Fallback option: if T<=0, then output keeps initial value.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Input signals: yi
Continuous states: x
Parameters: T
Lower limitation parameters: y\_min
Integrator with time constant T and delayed start based on parameter Tincfreeze
Functionality: Integrator with time constant T and delayed start based on parameter Tincfreeze
Option bypass: if time constant T<=0 then block is a feedthrough
Option incfreeze: blocks integrator at initialization and afterwards for a duration of Tincfreeze
seconds.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
Function:
1
H(s) =
sT
Integrator with time constant T and delayed start based on parameter Tincfreeze
Functionality: Integrator with time constant T and delayed start based on parameter Tincfreeze
Option incfreeze: blocks integrator at initialization and afterwards for a duration of Tincfreeze
seconds.
This macro has a non-linear behaviour.
Function:
1
H(s) =
sT
13.3.29 K/s
Function:
1
H(s) = K
s
Functionality: This block implements an integrator with gain, state limit by parameters, asym-
metrical
This macro has a non-linear behaviour.
Function:
1
H(s) = K
s
Functionality: This block implements an integrator with gain, upper/lower input limit signals.
State variable and output are limited using the same input limit signals y\_min and y\_max.
This macro has a non-linear behaviour.
Function:
1
H(s) = K
s
14 Lead-lag Blocks
This section provides a complete listing of the existing DSL macros within the Lead-lag Blocks
folder. Their functionality is explained along with a list of the input and output signals, state
variables and parameters.
14.1 (1+ATs)/(1+BTs)
Functionality: Block that implements a continuous time lead-lag transfer function. Uses three
parameters: A, B and T. Parameters T and B must be positive. Otherwise, a message is printed
to the output window.
Function:
1
1 + AT s A AT +s
H(s) = = 1
1 + BT s B BT +s
14.2 (1+sTb)/(1+sTa)
Functionality: This macro implements a lead-lag block using two parameters Ta and Tb. Param-
eter Ta must be positive. Otherwise, a message is printed to the output window. This macro has
a linear behaviour.
Function:
1
1 + sTb Tb Tb +s
H(s) = = 1
1 + sTa Ta Ta +s
Functionality: This macro implements a state limited lead-lag block with bypass. The state
variable and the output are limited using parameters "y_min" and "y_max". Parameter Ta must
be non-negative. Otherwise, a message is printed to the output window. Bypass option: if
Ta<=0 or Ta=Tb, block is a limited feed-through yo = yi between y_min and y_max limits. This
macro has a non-linear behaviour.
Function:
1
1 + sTb Tb Tb +s
H(s) = = 1
1 + sTa Ta Ta +s
Output signals: yo Input signals: yi Continuous states: x Parameters: Tb,Ta Lower limita-
tion parameters: y_min Upper limitation parameters: y_max Internal variables: dx,yox
Functionality: This macro implements a first order lead-lag block with anti-windup limits. Param-
eter Ta must be non-negative. Otherwise, a message is printed to the output window. Fallback
option: If lag time constant Ta<=0 then use Ta=0.01. This macro has a non-linear behaviour.
Function:
1
1 + sTb Tb Tb +s
H(s) = = 1
1 + sTa Ta Ta +s
Output signals: yo Input signals: yi Continuous states: x Parameters: Tb,Ta Lower limita-
tion parameters: y_min Upper limitation parameters: y_max Internal variables: dx,yox
Functionality: This macro implements a lead-lag block with anti windup limits dependent on
parameters K, y_min and y_max Parameter Ta must be non-negative. Otherwise, a message
is printed to the output window. Parameter K must be positive. Otherwise a message is printed
to the output window. Bypass option: if Ta<=0 Ta=Tb, block is a limited feed-through yo = yi
between y_min/K and y_max/K limits. This macro has a non-linear behaviour.
Function:
1
1 + sTb Tb Tb +s
H(s) = = 1
1 + sTa Ta Ta +s
Output signals: yo Input signals: yi Continuous states: x Parameters: Tb,Ta,K Lower lim-
itation parameters: y_min Upper limitation parameters: y_max Internal variables: dx,yox
Functionality: This macro implements a lead-lag block with bypass. Bypass option: If Ta>0 then
block is a lead-lag If Ta<=0 .or. Ta=Tb then block is bypassed (yo=yi) Parameter Ta must be
non-negative. Otherwise, a message is printed to the output window. This macro has a linear
behaviour.
Function:
1
1 + sTb Tb Tb +s
H(s) = = 1
1 + sTa Ta Ta +s
Lead-lag block with lead time constant Tld and lag time constant Tlg
Lead-lag block (variant) Tld - lead time constant Tlg - lag time constant If Tlg=0, then Tlg=0.01
Function:
1
1 + sTld Tld Tld +s
H(s) = = 1
1 + sTlg Tlg Tlg +s
14.8 (1-ATs)/(1+sAT/2)
Functionality: This macro implements a lead-lag block with gain and time constant Parameter A
and T must be non-negative. Otherwise, a message is printed to the output window. This macro
has a linear behaviour.
Function:
1
1 + AT s AT − s
H(s) = = 2 2
1 + A T2 s AT + s
Output signals: yo Input signals: yi Continuous states: x Parameters: A,T Internal vari-
ables: dx,Tz
Functionality: This block implements a variant of a lead-lag block based on a single parameter
T. it also includes a bypass in case T=0. Parameter T must be non-negative. Otherwise, a
message is printed to the output window. Bypass option: If T<=0 then yo=yi (feedthrough
block). This macro has a linear behaviour.
Function:
1
1 − sT −s
H(s) = = 2 T2
1 + sT /2 T +s
14.10 (K+sTb)/(1+sTa)
Functionality: This macro implements a variant of a lead-lag using three parameters K, Ta and
Tb. Parameter Ta must be positive. Otherwise, a message is printed to the output window. This
macro has a linear behaviour.
Function:
K
K + sTb Tb Tb +s
H(s) = = 1
1 + sTa Ta Ta +s
Functionality: This macro implements a lead-lag block using three parameters a, b and T. Pa-
rameter T must be non-negative. Otherwise, a message is printed to the output window. Bypass
option: if T<=0, block is a gain yo=a*yi This macro has a linear behaviour.
Function: a
a + sbT +s
H(s) = = b bT
1
1 + sT T + s
Output signals: yo Input signals: yi Continuous states: x Parameters: a,b,T Internal vari-
ables: dx
14.12 K(1+sTb)/(1+sTa)
Functionality: This macro implements a lead-lag block with gain, time constant Ta Parameter
Ta must be positive. Otherwise, a message is printed to the output window. This macro has a
linear behaviour.
Function:
1
K(1 + sTb ) Ta Tb +s
H(s) = = 1
1 + sTa KTb Ta +s
Functionality: This macro implements a lead-lag block with gain, time constant Tlg (fallback
value) Parameter Tlg must be non-negative. Otherwise, a message is printed to the output
window. Fallback option: If Tlg<=0, then use Tlg=0.01 This macro has a linear behaviour.
Function:
1
K(1 + sTld ) Tlg Tld +s
H(s) = = 1
1 + sTlg KTld Tlg +s
14.14 K(A1+sT1)/(A2+sT2)
Functionality: This macro implements a general first order lead-lag block, 5 parameters Param-
eter T2 must be positive. Otherwise, a message is printed to the output window. This macro
has a linear behaviour.
Function:
A1
K(A1 + sT1 ) T1 T1 +s
H(s) = =K A2
A2 + sT2 T2 T2 +s
General first order lead lag block with state and output limits, time constant T2 (fallback
value)
Functionality: This macro implements a general first order lead lag block with state limits, time
constant T2 (fallback value) Parameters T1 and T2 must be non-negative. Otherwise, a mes-
sage is printed to the output window. Fallback option: if T2<=0 then use T2=0.01 This macro
has a non-linear behaviour.
Function:
A1
K(A1 + sT1 ) T1 T1 +s
H(s) = =K A2
A2 + sT2 T2 T2 +s
Functionality: This macro implements a general first order lead-lag block with 5 parameters.
Parameter T2 must be non-negative. Otherwise, a message is printed to the output window.
Fallback option: If T2<=0, then use T2=0.01 This macro has a linear behaviour.
Function:
A1
K(A1 + sT1 ) T1 T1 +s
H(s) = =K A2
A2 + sT2 T2 T2 +s
14.17 a23(1+(a11-a13a21/a23)sTw)/(1+a11sTw)
a23(1+(a11-a13a21/a23)sTw)/(1+a11sTw)
Functionality: This block implements the first order transfer function H(s)=a23(1+(a11-a13a21/a23)sTw)/(1+a11sTw)
Parameter Tw must be positive. Otherwise, a message is printed to the output window. Param-
eter a11 must be positive. Otherwise, a message is printed to the output window. This macro
has a linear behaviour.
Function:
1 + (a11 − a13 a21 /a23 )Tw s
H(s) = a23
1 + a11 Tw s
15 Limiters
This section provides a complete listing of the existing DSL macros within the Limiters folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
Functionality: This block implements an upper limiter with a small threshold upon switching
between the linear and the limitted regions. This block avoids toggling behaviour when the input
signal is at one of the limit values. The threshold is defined by parameter eps and it is usually
set to a small user defined value. If set=rst=1 (at within deadband condition) then output is
undefined. If eps=0, then this block is an upper limiter without switching threshold. This macro
has a non-linear behaviour.
Output signals: yo Input signals: yi Parameters: eps Upper limitation parameters: y_max
Internal variables: setmax,rstmax,yo_max
Functionality: This block implements a lower limiter with a small threshold upon switching be-
tween the linear and the limitted regions. This block avoids toggling behaviour when the input
signal is at one of the limit values. The threshold is defined by parameter eps and it is usually
set to a small user defined value. If set=rst=1 (at within deadband condition) then output is
undefined. If eps=0, then this block is a lower limiter without switching threshold. This macro
has a non-linear behaviour.
Output signals: yo Input signals: yi Parameters: eps Lower limitation parameters: y_min
Internal variables: setmin,rstmin,yo_min
Functionality: This block implements an asymmetric limit (upper/lower) This macro has a non-
linear behaviour.
Output signals: yo Input signals: yi Lower limitation parameters: y_min Upper limitation
parameters: y_max
Functionality: This block implements a symmetric limiter with a small threshold upon switching
between the linear and the limitted regions. This block avoids toggling behaviour when the input
signal is at one of the limit values. The threshold is defined by parameter eps and it is usually
set to a small user defined value. If set=rst=1 (at within deadband condition) then output is
undefined. If eps=0, then this block is an asymmetric limiter without switching threshold. This
macro has a non-linear behaviour.
Output signals: yo Input signals: yi Parameters: eps Lower limitation parameters: y_min
Upper limitation parameters: y_max Internal variables: setmin,rstmin,setmax,rstmax,yo_min,yo_max
Limiter (lower/upper,symmetric)
Functionality: This block implements a symmetric limit. Parameter y_lim must be positive. Oth-
erwise a message is printed to the output window. This macro has a non-linear behaviour.
Limiter (lower/upper,symmetric)
Functionality: This block implements a symmetric limiter. Parameter y_lim must be positive.
Otherwise a message is printed to the output window. This macro has a non-linear behaviour.
Functionality: This block implements a symmetric limiter with a small threshold upon switching
between the linear and the limitted regions. This block avoids toggling behaviour when the input
signal is at one of the limit values. The threshold is defined by parameter eps and it is usually set
to a small user defined value. Parameter y_lim must be positive. Otherwise a message is printed
to the output window. If set=rst=1 (at within deadband condition) then output is undefined. If
eps=0, then this block is a symmetric limiter without switching threshold. This macro has a
non-linear behaviour.
Output signals: yo Input signals: yi Parameters: eps Upper limitation parameters: y_lim
Internal variables: setmin,rstmin,setmax,rstmax,yo_min,yo_max
Functionality: This block implements an asymmetric limiter with signals (upper/lower) This
macro has a non-linear behaviour.
Output signals: yo Input signals: yi Lower limitation input signals: y_min Upper limitation
input signals: y_max
Functionality: This block implements a symmetric limiter with a small threshold upon switching
between the linear and the limitted regions. This block avoids toggling behaviour when the input
signal is at one of the limit values. The threshold is defined by parameter eps and it is usually
set to a small user defined value. If set=rst=1 (at within deadband condition) then output is
undefined. If eps=0, then this block is an asymmetric limiter without switching threshold. This
macro has a non-linear behaviour.
Output signals: yo Input signals: yi Lower limitation input signals: y_min Upper limitation
input signals: y_max Parameters: eps Internal variables: setmin,rstmin,setmax,rstmax,yo_min,yo_max
Functionality: This block implements an asymmetric limiter with signals (upper/lower) and pa-
rameters (upper/lower). This macro has a non-linear behaviour.
Output signals: yo Input signals: yi Lower limitation input signals: yi_min Upper limitation
input signals: yi_max Lower limitation parameters: y_min Upper limitation parameters:
y_max
Limiter (lower)
Functionality: This block implements a lower limit. This macro has a non-linear behaviour.
Limiter (upper)
Functionality: This block implements an upper limit. This macro has a non-linear behaviour.
Functionality: This block implements a gradient limiter (upper) Parameter grd_up will always
be interpreted as a positive gradient when input is increasing. This macro has a non-linear
behaviour.
Functionality: This block implements an upper gradient limiter block Parameters: base - the
base value of the input signal, this leads to a gradient limitation in pu/s grd_up - upper gradient
parameter, must be positive, in p.u., base value = base Parameter grd_up will always be inter-
preted as a positive gradient when input is increasing. This macro has a non-linear behaviour.
Output signals: yo Input signals: yi Parameters: base Upper limitation parameters: grd_up
Functionality: This block implements a lower gradient limiter block Parameters: base - the base
value of the input signal, this leads to a gradient limitation in pu/s grd_down - lower gradient
parameter, in p.u., base value = base Parameter grd_down will always be interpreted as a
negative gradient when input is decreasing. This macro has a non-linear behaviour.
Output signals: yo Input signals: yi Parameters: base Lower limitation parameters: grd_down
Functionality: This block implements a gradient limiter (asymmetrical) using parameters grd_up
and grd_down Parameters: base - the base value of the input signal, this leads to a gradient
limitation in pu/s grd_down - lower gradient parameter in p.u., base value = base grd_up - upper
gradient parameter in p.u., base value = base Parameter grd_up will always be interpreted as a
positive gradient when input is increasing. Parameter grd_down will always be interpreted as a
negative gradient when input is decreasing. This macro has a non-linear behaviour.
Output signals: yo Input signals: yi Parameters: base Lower limitation parameters: grd_down
Upper limitation parameters: grd_up
Functionality: This block implements a gradient limiter block (upper/lower), symmetric, in per-
unit Parameters: base - the base value of the input signal, this leads to a gradient limitation in
pu/s grd - gradient parameter, in p.u., base value = base Parameter grd will always be interpreted
as a positive gradient when input is increasing. Parameter grd will always be interpreted as a
negative gradient when input is decreasing. This macro has a non-linear behaviour.
Output signals: yo Input signals: yi Parameters: base Upper limitation parameters: grd
Functionality: This block implements a gradient limiter (lower) Parameter grd_down will always
be interpreted as a negative gradient when input is decreasing. This macro has a non-linear
behaviour.
Output signals: yo Input signals: yi Lower limitation parameters: grd_down Upper limita-
tion parameters: grd_up
Functionality: This block implements an asymmetric gradient limiter using adjustable input limits.
Attention: This macro uses the DSL special function lastvalue (buffer based). The output yo of
this block is simulation time step dependent This macro has a non-linear behaviour.
Output signals: yo Input signals: yi Lower limitation input signals: grd_down Upper limi-
tation input signals: grd_up Internal variables: yi0,t0,dt,dy
16 Logic Functions
This section provides a complete listing of the existing DSL macros within the Logic Functions
folder. Their functionality is explained along with a list of the input and output signals, state
variables and parameters.
16.1.1 AND2
16.1.2 AND3
16.1.3 AND4
16.1.4 EOR
Functionality: Implements the logic function EOR (NOT EQUAL) with two inputs
yi1 and yi2 are assumed to be boolean input values
false =(-oo,0.5)
true =[0.5, oo)
Truth table
-------------------------
| yi1 | yi2 | yo |
|-----------------------|
| false | false | false |
| true | false | true |
| false | true | true |
| true | true | false |
-------------------------
This macro has a non-linear behaviour.
16.1.5 EQUAL
16.1.6 NOR
|-----------------------|
| false | false | true |
| true | false | false |
| false | true | false |
| true | true | false |
-------------------------
This macro has a non-linear behaviour.
16.1.7 NOT
16.1.8 OR2
-------------------------
This macro has a non-linear behaviour.
16.1.9 OR3
16.1.10 OR4
-----------------
This macro has a non-linear behaviour.
16.3.1 Bistable
Functionality: The Edge Detector block outputs an impulse (the value of 1 for one time step)
when the logical input changes
If EDGE< 0.5 (e.g. EDGE=0 (default value) ) then the detection occurs on the rising edge (from
FALSE (yi<0.5) to TRUE (yi>=0.5) ).
If 0.5<=EDGE< 1.5 (e.g. EDGE=1) then the detection occurs on the falling edge (from TRUE
(yi>=0.5) to FALSE (yi<0.5) ).
If EDGE>=1.5 (e.g. EDGE=2) then the detection occurs on either edges.
16.3.3 Monostable
17 Math Functions
This section provides a complete listing of the existing DSL macros within the Math Functions
folder. Their functionality is explained along with a list of the input and output signals, state
variables and parameters.
17.1.1 ABS
17.1.2 CEIL
17.1.3 EXP
Exponential function
17.1.4 FLOOR
17.1.5 FRAC
17.1.6 LN
17.1.7 LOG
Logarithm to base of 10
17.1.8 MAX2
17.1.9 MAX3
17.1.10 MAX4
17.1.11 MIN2
17.1.12 MIN3
17.1.13 MIN4
17.1.14 MODULO
17.1.15 RECIPROCAL
Input signals: u
17.1.17 ROUND
17.1.18 SIGN
17.1.19 SQRT
17.1.20 xˆ2
Square function
17.1.21 xˆp
Functionality: Retrieves the magnitude of a complex quantity with real and imaginary com-
ponents ’re’ and ’im’.
This macro has a non-linear behaviour.
Functionality: Compute the polar form of a complex number from rectangular form.
Output phi is in radians.
This macro has a non-linear behaviour.
Functionality: Compute the rectangular form of a complex number from polar form.
This macro has a non-linear behaviour.
17.3.1 ACOS
Arccosine of input
17.3.2 ASIN
Arcsine of input
17.3.3 ATAN
Arctangent of input
17.3.4 ATAN2
Four-quadrant arctangent
Functionality: Returns the principal value of the angle, given in radians, between the Euclidean
plane positive x-axis and the ray to the point (re,im) of the complex value defined by inputs "re"
and "im".
Output is in radians, ranging between (-pi,pi].
This macro has a non-linear behaviour.
17.3.5 ATAN2D
Functionality: Returns the principal value of the angle, given in degrees, between the Euclidean
plane positive x-axis and the ray to the point (re,im) of the complex value defined by inputs "re"
and "im".
Output is in degrees, ranging between (-180,180].
This macro has a non-linear behaviour.
Output signals: yo
Input signals: re,im
17.3.6 ATAND
Functionality: Returns the arctangent of the input (input is the tangent of angle).
Output yo is expressed in degrees
This macro has a linear behaviour.
17.3.7 COS
Cosine of input
17.3.8 COSD
17.3.9 COSH
17.3.10 COSHD
17.3.11 SIN
Sine of input
17.3.12 SIND
17.3.13 SINH
17.3.14 SINHD
17.3.15 TAN
Tangent of input
17.3.16 TAND
17.3.17 TANH
17.3.18 TANHD
18 Mechanical
This section provides a complete listing of the existing DSL macros within the Mechanical folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
18.1 1/(2Hs)
Inertia H
Functionality: This macro computes the accelerating power This macro has a linear behaviour.
Functionality: This macro calculates the accellerating power of a machine in either generator
MVA base (IPB=1) or in generator MW base (IPB=0)
Gear Box
18.5 Mass_J
Mass_J
Output signals: omega Input signals: M1,M2 Continuous states: xomega Parameters: J
Functionality: This macro computes torque based on speed and power. Speed input ’omega’ is
expressed in rad/s. ’Power’ input is expressed in kW. ’Torque’ output is expressed in Nm. This
18.7 Pt/Pturb
Functionality: This block converts the turbine power from the base defined by parameter PN to
the generator MW base. If PN=0, no conversion is perfromed This macro has a linear behaviour.
Single mass p.u. shaft model with one coupling and input power
Functionality: This block implements a single mass p.u. shaft model with one coupling and input
power Nominal torque Tnom = Snom/(2*pi*fnom)
Single mass p.u. shaft model with one coupling, no input power
Functionality: This block implements a single mass p.u. shaft model with one coupling, no input
power Nominal torque Tnom = Snom/(2*pi*fnom)
Single mass p.u. shaft model with two couplings, no input power
Functionality: This block implements a single mass p.u. shaft model with two couplings, no input
power Nominal torque Tnom = Snom/(2*pi*fnom)
Single mass p.u. shaft model with two couplings and input power
Functionality: This block implements a single mass p.u. shaft model with two couplings and
input power Nominal torque Tnom = Snom/(2*pi*fnom)
18.12 Spring
Spring
19 PI(D) Controllers
This section provides a complete listing of the existing DSL macros within the PI(D) Controllers
folder. Their functionality is explained along with a list of the input and output signals, state
variables and parameters.
PI controller, parallel variant, with anti-windup limiter and integrator time constant
Functionality: This macro implements a variant of a PI Controller (parallel variant) with the
possibility to apply performance parameters.
Controller proportional gain and integrator time constant are tuned using performance parame-
ters Kc, tau\_p and theta\_p.
Selectable tuning methods: Internal Model Control (IMC) and Integral of Time-weighted Abso-
lute Error (ITAE)
The parameters K\_p, T\_p, and theta\_p should be entered/obtained by fitting dynamic input
and output data to a first-order plus dead-time (FOPDT) model.
Tunable parameters:
- K\_p: Process gain - affects the magnitude of the response, regardless of the speed of re-
sponse. Kp=steady state change in measured process variable / steady state change in con-
troller output
- T\_p: Process time constant, in seconds - (the amount of time needed for the output to reach
(1-exp(-1)) or 63.2\% of the way to steady state conditions. The process time constant affects
the speed of response.
- theta\_p: Process dead time, in seconds - the time delay is expressed as a time shift in the
input variable
PI Controller parameters (calculated parameters based on the tunable parameters):
- Proportional gain: Kc
- Integral time constant: Ti, in seconds
Parameter Ti must be positive. Otherwise, a message is printed to the output window.
ControlTuning: selects one of the available tuning modes: IMC aggressive, IMC moderate, IMC
conservative, ITAE set point tracking, ITAE Disturbance rejection
1=IMC Aggressive tuning:
tau\_c = max(0.1*T\_p,0.8*theta\_p)
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
2=IMC Moderate tuning: tau\_c = max(1*T\_p,8.0*theta\_p
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
3=IMC Conservative tuning: tau\_c = max(10.0*T\_p,80.0*theta\_p
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
4=ITAE Set point tracking:
Kc = 0.586/Kp*(theta\_p/T\_p)\ˆ-0.916
Ti = T\_p/(1.03-0.165*(theta\_p/T\_p)
any other value=ITAE Disturbance rejection:
Kc = 0.859/Kp*(theta\_p/T\_p)\ˆ-0.977
Ti = T\_p/0.674*(theta\_p/T\_p)\ˆ0.680
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1
1 +s
H(s) = Kc + = Kc Kc Ti
sTi s
PI controller, parallel variant, with anti-windup limiter and integrator time constant
Functionality: This macro implements a variant of a PI Controller (parallel variant) with the
possibility to apply performance parameters.
Controller proportional gain and integrator time constant are tuned using performance parame-
ters Kc, tau\_p and theta\_p.
Selectable tuning methods: Internal Model Control (IMC) and Integral of Time-weighted Abso-
lute Error (ITAE)
The parameters K\_p, T\_rise, and theta\_p should be entered/obtained by fitting dynamic input
and output data to a first-order plus dead-time (FOPDT) model.
The parameter T\_p is computed based on the input parameter T\_rise - rise time of a first order
equivalated plant model
Tunable parameters:
- K\_p: Process gain - affects the magnitude of the response, regardless of the speed of re-
sponse. Kp=steady state change in measured process variable / steady state change in con-
troller output
- T\_rise: Process rise time, in seconds - the time needed for the output to reach 90% from 10%
of the way to steady state conditions assuming a first order system for the process.
- theta\_p: Process dead time, in seconds - the time delay is expressed as a time shift in the
input variable
PI Controller parameters (calculated parameters based on the tunable parameters):
- Proportional gain: Kc
- Integral time constant: Ti, in seconds
Parameter Ti must be positive. Otherwise, a message is printed to the output window.
Internal variable T\_p: Process time constant, in seconds - (the amount of time needed for the
output to reach (1-exp(-1)) or 63.2\% of the way to steady state conditions. The process time
constant affects the speed of response.
ControlTuning: selects one of the available tuning modes: IMC aggressive, IMC moderate, IMC
conservative, ITAE set point tracking, ITAE Disturbance rejection
1=IMC Aggressive tuning:
tau\_c = max(0.1*T\_p,0.8*theta\_p)
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
2=IMC Moderate tuning: tau\_c = max(1*T\_p,8.0*theta\_p
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
3=IMC Conservative tuning: tau\_c = max(10.0*T\_p,80.0*theta\_p
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
4=ITAE Set point tracking:
Kc = 0.586/Kp*(theta\_p/T\_p)\ˆ-0.916
Ti = T\_p/(1.03-0.165*(theta\_p/T\_p)
any other value=ITAE Disturbance rejection:
Kc = 0.859/Kp*(theta\_p/T\_p)\ˆ-0.977
Ti = T\_p/0.674*(theta\_p/T\_p)\ˆ0.680
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1
1 +s
H(s) = Kc + = Kc Kc Ti
sTi s
Function:
1/Ti + s
H(s) = Kp
s
PI controller, series variant, gain Kp, time constant Ti, with anti-windup, reset and hold
Functionality: This block implements a PI controller, series variant with anti-windup, with state
reset and output hold function.
The anti-windup implementation is based on the backfeed of the saturated output (external sig-
nal) and the unsaturated output (internal).
The difference between these two is used as a second term fed to the integrator input.
Proportional gain: Kp
Integral time constant: Ti
Time constant Tt determines how quickly the integrator is reset.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1/Ti + s
H(s) = Kp
s
PI controller, series variant, gain Kp, time constant Ti, reset and hold
Functionality: This block implements a PI controller, series variant, with state reset and out-
put hold function.
Proportional gain: Kp
Integral time constant: Ti
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1/Ti + s
H(s) = Kp
s
PI controller, parallel variant, anti-windup limiter and integrator time constant, reset and
hold
Functionality: This macro implements a variant of a PI Controller (parallel variant), with state
reset and output hold function.
Proportional gain: Kp
Integral time constant: Ti
Parameter Ti must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1
1 K T +s
H(s) = Kp + = Kp p i
sTi s
PI Controller, parallel variant, proportional gain Kp, integral time constant Ti, reset and
hold
Functionality: This macro implements a variant of a PI Controller (parallel variant), with state
reset and output hold function.
Proportional gain: Kp
Integral time constant: Ti
Parameter Ti must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1
1 K T +s
H(s) = Kp + = Kp p i
sTi s
PI controller, parallel variant, Kp and Ki, ext. signal tracking anti-windup, reset and hold
Functionality: This block implements a PI controller, parallel variant with external signal tracking
anti-windup, with state reset and output hold function.
The anti-windup implementation is based on the backfeed of the saturated output (external sig-
nal) and the unsaturated output (internal).
Note: Signal yo\_lim is the saturated output (not the limit itself) obtained by externally limiting
the signal yo.
The difference between these two is used as a second term fed to the integrator input.
Proportional gain: Kp
Integral gain: Ki
Time constant Tt determines how quickly the integrator state is frozen.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PI controller, parallel variant, with Kp and Ki, and anti-windup limits, reset and hold
Functionality: This block implements a Proportional-Integral (PI) block (parallel variant) with
anti-windup limits, with state reset and output hold function.
Proportional gain: Kp
Integral gain: Ki
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PI Controller, parallel variant, with anti-windup acc. to IEEE 421.5, reset and hold
Functionality: This macro implements a PI Controller with anti-windup acc. to IEEE 421.5 (par-
allel form), in which the integrator state variable is frozen if the output reaches the limits, with
state reset and output hold function.
Note: Kp = 0 is not supported, due to risk of integrator latching to limit.
vardef(Kp) = ’p.u.’;’Proportional gain’
vardef(Ki) = ’p.u.’;’Integral gain’
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PI Controller, parallel variant, with anti-windup acc. to IEEE 421.5, variable limit, reset
and hold
Functionality: This macro implements a PI Controller with anti-windup acc. to IEEE 421.5 (par-
allel form), in which the integrator state variable is frozen if the output reaches the limits, with
state reset and output hold function.
Limits ymin and ymax are variable and provided as input signals.
Note: Kp = 0 is not supported, due to risk of integrator latching to limit.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
vardef(Kp) = ’p.u.’;’Proportional gain’
vardef(Ki) = ’p.u.’;’Integral gain’
Function:
Ki
Ki Kp + s
H(s) = Kp + = Kp
s s
PI controller, parallel variant, proportional and integral gains, reset and hold
Functionality: This block implements a PI controller, parallel variant, with state reset and output
hold function.
Proportional gain: Kp
Integral gain: Ki
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PID controller,parallel variant, with anti-windup and limits, reset and hold
Functionality: This block implements a PID controller with anti-windup limit and output limits
based on the same parameters, with state reset and output hold function.
Proportional gain: Kp
Integral gain: Ki
Derivative gain: Kd
Derivative term time constant: Td
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the initial value
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
Ki p i d K +K T
2
sKd Ki Kd Kp Td +Kd + Kp Td +Kd s + s
H(s) = Kp + + = (Kp + ) 1 2
1 + sTd s Td Td s + s
PI controller, parallel variant, with anti-windup limiter and integrator time constant
Functionality: This macro implements a variant of a PI Controller (parallel variant) with the
possibility to apply performance parameters.
Controller proportional gain and integrator time constant are tuned using performance parame-
ters Kc, tau\_p and theta\_p.
Selectable tuning methods: Internal Model Control (IMC) and Integral of Time-weighted Abso-
lute Error (ITAE)
The parameters K\_p, T\_p, and theta\_p should be entered/obtained by fitting dynamic input
and output data to a first-order plus dead-time (FOPDT) model.
Tunable parameters:
- K\_p: Process gain - affects the magnitude of the response, regardless of the speed of re-
sponse. Kp=steady state change in measured process variable / steady state change in con-
troller output
- T\_p: Process time constant, in seconds - (the amount of time needed for the output to reach
(1-exp(-1)) or 63.2\% of the way to steady state conditions. The process time constant affects
the speed of response.
- theta\_p: Process dead time, in seconds - the time delay is expressed as a time shift in the
input variable
PI Controller parameters (calculated parameters based on the tunable parameters):
- Proportional gain: Kc
- Integral time constant: Ti, in seconds
Parameter Ti must be positive. Otherwise, a message is printed to the output window.
ControlTuning: selects one of the available tuning modes: IMC aggressive, IMC moderate, IMC
conservative, ITAE set point tracking, ITAE Disturbance rejection
1=IMC Aggressive tuning:
tau\_c = max(0.1*T\_p,0.8*theta\_p)
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
2=IMC Moderate tuning: tau\_c = max(1*T\_p,8.0*theta\_p
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
3=IMC Conservative tuning: tau\_c = max(10.0*T\_p,80.0*theta\_p
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
4=ITAE Set point tracking:
Kc = 0.586/Kp*(theta\_p/T\_p)\ˆ-0.916
Ti = T\_p/(1.03-0.165*(theta\_p/T\_p)
any other value=ITAE Disturbance rejection:
Kc = 0.859/Kp*(theta\_p/T\_p)\ˆ-0.977
Ti = T\_p/0.674*(theta\_p/T\_p)\ˆ0.680
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the value of
input signal x\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1
1 +s
H(s) = Kc + = Kc Kc Ti
sTi s
PI controller, parallel variant, with anti-windup limiter and integrator time constant
Functionality: This macro implements a variant of a PI Controller (parallel variant) with the
possibility to apply performance parameters.
Controller proportional gain and integrator time constant are tuned using performance parame-
ters Kc, tau\_p and theta\_p.
Selectable tuning methods: Internal Model Control (IMC) and Integral of Time-weighted Abso-
lute Error (ITAE)
The parameters K\_p, T\_rise, and theta\_p should be entered/obtained by fitting dynamic input
and output data to a first-order plus dead-time (FOPDT) model.
The parameter T\_p is computed based on the input parameter T\_rise - rise time of a first order
equivalated plant model
Tunable parameters:
- K\_p: Process gain - affects the magnitude of the response, regardless of the speed of re-
sponse. Kp=steady state change in measured process variable / steady state change in con-
troller output
- T\_rise: Process rise time, in seconds - the time needed for the output to reach 90% from 10%
of the way to steady state conditions assuming a first order system for the process.
- theta\_p: Process dead time, in seconds - the time delay is expressed as a time shift in the
input variable
PI Controller parameters (calculated parameters based on the tunable parameters):
- Proportional gain: Kc
- Integral time constant: Ti, in seconds
Parameter Ti must be positive. Otherwise, a message is printed to the output window.
Internal variable T\_p: Process time constant, in seconds - (the amount of time needed for the
output to reach (1-exp(-1)) or 63.2\% of the way to steady state conditions. The process time
constant affects the speed of response.
ControlTuning: selects one of the available tuning modes: IMC aggressive, IMC moderate, IMC
conservative, ITAE set point tracking, ITAE Disturbance rejection
1=IMC Aggressive tuning:
tau\_c = max(0.1*T\_p,0.8*theta\_p)
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
2=IMC Moderate tuning: tau\_c = max(1*T\_p,8.0*theta\_p
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
3=IMC Conservative tuning: tau\_c = max(10.0*T\_p,80.0*theta\_p
Kc = 1/K\_p*T\_p/(theta\_p+tau\_c)
Ti = T\_p
Function:
1
1 +s
H(s) = Kc + = Kc Kc Ti
sTi s
PI controller, series variant, gain Kp, time constant Ti, with anti-windup, reset and hold
Functionality: This block implements a PI controller, series variant with anti-windup, with state
reset and output hold function.
The anti-windup implementation is based on the backfeed of the saturated output (external sig-
nal) and the unsaturated output (internal).
The difference between these two is used as a second term fed to the integrator input.
Proportional gain: Kp
Integral time constant: Ti
Time constant Tt determines how quickly the integrator is reset.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the current
value of the input signal x\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1/Ti + s
H(s) = Kp
s
PI controller, series variant, gain Kp, time constant Ti, reset and hold
Functionality: This block implements a PI controller, series variant, with state reset and out-
put hold function.
Proportional gain: Kp
Integral time constant: Ti
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the current
value of the input signal x\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1/Ti + s
H(s) = Kp
s
PI controller, parallel variant, anti-windup limiter and integrator time constant, reset and
hold
Functionality: This macro implements a variant of a PI Controller (parallel variant), with state
reset and output hold function.
Proportional gain: Kp
Integral time constant: Ti
Parameter Ti must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the current
value of the input signal x\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1
1 K T +s
H(s) = Kp + = Kp p i
sTi s
PI Controller, parallel variant, proportional gain Kp, integral time constant Ti, reset and
hold
Functionality: This macro implements a variant of a PI Controller (parallel variant), with state
reset and output hold function.
Proportional gain: Kp
Integral time constant: Ti
Parameter Ti must be positive. Otherwise, a message is printed to the output window.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the current
value of the input signal x\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
1
1 K T +s
H(s) = Kp + = Kp p i
sTi s
PI controller, parallel variant, Kp and Ki, ext. signal tracking anti-windup, reset and hold
Functionality: This block implements a PI controller, parallel variant with external signal tracking
anti-windup, with state reset and output hold function.
The anti-windup implementation is based on the backfeed of the saturated output (external sig-
nal) and the unsaturated output (internal).
Note: Signal yo\_lim is the saturated output (not the limit itself) obtained by externally limiting
the signal yo.
The difference between these two is used as a second term fed to the integrator input.
Proportional gain: Kp
Integral gain: Ki
Time constant Tt determines how quickly the integrator state is frozen.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the current
value of the input signal x\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PI controller, parallel variant, with Kp and Ki, and anti-windup limits, reset and hold
Functionality: This block implements a Proportional-Integral (PI) block (parallel variant) with
anti-windup limits, with state reset and output hold function.
Proportional gain: Kp
Integral gain: Ki
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the current
value of the input signal x\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PI Controller, parallel variant, with anti-windup acc. to IEEE 421.5, reset and hold
Functionality: This macro implements a PI Controller with anti-windup acc. to IEEE 421.5 (par-
allel form), in which the integrator state variable is frozen if the output reaches the limits, with
state reset and output hold function.
Note: Kp = 0 is not supported, due to risk of integrator latching to limit.
vardef(Kp) = ’p.u.’;’Proportional gain’
vardef(Ki) = ’p.u.’;’Integral gain’
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the current
value of the input signal x\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PI Controller, parallel variant, with anti-windup acc. to IEEE 421.5, variable limit, reset
and hold
Functionality: This macro implements a PI Controller with anti-windup acc. to IEEE 421.5 (par-
allel form), in which the integrator state variable is frozen if the output reaches the limits, with
state reset and output hold function.
Limits ymin and ymax are variable and provided as input signals.
Note: Kp = 0 is not supported, due to risk of integrator latching to limit.
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the current
value of the input signal x\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
vardef(Kp) = ’p.u.’;’Proportional gain’
vardef(Ki) = ’p.u.’;’Integral gain’
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PI controller, parallel variant, proportional and integral gains, reset and hold
Functionality: This block implements a PI controller, parallel variant, with state reset and output
hold function.
Proportional gain: Kp
Integral gain: Ki
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the current
value of the input signal x\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PID controller,parallel variant, with anti-windup and limits, reset and hold
Functionality: This block implements a PID controller with anti-windup limit and output limits
based on the same parameters, with state reset and output hold function.
Proportional gain: Kp
Integral gain: Ki
Derivative gain: Kd
Derivative term time constant: Td
\_rst: If the signal "rst" crosses 0.5 via a rising edge, the state variable is reset to the current
value of the input signal x1\_rst
\_hold: If the signal "hold" is larger than 0.5, then the state variable and the output are held to
their previous value. If hold is active, the reset function is still operational.
This macro has a non-linear behaviour.
Function:
Ki p i d K +K T
2
sKd Ki Kd Kp Td +Kd + Kp Td +Kd s + s
H(s) = Kp + + = (Kp + ) 1 2
1 + sTd s Td Td s + s
Function:
1
1 + sT 1 T +s
H(s) = =
KsT K s
Functionality: PI controller with a symmetrical rate limiter and an upper/lower output limitation
with two parameters (y\_min and y\_max)
The rate limiter parameter "ylim" defines the derivative limit.
The upper/lower output limitation is defined using two parameters "y\_min" and "y\_max".
Parameters T and K must be positive. Otherwise, a message is printed to the output window.
This macro has a non-linear behaviour.
Function:
1
1 + sT 1 T +s
H(s) = =
KsT K s
19.3.3 (1+sTb)/sTa
PI controller (variant)
Function:
1
1 + sTb Tb Tb +s
H(s) = =
sTa Ta s
Function:
1
1 + sT p Tp Tp +s
H(s) = =
sTi Ti s
19.3.5 1+K/sT
PI controller with unity proportional gain, integral gain and time constant
Functionality: This macro implements a variant of a PI controller with unity proportional gain,
integral gain and time constant
Parameter T must be positive. Otherwise, a message is printed to the output window.
This macro has a linear behaviour.
Function:
K
1 T +s
H(s) = 1 + K =
sT s
19.3.6 Kp(1/Ti+s)/s
Proportional gain: Kp
Integral time constant: Ti
This macro has a linear behaviour.
Function:
1/Ti + s
H(s) = Kp
s
PI controller, series variant, gain Kp, time constant Ti, with anti-windup
Function:
1/Ti + s
H(s) = Kp
s
19.3.8 Kp+1/sTi
Function:
1
1 K T +s
H(s) = Kp + = Kp p i
sTi s
PI controller, parallel variant, with anti-windup limiter and integrator time constant
Function:
1
1 K T +s
H(s) = Kp + = Kp p i
sTi s
19.3.10 Kp+Ki/s
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PI controller, parallel variant, proportional and integral gains, ext. signal tracking anti-
windup
Functionality: This block implements a PI controller, parallel variant with external signal tracking
anti-windup.
The anti-windup implementation is based on the backfeed of the saturated output (external sig-
nal) and the unsaturated output (internal).
Note: Signal yo\_lim is the saturated output (not the limit itself) obtained by externally limiting
the signal yo.
The difference between these two is used as a second term fed to the integrator input.
Proportional gain: Kp
Integral gain: Ki
Time constant Tt determines how quickly the integrator state is frozen.
This macro has a non-linear behaviour.
Function:
Ki
Ki Kp + s
H(s) = Kp + = Kp
s s
Functionality: This block implements a Proportional-Integral (PI) block (parallel variant) with
anti-windup limits.
Proportional gain: Kp
Integral gain: Ki
This macro has a non-linear behaviour.
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
PI Controller, parallel variant, with anti-windup acc. to IEEE 421.5 (parallel form)
Functionality: This macro implements a PI Controller with anti-windup acc. to IEEE 421.5 (par-
allel form), in which the integrator state variable is frozen if the output reaches the limits.
Note: Kp = 0 is not supported, due to risk of integrator latching to limit.
vardef(Kp) = ’p.u.’;’Proportional gain’
vardef(Ki) = ’p.u.’;’Integral gain’
Function:
Ki
Ki Kp + s
H(s) = Kp + = Kp
s s
PI Controller, parallel variant, with anti-windup acc. to IEEE 421.5 (parallel form, variable
limit)
Functionality: This macro implements a PI Controller with anti-windup acc. to IEEE 421.5 (par-
allel form), in which the integrator state variable is frozen if the output reaches the limits.
Limits ymin and ymax are variable and provided as input signals.
Note: Kp = 0 is not supported, due to risk of integrator latching to limit.
vardef(Kp) = ’p.u.’;’Proportional gain’
vardef(Ki) = ’p.u.’;’Integral gain’
Function:
Ki
Ki K +s
H(s) = Kp + = Kp p
s s
Functionality: This block implements a PID controller with anti-windup limit and output limits
based on the same parameters.
Proportional gain: Kp
Integral gain: Ki
Derivative gain: Kd
Derivative term time constant: Td
This macro has a non-linear behaviour.
Function:
Ki K +K T
p i d 2
sKd Ki Kd Kp Td +Kd + Kp Td +Kd s + s
H(s) = Kp + + = (Kp + ) 1 2
1 + sTd s Td Td s + s
20 Signals
This section provides a complete listing of the existing DSL macros within the Signals folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
Functionality: Outputs a square wave signal with frequency cFreq [Hz]. The "on" pulse has
the half width of the period of the signal (Ton/Tp = 0.5). The clock frequency can be changed
via parameter "cFreq". The waveform is precise if the maximum simulation time step size is
below 1/(2*cFreq). The clock signal is generated only at time > 0. vardef(cFreq) = ’Hz’;’Clock
frequency’ vardef(clock) = ;’Clock signal’ vardef(output) = ;’Clock output signal’
Output signals: output Continuous states: x Parameters: cFreq Internal variables: clock
Functionality: Outputs a square wave signal with frequency "extfrq" [Hz]. The "on" pulse has
the half width of the period of the signal (Ton/Tp = 0.5). The clock frequency can be changed
throughout the simulation via input signal "extfrq". The waveform is precise if the maximum
simulation time step size is below 1/(2*extfrq). The clock signal is generated only at time >
0. vardef(extfrq) = ’Hz’;’Clock frequency’ vardef(clock) = ;’Clock signal’ vardef(output) = ;’Clock
output signal’
Output signals: output Input signals: extfrq Continuous states: x Internal variables: clock
Functionality: Outputs a square wave signal with frequency cFreq [Hz]. The "on" pulse has the
half width of the period of the signal (Ton/Tp = 0.5). The clock frequency can be changed via
parameter "cFreq". The waveform is precise if the maximum simulation time step size is below
1/(2*cFreq). The macro supresses a derivative of state variable being larger than zero at initial
condition, this results in a delay of 1.0 us of the clock signal at simulation start. vardef(cFreq) =
’Hz’;’Clock frequency’ vardef(clock) = ;’Clock signal’ vardef(output) = ;’Clock output signal’
Output signals: output Continuous states: x Parameters: cFreq Internal variables: t0,clock
Functionality: Outputs a square wave signal with frequency "extfrq" [Hz]. The "on" pulse has
the half width of the period of the signal (Ton/Tp = 0.5). The clock frequency can be changed
throughout the simulation via input signal "extfrq". The waveform is precise if the maximum
simulation time step size is below 1/(2*extfrq). The macro supresses a derivative of state vari-
able being larger than zero at initial condition, this results in a delay of 1.0 us of the clock
signal at simulation start. vardef(extfrq) = ’Hz’;’Clock frequency’ vardef(clock) = ;’Clock signal’
vardef(output) = ;’Clock output signal’
Output signals: output Input signals: extfrq Continuous states: x Internal variables: t0,clock
Functionality: Outputs a square wave signal with frequency cFreq [Hz]. The "on" pulse has the
half width of the period of the signal (Ton/Tp = 0.5). The clock frequency can be changed via
parameter "cFreq". The waveform is precise if the maximum simulation time step size is below
1/(2*cFreq). The macro contains a state variable with a derivative being larger than zero at initial
condition. vardef(cFreq) = ’Hz’;’Clock frequency’ vardef(clock) = ;’Clock signal’ vardef(output) =
;’Clock output signal’
Output signals: output Continuous states: x Parameters: cFreq Internal variables: clock
Functionality: Outputs a square wave signal with frequency "extfrq" [Hz]. The "on" pulse has
the half width of the period of the signal (Ton/Tp = 0.5). The clock frequency can be changed
throughout the simulation via input signal "extfrq". The waveform is precise if the maximum sim-
ulation time step size is below 1/(2*extfrq). The macro contains a state variable with a derivative
being larger than zero at initial condition. vardef(extfrq) = ’Hz’;’Clock frequency’ vardef(clock) =
;’Clock signal’ vardef(output) = ;’Clock output signal’
Output signals: output Input signals: extfrq Continuous states: x Internal variables: clock
20.7 Pulse
Functionality: Creates a pulse for T1 sec, if input is larger than K This macro has a linear
behaviour.
Functionality: Outputs a sawtooth signal with f=freq [Hz] The block does not generate inter-
ruption events. The waveform is precise only if the simulation time step size (throughout the
simulation) is less than 1/f.
Functionality: Outputs a sawtooth signal with f=freq [Hz] The block enforces interruption events
at sawtooth wave peaks. The waveform is precise if the minimum simulation time step size is
less than 1/f (maximum time step can be greater). Simulations using this block ("Sawtooth Wave
Generator _ip") are typically slower than when using the block "Sawtooth Wave Generator".
Outputs a sine wave with adjustable amplitude a, frequency f[Hz] and phase angle phi[deg]
Functionality: Outputs a sine wave with adjustable amplitude a, frequency f[Hz] and phase angle
phi[deg] Parameters: a - signal amplitude f - frequency in Hz phi - phase angle in degrees (with
reference to t=0s)
Outputs a sine wave with adjustable amplitude a, frequency f[Hz] and phase angle phi[deg]
at t>t0
Functionality: Outputs an adjutable sinusoidal signal Note: for simulation time t<t0, then output
is yo=0. Parameters: a - signal amplitude f - frequency in Hz phi - phase angle in degrees (with
reference to time t=t0) t0 - simulation time at which the source outputs the sine wave; before
this time output yo=0 This macro has a non-linear behaviour.
Functionality: Outputs a square wave signal with f=freq [Hz] The block does not generate in-
terruption events. The waveform is precise only if the simulation time step size (throughout the
simulation) is less than 1/f.
Functionality: Outputs a square wave signal with f=freq [Hz] The block enforces interruption
events at square wave flanks (rising/falling). The waveform is precise if the MAXIMUM simula-
tion time step size is below 1/(2f). Simulations using this block ("Square Wave Generator _ip")
are typically slower than when using the block "Square Wave Generator".
20.14 Time
Functionality: Outputs the simulation time This macro has a linear behaviour.
Output signals: t
Functionality: Outputs a triangle signal with f=freq [Hz]. The block does not generate interruption
events. The waveform is precise only if the simulation time step size (throughout the simulation)
is less than 1/f.
Functionality: Outputs a triangle signal with f=freq [Hz] Enforces interruption events at top and
bottom triangle wave peaks. The waveform is precise if the minimum simulation time step size
is below 1/f. Simulations using this block ("Triangle Wave Generator _ip") are typically slower
than when using the block "Triangle Wave Generator".
21 Switches / Selectors
This section provides a complete listing of the existing DSL macros within the Switches / Selec-
tors folder. Their functionality is explained along with a list of the input and output signals, state
variables and parameters.
Functionality: Enable an input to pass through depending on signal flag Note: Output can switch
during the simulation via parameter events on Enable Output: Enable >= 0.5 (at inc) then yo = yi
(throughout the simulation) Enable < 0.5 (at inc) then yo = yi_default (throughout the simulation)
Output signals: yo Input signals: yi Upper limitation input signals: Enable Parameters:
yi_default
Functionality: Enable an input to pass through depending on signal flag Note: Output can switch
during the simulation via parameter events on Enable Output: Enable >= 0.5 (at inc) then yo =
yi Enable < 0.5 (at inc) then hold output
Output signals: yo Input signals: yi Upper limitation input signals: Enable Internal vari-
ables: yi_register
Functionality: Enable inputs to pass through depending on signal flag Output: Enable >= 0.5 (at
inc) then yo = yi Enable < 0.5 (at inc) then yo = yi_default
Output signals: yo1,yo2 Input signals: yi1,yi2 Upper limitation input signals: Enable Pa-
rameters: yi1_default,yi2_default
Functionality: Enable inputs to pass through depending on signal flag or hold otherwise Note:
Output can switch during the simulation via parameter events on Enable Output: Enable >= 0.5
(at inc) then yo = yi Enable < 0.5 (at inc) then hold output
Output signals: yo1,yo2 Input signals: yi1,yi2 Upper limitation input signals: Enable Inter-
nal variables: yi1_register,yi2_register
Functionality: Enable inputs to pass through depending on signal flag Output: Enable >= 0.5 (at
inc) then yo = yi Enable < 0.5 (at inc) then yo = yi_default
Output signals: yo1,yo2,yo3 Input signals: yi1,yi2,yi3 Upper limitation input signals: En-
able Parameters: yi1_default,yi2_default,yi3_default
Functionality: Enable inputs to pass through depending on signal flag or hold otherwise Note:
Output can switch during the simulation via parameter events on Enable Output: Enable >= 0.5
(at inc) then yo = yi Enable < 0.5 (at inc) then hold output
Output signals: yo1,yo2,yo3 Input signals: yi1,yi2,yi3 Upper limitation input signals: En-
able Internal variables: yi1_register,yi2_register,yi3_register
Functionality: Enable inputs to pass through depending on signal flag Output: Enable >= 0.5 (at
inc) then yo = yi Enable < 0.5 (at inc) then yo = yi_default
Output signals: yo1,yo2,yo3,yo4 Input signals: yi1,yi2,yi3,yi4 Upper limitation input sig-
nals: Enable Parameters: yi1_default,yi2_default,yi3_default,yi4_default
Functionality: Enable inputs to pass through depending on signal flag or hold otherwise Note:
Output can switch during the simulation via parameter events on Enable Output: Enable >= 0.5
(at inc) then yo = yi Enable < 0.5 (at inc) then hold output
Output signals: yo1,yo2,yo3,yo4 Input signals: yi1,yi2,yi3,yi4 Upper limitation input sig-
nals: Enable Internal variables: yi1_register,yi2_register,yi3_register,yi4_register
Functionality: Enable inputs to pass through depending on signal flag Output: Enable >= 0.5 (at
inc) then yo = yi Enable < 0.5 (at inc) then yo = yi_default
Functionality: Enable inputs to pass through depending on signal flag or hold otherwise Note:
Output can switch during the simulation via parameter events on Enable Output: Enable >= 0.5
(at inc) then yo = yi Enable < 0.5 (at inc) then hold output
Functionality: Enable inputs to pass through depending on signal flag or hold otherwise Note:
Output can switch during the simulation via parameter events on Enable Output: Enable >= 0.5
(at inc) then yo = yi Enable < 0.5 (at inc) then hold output
Functionality: Enable inputs to pass through depending on signal flag or hold otherwise Note:
Output can switch during the simulation via parameter events on Enable Output: Enable >= 0.5
(at inc) then yo = yi Enable < 0.5 (at inc) then hold output
Functionality: Enable inputs to pass through depending on signal flag or hold otherwise Note:
Output can switch during the simulation via parameter events on Enable Output: Enable >= 0.5
(at inc) then yo = yi Enable < 0.5 (at inc) then hold output
Functionality: Enable an input to pass through depending on parameter flag Note: Output can
switch during the simulation via parameter events on Enable Output: Enable >= 0.5 (at inc) then
yo = yi (throughout the simulation) Enable < 0.5 (at inc) then yo = 0 (throughout the simulation)
Enable an input to pass through depending on parameter flag Note: Switch is fixed throughout
the simulation Output: Enable >= 0.5 (at inc) then yo = yi (throughout the simulation) Enable <
0.5 (at inc) then yo = 0 (throughout the simulation)
Outputs either the input or a parameter depending on parameter flag Note: Output can switch
during the simulation via parameter events on Enable Output: Enable >= 0.5 then yo = yi Enable
< 0.5 then yo = p
Outputs either the input or a parameter depending on parameter flag Note: Switch is fixed
throughout the simulation Output: Enable >= 0.5 (at inc) then yo = yi (throughout the simulation)
Enable < 0.5 (at inc) then yo = p (throughout the simulation)
Functionality: Parameter switch 1->2 by parameter Note: Switch is fixed throughout the simula-
tion Operation: If sw < 0.5 then parameter K is routed to output yo1 (and yo2 is 0) If sw >=0.5
then parameter K is routed to output yo2 (and yo1 is 0) This macro has a non-linear behaviour.
Functionality: Parameter switch 1->2 by signal sw Note: Output can switch during the simulation
(via changing signal sw) Operation: If sw < 0.5 then parameter K is routed to output yo1 (and
yo2 is 0) If sw >=0.5 then parameter K is routed to output yo2 (and yo1 is 0) This macro has a
non-linear behaviour.
Functionality: Parameter switch 2->1 by parameter Note: Switch is fixed throughout the simula-
tion Operation: If sw <=0 then K1 is routed to output If sw > 0 then K2 is routed to output This
macro has a non-linear behaviour.
Functionality: Signal switch 2->1 by signal Note: Output can switch during the simulation (via
changing signal sw) Operation: If sw <=0 then parameter K1 is routed to output If sw > 0 then
parameter K2 is routed to output This macro has a non-linear behaviour.
Outputs either the input or a parameter depending on an input signal flag "Enable" Note: Output
can switch during the simulation via parameter events on Enable Output: Enable >= 0.5 then yo
= yi Enable < 0.5 then yo = p
Outputs either the input or a parameter depending on an input signal flag "Enable" Note: Switch
is fixed throughout the simulation Output: Enable >= 0.5 (at inc) then yo = yi (throughout the
simulation) Enable < 0.5 (at inc) then yo = p (throughout the simulation)
Functionality: Signal switch 1->2 by parameter Note: Switch is fixed throughout the simulation
Operation: If sw < 0.5 then input is routed to output yo1 (and yo2 is 0) If sw >=0.5 then input is
routed to output yo2 (and yo1 is 0) This macro has a non-linear behaviour.
Functionality: Signal switch 1->2 by parameter (variant) Note: Switch is fixed throughout the
simulation Operation: If sw< 0.5 then outputs are zero If 0.5<=sw<=1.5 then input is routed to
yo1 (and yo2=0) If sw> 1.5 then input is routed to yo2 (and yo1=0) This macro has a non-linear
behaviour.
Functionality: Signal switch 1->2 by signal sw Note: Output can switch during the simulation (via
changing signal sw) Operation: If sw < 0.5 then input is routed to output yo1 (and yo2 is 0) If sw
>=0.5 then input is routed to output yo2 (and yo1 is 0) This macro has a non-linear behaviour.
Functionality: Signal switch 2->1 (NOT EQ K) by signal/parameter Note: Output can switch
during the simulation (via changing signal sw or parameter events on K) Operation: If sw <>
K then yi1 is routed to output. Otherwise yi2 is routed to output. This macro has a non-linear
behaviour.
Functionality: Signal switch 2->1 by parameter Note: Switch is fixed throughout the simulation
Operation: If sw <=0 then yi1 is routed to output If sw > 0 then yi2 is routed to output This macro
has a non-linear behaviour.
Functionality: Signal switch 2->1 by parameter Note: Switch is fixed throughout the simulation
Operation: If sw< 0.5 then output is zero If 0.5<=sw<=1.5 then yi1 is routed to output If sw> 1.5
then yi2 is routed to output This macro has a non-linear behaviour.
Functionality: Signal switch 2->1 by signal Note: Output can switch during the simulation (via
changing signal sw) Operation: If sw <=0 then yi1 is routed to output If sw > 0 then yi2 is routed
to output This macro has a non-linear behaviour.
Passes through a single input depending on the state of input signal "sw": Note: Output can
switch during the simulation (via changing signal sw) pass first input if sw< 0.5 e.g. sw = 0 pass
second input if sw>=0.5 e.g. sw = 1 This macro has a non-linear behaviour.
Functionality: Passes through a single input depending on the state of input signal "sw": Note:
Switch is fixed throughout the simulation pass first input if sw< 0.5 e.g. sw = 0 pass second
input if sw>=0.5 e.g. sw = 1 This macro has a linear behaviour.
Passes through a single input depending on the state of input signal "sw": Note: Output can
switch during the simulation (via changing signal sw) pass first input if sw<0.5 e.g. sw = 0 pass
second input if 0.5<=sw<1.5 e.g. sw = 1 pass third input if 1.5<=sw e.g. sw = 2 This macro has
a non-linear behaviour.
Passes through a single input depending on the state of input signal "sw": Note: Output can
switch during the simulation (via changing signal sw) pass first input if sw<0.5 e.g. sw = 0 pass
second input if 0.5<=sw<1.5 e.g. sw = 1 pass third input if 1.5<=sw<2.5 e.g. sw = 2 pass fourth
input if 2.5<=sw e.g. sw = 3 This macro has a non-linear behaviour.
Switch sw =C 2s->1s
Functionality: Switch sw=C 2s->1s Pass first input if condition is true, otherwise pass third
input. Note: Output can switch during the simulation (via changing signal sw) Operation: If sw
=C then yi1 is routed to output If sw =C then yi2 is routed to output This macro has a non-linear
behaviour.
Functionality: Switch sw>C 2s->1s Pass first input if condition is true, otherwise pass third
input. Note: Output can switch during the simulation (via changing signal sw) Operation: If sw
>C then yi1 is routed to output If sw <=C then yi2 is routed to output This macro has a non-linear
behaviour.
Functionality: Switch sw>=C 2s->1s Pass first input if condition is true, otherwise pass third
input. Note: Output can switch during the simulation (via changing signal sw) Operation: If sw
>=C then yi1 is routed to output If sw <C then yi2 is routed to output This macro has a non-linear
behaviour.
Switch sw =C 2s->1s
Functionality: Switch sw =C 2s->1s Pass first input if condition is true, otherwise pass third
input. Note: Output can switch during the simulation (via changing signal sw) Operation: If sw
=C then yi1 is routed to output If sw =C then yi2 is routed to output This macro has a non-linear
behaviour.
Functionality: Switch sw<C 2s->1s Pass first input if condition is true, otherwise pass third
input. Note: Output can switch during the simulation (via changing signal sw) Operation: If sw
<C then yi1 is routed to output If sw >=C then yi2 is routed to output This macro has a non-linear
behaviour.
Functionality: Switch sw<=C 2s->1s Pass first input if condition is true, otherwise pass third
input. Note: Output can switch during the simulation (via changing signal sw) Operation: If sw
<=C then yi1 is routed to output If sw > C then yi2 is routed to output This macro has a non-linear
behaviour.
22 Timers
This section provides a complete listing of the existing DSL macros within the Timers folder.
Their functionality is explained along with a list of the input and output signals, state variables
and parameters.
Functionality: Timer with reset. Starts always at zero. If trigerred via signal rst then it resets to
zero. Reset signal rst expected within range [0,1]. Triggering occurs when ’rst’ signal crosses
0.5 on the rising edge. This macro has a non-linear behaviour.
Timer with reset, hold reset, initial timer value and delayed start
Functionality: Timer with reset, hold reset, initial timer value and delayed start. Reset option:
This function includes a state/internal variable reset (based on an input signal) Forward initial
condition option: Output is initialised based on the input. Reset signal rst expected within
range [0,1] Inputs: rst - reset signal between 0 and 1 (including); when rst input greater/smaller
than 0.5 then reset timer t0 - value of time upon reset Outputs: yo - outputs the timer value;
initialises to t0, resets to t0 Parameters: flank - ’0/1’;’0:rising / 1:falling’ flank = 0 (rising flank)
then when rst>0.5 apply timer reset flank = 1 (falling flank) then when rst<0.5 apply timer reset
t_start_delay - Delay in seconds until timer starts: freezes the output for t_start_delay seconds
upon simulation start and has no influence afterwards. This macro has a non-linear behaviour.
23 Transformations
This section provides a complete listing of the existing DSL macros within the Transformations
folder. Their functionality is explained along with a list of the input and output signals, state
variables and parameters.
Clarke transform
Functionality: implements the Clarke transform for EMT type signals Transforms instantaneous
A/B/C components to alpha/beta/gamma components This macro has a linear behaviour.
Function: 2 1 1
− −
alpha 3 √3 √3 a
3
beta = 0 3 − 33 b
gamma 1 1 1 c
3 3 3
Functionality: implements the inverse Clarke transform for EMT type signals Transforms al-
pha/beta/gamma components to A/B/C instantaneous components This macro has a linear be-
haviour.
Function:
1 0 1
a √ alpha
− 21
b = 3
1 beta
√2
c − 12 − 23 1 gamma
Functionality: This macro implements the inverse Park transform (d/q) This macro has a linear
behaviour.
Function:
alpha cos(φ) −sin(φ) d
=
beta sin(φ) cos(φ) q
Functionality: This macro implements the inverse Park transform (d/q/0) This macro has a linear
behaviour.
Function:
alpha cos(φ) −sin(φ) 0 d
beta = sin(φ) cos(φ) 0 q
gamma 0 0 1 zero
Functionality: This macro implements the forward Park transform (alpha,beta)->(d,q) This macro
has a linear behaviour.
Function:
d cos(φ) sin(φ) alpha
=
q −sin(φ) cos(φ) beta
Function:
d cos(φ) sin(φ) 0 alpha
q = −sin(φ) cos(φ) 0 beta
zero 0 0 1 gamma
Functionality: Calculation of RMS value of a signal in EMT simulation Caution: The RMS value
needs one period to settle. The result is not precise in the first period. In RMS simulation this
block is a simple feed-through (yo = yi).
Functionality: Calculation of RMS value of a signal in p.u. in EMT simulation Input signal yi: p.u.
base is nominal peak value (1 p.u. = nominal peak value = sqrt(2) * nominal RMS value). Outut
signal yo: p.u. base is nominal RMS value (1 p.u. = nominal RMS value). Caution: The RMS
value needs one period to settle. The result is not precise in the first period. In RMS simulation
this block is a simple feed-through (yo = yi).
Calculation of line-ground and line-line voltage RMS magnitudes in RMS and EMT simu-
lation
In case of EMT simulation: inverse Clarke transform for instantaneous values with subsequent
per phase RMS value calculation. [ua] [1 0 1] [ualpha] with ualpha = u1r [ub] = [-1/2 +sqrt(3)/2
1] * [ubeta ] with ubeta = u1i [uc] [-1/2 -sqrt(3)/2 1] [u0 ]
and:
ua kua k
ub = kub k
uc kuc k
Functionality: This macro implements the power invariant forward Park transformatopm (a,b,c)-
>(d,q,0) It aligns phase a to d-axis. Supports EMT simulation only. This macro has a non-linear
behaviour.
Functionality: This macro implements the power invariant forward Park transformatopm (a,b,c)-
>(d,q,0) It aligns phase a to the q-axis. Supports EMT simulation only. This macro has a
non-linear behaviour.
Functionality: This macro implements the power variant forward Park transformatopm (a,b,c)-
>(d,q,0) It aligns phase a to the d-axis. Supports EMT simulation only. This macro has a
non-linear behaviour.
Functionality: This macro implements the power variant forward Park transformatopm (a,b,c)-
>(d,q,0) It aligns phase a to the q-axis. Supports EMT simulation only. This macro has a
non-linear behaviour.
Functionality: This macro implements the power invariant inverse Park transformatopm (d,q,0)-
>(a,b,c) It aligns phase a to d-axis. Supports EMT simulation only. This macro has a non-linear
behaviour.
Functionality: This macro implements the power invariant inverse Park transformatopm (d,q,0)-
>(a,b,c) It aligns phase a to q-axis. Supports EMT simulation only. This macro has a non-linear
behaviour.
Functionality: This macro implements the power variant inverse Park transformatopm (d,q,0)-
>(a,b,c) It aligns phase a to d-axis. Supports EMT simulation only. This macro has a non-linear
behaviour.
Functionality: This macro implements the power variant inverse Park transformatopm (d,q,0)-
>(a,b,c) It aligns phase a to q-axis. Supports EMT simulation only. This macro has a non-linear
behaviour.
24 Unit Conversion
This section provides a complete listing of the existing DSL macros within the Unit Conversion
folder. Their functionality is explained along with a list of the input and output signals, state
variables and parameters.
Functionality: This macro converts an input frequency/speed to p.u., with the base frequency
equal to parameter freqbase. This macro has a linear behaviour.
Functionality: This macro converts a torque quantity expressed in Nm into pu, with base param-
eters freqbase, Zp and Pel_base. This macro has a linear behaviour.
Functionality: This block converts the input quantity to per unit, with the base value defined by
the parameter ’base’. This macro has a linear behaviour.
Functionality: This block converts the input quantity to per unit, with the base value defined by
the input signal ’base’. This macro has a linear behaviour.
Functionality: This macro converts the input yi, expressed in degrees, into radians. This macro
has a linear behaviour.
Functionality: This macro converts the input signal fpu, in p.u., to Hz using the nominal fre-
quency "freqbase". This macro has a linear behaviour.
Functionality: This macro multiplies the input by the parameter "base" This macro has a linear
behaviour.
Functionality: This macro multiplies the input "yi" by the input signal "base" This macro has a
linear behaviour.
Functionality: This macro converts the input signal fpu, in p.u., to rpm using the nominal fre-
quency "freqbase" and "Zp". This macro has a linear behaviour.
Functionality: This macro converts the input, expressed in radians, into degrees. This macro
has a linear behaviour.
Functionality: This macro converts the input, expressed in rad/s, into rpm. This macro has a
linear behaviour.
Functionality: This macro converts the input signal "n", expressed in rpm, into p.u. using the
parameters "freqbase" and "Zp". This macro has a linear behaviour.
Functionality: This macro converts the input signal "n", expressed in rpm, into rad/s. This macro
has a linear behaviour.