GENERIC D
GENERIC D
Issued: 11/1997
Version: D/12.2.2002
Data subject to change without notice
Contents
1. Arithmetic.................................................................................................. 4
2. Bistable ................................................................................................... 11
2.1 Reset dominant bistable function block (RS) ..................................... 11
2.2 Reset dominant bistable function block (RS_D) with data input......... 12
2.3 Set dominant bistable function block (SR) ......................................... 13
3. Bit-Shift ................................................................................................... 14
3.1 Rotate to left (ROL) ........................................................................... 14
3.2 Rotate to right (ROR) ........................................................................ 15
3.3 Bit-shift to left (SHL) .......................................................................... 16
3.4 Bit-shift to right (SHR) ....................................................................... 17
4. Bitwise Operation ................................................................................... 18
5. Comparison ............................................................................................ 25
6. Counter ....................................................................................................32
6.1 Down-counter (CTD)..........................................................................32
6.2 Up-down counter (CTUD) ..................................................................34
6.3 Up-counter (CTU) ..............................................................................37
7. Edge Detection........................................................................................39
8. Numeric ...................................................................................................41
8.1 Absolute value (ABS).........................................................................41
8.2 Principal arc cosine (ACOS) ..............................................................42
8.3 Principal arc sine (ASIN)....................................................................43
8.4 Principal arc tangent (ATAN) .............................................................44
8.5 Cosine in radians (COS) ....................................................................45
8.6 Natural exponential (EXP) .................................................................46
8.7 Natural logarithm (LN)........................................................................47
8.8 Logarithm base 10 (LOG) ..................................................................48
8.9 Sine in radians (SIN)..........................................................................49
8.10 Square root (SQRT)...........................................................................50
8.11 Tangent in radians (TAN)...................................................................51
9. Selection..................................................................................................52
9.1 Limiter (LIMIT) ...................................................................................52
9.2 Extensible maximum (MAX)...............................................................53
9.3 Extensible minimum (MIN).................................................................54
9.4 Multiplexer (MUX) ..............................................................................55
9.5 Binary selection (SEL) .......................................................................56
2
Substation Automation Generic Base Elements
12.1 TRUNC_REAL_TO_**....................................................................... 80
3
Generic Base Elements Substation Automation
1. Arithmetic
)LJXUH )XQFWLRQEORFNV\PERO
For example:
ADD(2,3) = 5
ADD(2,-3) = -1
4
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
For example:
DIV(7,3) = 2
5
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
OUT := IN1IN2
For example:
EXPT(2, 3) = 8
6
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
Example:
MOD(7,3) = 1
7
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
OUT := IN
8
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
For example:
MUL(2,3) = 6
9
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
For example:
SUB(3,2) = 1
10
Substation Automation Generic Base Elements
2. Bistable
)LJXUH )XQFWLRQEORFNV\PERO
The output Q1 is reset if the RESET1 input is set, regardless of the state of the SET
input. If the SET input is set and RESET1 is low, the output pin Q1 is set. If both the
inputs are FALSE, the output Q1 will preserve its previous value.
11
Generic Base Elements Substation Automation
2.2 Reset dominant bistable function block (RS_D) with data input
)LJXUH )XQFWLRQEORFNV\PERO
If only SET and RESET are used, RS_D operates as an ordinary RS element. When
the RESET input is reset and LOAD goes to 1, the value at D is stored at the output
Q. When the RESET input is set, the output Q is unconditionally reset, i.e. the RESET
input overrides the other inputs.
12
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
The output Q1 is set if the SET1 input is set, regardless of the state of the RESET
input. If the RESET input is set and SET1 is low, the output pin Q1 is cleared. If both
the inputs are FALSE, the output will preserve its previous value.
13
Generic Base Elements Substation Automation
3. Bit-Shift
)LJXUH )XQFWLRQEORFNV\PERO
14
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
15
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
16
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
17
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
For example:
AND(TRUE,FALSE) = FALSE
AND(0x0F,0x08) = 0x08
18
Substation Automation Generic Base Elements
4.2.1 Application
BITGET is used to read a selected bit of an integer value and is thus useful in reading
the status information of a relay.
)LJXUH )XQFWLRQEORFNV\PERO
If the BITNR is not within the range from 0 to 15, the output Q is FALSE. Otherwise
the bit value of IN, specified by BITNR, is loaded to the output Q.
19
Generic Base Elements Substation Automation
4.3.1 Application
BITSET is used to set a selected bit of an integer value and is thus useful in writing
the status information of a relay.
)LJXUH )XQFWLRQEORFNV\PERO
When the input EN is FALSEthe data input IN is loaded unchanged to the output Q.
When the input EN is TRUE, the value of the bit number BITNR of the input data IN
is replaced by the value of the input BIT and the result is loaded to the output Q. If the
BITNR input is not within the range from 0 to 15, the output Q remains unchanged.
20
Substation Automation Generic Base Elements
For example:
21
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
OUT := NOT IN
For example:
NOT(TRUE) = FALSE
NOT(FALSE) = TRUE
NOT(0x80) = 0x7F
22
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
For example:
23
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
For example:
XOR(FALSE,FALSE) = FALSE
XOR(TRUE,TRUE) = FALSE
XOR(FALSE,TRUE) = TRUE
XOR(TRUE, FALSE) = TRUE
XOR(0x08, 0x0F) = 0x07
24
Substation Automation Generic Base Elements
5. Comparison
5.1.1 Application
)LJXUH )XQFWLRQEORFNV\PERO
25
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
OUT := (IN1 = IN2) & (IN2 = IN3) & ... & (INn-1 = INn)
For example:
EQ(1,0) = FALSE
26
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
OUT := (IN1 ≥ IN2) & (IN2 ≥ IN3) & ... & (INn-1 ≥ INn)
For example:
GE(10,9) = TRUE
GE(10,10) = TRUE
GE(9, 10) = FALSE
27
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
OUT := (IN1 > IN2) & (IN2 > IN3) & ... & (INn-1 > INn)
For example:
GT(10,9) = TRUE
GT(10,10) = FALSE
GT(9, 10) = FALSE
28
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
OUT := (IN1 ≤ IN2) & ( IN2 ≤ IN3) & ... & (INn-1 ≤ INn)
For example:
LE(10,9) = FALSE
LE(10,10) = TRUE
LE(9, 10) = TRUE
29
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
OUT := (IN1 < IN2) & (IN2 < IN3) & ... & (INn-1 < INn)
For example:
LT(10,9) = FALSE
LT(10,10) = FALSE
LT(9, 10) = TRUE
30
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
For example:
NE(10,9) = TRUE
NE(10,10) = FALSE
NE(9, 10) = TRUE
31
Generic Base Elements Substation Automation
6. Counter
)LJXUH )XQFWLRQEORFNV\PERO
6.1.3.1 Counting
When the LOAD input is FALSE, each rising edge at the CD input decrements the
counter value CV by one.
6.1.3.2 Presetting
The LOAD input is used to load the new preset value of the counter from PV. The
counter is held as long as the LOAD input is TRUE.
32
Substation Automation Generic Base Elements
6.1.3.3 Supervision
The status output Q specifies the relation of the counter value to zero.Q is set when
CV ≤ 0.
6.1.3.4 Limits
When the counter reaches its lowest or highest value for the data type INT, all
counting ceases.
33
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
Note! The CTUD function complies with the corrected version of the IEC 61131-3
standard (see the correction below).
34
Substation Automation Generic Base Elements
6.2.3.1 Up-count
Each rising edge at the CU input increments the counter value by one. If there is a
rising edge at both CU and CD, nothing is done.
6.2.3.2 Down-count
Each rising edge at the CD input decrements the counter value by one. If there is a
rising edge at both CU and CD, nothing is done.
6.2.3.3 Clearing
The RESET input clears the counter and prevents all further counting or loading.
When set, RESET overrides the other inputs of the counter and prevents them from
affecting the state of the counter.
6.2.3.4 Supervision
The status outputs specify the relation of the counter value to zero and to a loaded
preset value. QD is set when CV ≤ 0 and QU is set when CV ≥ PV.
35
Generic Base Elements Substation Automation
6.2.3.5 Limits
When the counter reaches its lowest or highest value for the data type INT, all
counting ceases.
36
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
6.3.3.1 Counting
When the RESET input is FALSE, each rising edge at the CU input increments the
counter value CV by one.
6.3.3.2 Clearing
The input RESET clears the counter (CV := 0) and prevents all further counting.
37
Generic Base Elements Substation Automation
6.3.3.3 Supervision
The status output Q specifies the relation of the counter value to a supervision high
limit value. The Q is set, when CV ≥ PV.
6.3.3.4 Limits
When the counter reaches its lowest or highest value for the data type INT, all
counting ceases.
38
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
The Q output of the F_TRIG element stands at the TRUE value from one execution of
the element to the next, following the TRUE to FALSE transition of the “CLK” input,
and returns to FALSE at the next execution.
39
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
The Q output of the R_TRIG element stands at the TRUE value from one execution of
the element to the next, following the FALSE to TRUE transition of the “CLK” input,
and returns to FALSE at the next execution.
40
Substation Automation Generic Base Elements
8. Numeric
)LJXUH )XQFWLRQEORFNV\PERO
For example:
ABS(10) = 10
ABS(-10) = 10
ABS(-10.11) =10.11
41
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
The ACOS function returns the arc cosine of a floating-point argument IN. IN must be
in the range [-1, 1]. The return value is an angle in the range [0, π ] radians.
42
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
The ASIN function returns the arc sine of a floating-point argument IN. IN must be in
the range [-1, 1]. The return value is an angle in the range
π π
[− , ]
2 2 radians.
43
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
The ATAN function returns the arc tangent of a floating-point argument IN. The
return value is an angle in the range
π π
[− , ]
2 2 radians.
44
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
The COS function returns the cosine of a floating-point number IN. IN is an angle
expressed in radians. An argument with large magnitude may produce a result with
little or no significance.
45
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
OUT := eIN
46
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
OUT := ln IN
47
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
OUT := log IN
48
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
The SIN function returns the sine of a floating-point number IN. IN is an angle
expressed in radians. An argument with large magnitude may produce a result with
little or no significance.
49
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
287:= ,1
An argument with large magnitude may produce a result with little or no significance.
Negative input values yield to a zero result.
50
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
The TAN function returns the tangent of a floating-point number IN. IN is an angle
expressed in radians. An argument with large magnitude may produce a result with
little or no significance.
51
Generic Base Elements Substation Automation
9. Selection
)LJXUH )XQFWLRQEORFNV\PERO
OUT := MIN(MAX(IN,MN),MX)
52
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
53
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
Returns the minimun of input values, OUT := MIN(IN1, IN2, ..., INn)
54
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
Select one of the “N” inputs depending on the input K. Note that index zero selects
the first input IN1. If index K is greater than N-1, funtion returns zero.
For example:
55
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
56
Substation Automation Generic Base Elements
10. Timer
)LJXUH )XQFWLRQEORFNV\PERO
IN
t0 t1 t2 t3 t4 t5
Q
t0 t1+PT t2 t5+PT
(PT)
ET
t1 t3 t5 0
)LJXUH 2IIGHOD\WLPLQJ
57
Generic Base Elements Substation Automation
)LJXUH )XQFWLRQEORFNV\PERO
IN
t0 t1 t2 t3 t4 t5
Q
t0+PT t1 t4+PT t5
(PT)
ET
t0 t1 t2 t3 t4 t5
)LJXUH 2QGHOD\WLPLQJ
58
Substation Automation Generic Base Elements
)LJXUH )XQFWLRQEORFNV\PERO
IN
t0 t1 t2 t3 t4 t5 t6 t7
Q
t0 t0+PT t2 t2+PT t6 t6+PT
(PT)
ET
t0 t1 t2 t6 t7 0
)LJXUH 3XOVHWLPLQJ
59
Generic Base Elements Substation Automation
The time duration for TOF, TON and TP is configured in the Relay Configuration
Tool. The time duration can be defined in the range 0...49.7 days, in steps of one
millisecond. The desired time duration can be given in milliseconds (ms), seconds (s),
minutes (m) , hours (h) or days (d).
"TIME#1000ms"
"time#1s"
"T#1000ms"
"t#1s"
"T#1d 2h 3m 4s 5ms"
"T#1d_2h_3m_4s_5ms"
"T#25h_15m"
is equivalent to
"T#1d_1h_15m"
)LJXUH ([DPSOHRISXOVHZLGWKFRQILJXUDWLRQ
60
Substation Automation Generic Base Elements
11.1.1 Application
)LJXUH )XQFWLRQEORFNV\PERO
61
Generic Base Elements Substation Automation
BOOL2INT returns the integer output Q, the value of which is equal to the 16 input
bits.
62
Substation Automation Generic Base Elements
BYTE
DINT
DWORD
INT
REAL
SINT
UDINT
UINT
USINT
WORD
The BOOL type of data is converted e.g. to the BYTE type.
63
Generic Base Elements Substation Automation
DWORD
WORD
The BYTE type of data is converted e.g. to the DWORD type.
64
Substation Automation Generic Base Elements
65
Generic Base Elements Substation Automation
INT
REAL
SINT
When the DINT type of data is converted e.g. to the INT type:
Data type DINT: -2 147 483 648 ... 2 147 483 647
Data type INT: -32 768 ... 32 767
For example:
DINT_TO_INT(10) = 10
DINT_TO_INT(-10) = -10
DINT_TO_INT(32768) = -32 768
DINT_TO_INT(-32769) = 32 767
When the DINT type of data is converted to the SINT type:
Data type DINT: -2 147 483 648 ... 2 147 483 647
Data type SINT: -128 ... 127
For example:
DINT_TO_SINT(10) = 10
DINT_TO_SINT(-10) = -10
DINT_TO_SINT(128) = -128
DINT_TO_SINT(-129) = 127
66
Substation Automation Generic Base Elements
BYTE
WORD
The DWORD type of data is converted to the BYTE or WORD type.
For example:
DWORD_TO_BYTE(0xFFFFFFFF) = 0xFF
DWORD_TO_WORD(0xFFFFFFFF) = 0xFFFF
67
Generic Base Elements Substation Automation
11.7.1 Application
)LJXUH )XQFWLRQEORFNV\PERO
68
Substation Automation Generic Base Elements
The input value IN is separated to a bit format and the status of each of the 16 bits is
returned as an output.
For example: the output B0 is equal to the status of the first bit of input IN.
69
Generic Base Elements Substation Automation
DINT
REAL
The INT type of data is converted e.g. to the DINT type.
70
Substation Automation Generic Base Elements
DINT
INT
SINT
UDINT
UINT
USINT
The REAL type of data is converted e.g. to the DINT type.
REAL_TO_DINT(2147483647.1) = 2147483647
REAL_TO_DINT(-2147483648.1) = -2147483648
REAL_TO_DINT(10.4) = 10
REAL_TO_DINT(10.5) = 11
REAL_TO_DINT(-10.4) = -10
REAL_TO_DINT(-10.5) = -11
71
Generic Base Elements Substation Automation
REAL_TO_INT(32767.1) = 32767
REAL_TO_INT(-32768.1) = -32768
REAL_TO_INT(10.4) = 10
REAL_TO_INT(10.5) = 11
REAL_TO_INT(-10.4) = -10
REAL_TO_INT(-10.5) = -11
SINT values are -128...127, for example:
REAL_TO_SINT(127.1) = 127
REAL_TO_SINT(-128.1) = -128
REAL_TO_SINT(10.4) = 10
REAL_TO_SINT(10.5) = 11
REAL_TO_SINT(-10.4) = -10
REAL_TO_SINT(-10.5) = -11
UDINT values are 0...4294967295, for example:
REAL_TO_UDINT(4294967295.1) = 4294967295
REAL_TO_UDINT(-0.1) = 0
REAL_TO_UDINT(10.4) = 10
REAL_TO_UDINT(10.5) = 11
REAL_TO_UDINT(-10.4) = 0
REAL_TO_UDINT(-10.5) = 0
UINT values are 0...65535, for example:
REAL_TO_UINT(65535.1) = 65535
REAL_TO_UINT(-0.1) = 0
REAL_TO_UINT(10.4) = 10
REAL_TO_UINT(10.5) = 11
REAL_TO_UINT(-10.4) = 0
REAL_TO_UINT(-10.5) = 0
USINT values are 0 ... 255, for example:
REAL_TO_USINT(255.1) = 255
REAL_TO_USINT(-0.1) = 0
REAL_TO_USINT(10.4) = 10
REAL_TO_USINT(10.5) = 11
REAL_TO_USINT(-10.4) = 0
REAL_TO_USINT(-10.5) = 0
72
Substation Automation Generic Base Elements
DINT
INT
REAL
The SINT type of data is converted e.g. to the DINT type.
73
Generic Base Elements Substation Automation
REAL
TOD
UDINT
The TIME type of data is converted e.g. to the REAL type.
74
Substation Automation Generic Base Elements
REAL
TIME
UDINT
The TOD type of data is converted e.g. to the TIME type.
75
Generic Base Elements Substation Automation
REAL
UINT
USINT
The UDINT type of data is converted e.g. to the REAL type.
76
Substation Automation Generic Base Elements
BOOL
REAL
UDINT
USINT
The UINT type of data is converted e.g. to the BOOL type.
77
Generic Base Elements Substation Automation
REAL
UDINT
UINT
The USINT type of data is converted to the REAL type.
78
Substation Automation Generic Base Elements
BYTE
DWORD
The WORD type of data is converted e.g. to the BYTE type.
For example:
WORD_TO_BYTE(0xFFFF) = 0xFF
79
Generic Base Elements Substation Automation
12.1 TRUNC_REAL_TO_**
DINT
INT
SINT
UDINT
UINT
USINT
DINT values are in the range -2147483648...2147483647, for example:
TRUNC_REAL_TO_DINT(2147483647.1) = 2147483647
TRUNC_REAL_TO_DINT(-2147483648.1) = -2147483648
TRUNC_REAL_TO_DINT(10.4) = 10
TRUNC_REAL_TO_DINT(10.5) = 10
TRUNC_REAL_TO_DINT(-10.4) = -10
80
Substation Automation Generic Base Elements
TRUNC_REAL_TO_INT(32767.1) = 32767
TRUNC_REAL_TO_INT(-32768.1) = -32768
TRUNC_REAL_TO_INT(10.4) = 10
TRUNC_REAL_TO_INT(10.5) = 10
TRUNC_REAL_TO_INT(-10.4) = -10
TRUNC_REAL_TO_INT(-10.5) = -10
SINT values are in the range -128...127, for example:
TRUNC_REAL_TO_SINT(127.1) = 127
TRUNC_REAL_TO_SINT(-128.1) = -128
TRUNC_REAL_TO_SINT(10.4) = 10
TRUNC_REAL_TO_SINT(10.5) = 10
TRUNC_REAL_TO_SINT(-10.4) = -10
TRUNC_REAL_TO_SINT(-10.5) = -10
UDINT values are in the range 0...4294967295, for example:
TRUNC_REAL_TO_UDINT(4294967295.1) = 4294967295
TRUNC_REAL_TO_UDINT(-0.1) = 0
TRUNC_REAL_TO_UDINT(10.4) = 10
TRUNC_REAL_TO_UDINT(10.5) = 10
TRUNC_REAL_TO_UDINT(-10.4) = 0
TRUNC_REAL_TO_UDINT(-10.5) = 0
UINT values are in the range 0...65535, for example:
TRUNC_REAL_TO_UINT(65535.1) = 65535
TRUNC_REAL_TO_UINT(-0.1) = 0
TRUNC_REAL_TO_UINT(10.4) = 10
TRUNC_REAL_TO_UINT(10.5) = 10
TRUNC_REAL_TO_UINT(-10.4) = 0
TRUNC_REAL_TO_UINT(-10.5) = 0
USINT values are in the range 0...255, for example:
TRUNC_REAL_TO_USINT(255.1) = 255
TRUNC_REAL_TO_USINT(-0.1) = 0
TRUNC_REAL_TO_USINT(10.4) = 10
TRUNC_REAL_TO_USINT(10.5) = 10
TRUNC_REAL_TO_USINT(-10.4) = 0
TRUNC_REAL_TO_USINT(-10.5) = 0
81