S7jbib B en-US
S7jbib B en-US
S7jbib B en-US
Control blocks 17
System function blocks
(SFBs) 18
Blocks for AS-wide
connections 19
"@SYSTEM" block family 20
Appendix 21
05/2017
A5E41367261-AA
Legal information
Warning notice system
This manual contains notices you have to observe in order to ensure your personal safety, as well as to prevent
damage to property. The notices referring to your personal safety are highlighted in the manual by a safety alert
symbol, notices referring only to property damage have no safety alert symbol. These notices shown below are
graded according to the degree of danger.
DANGER
indicates that death or severe personal injury will result if proper precautions are not taken.
WARNING
indicates that death or severe personal injury may result if proper precautions are not taken.
CAUTION
indicates that minor personal injury can result if proper precautions are not taken.
NOTICE
indicates that property damage can result if proper precautions are not taken.
If more than one degree of danger is present, the warning notice representing the highest degree of danger will be
used. A notice warning of injury to persons with a safety alert symbol may also include a warning relating to property
damage.
Qualified Personnel
The product/system described in this documentation may be operated only by personnel qualified for the specific
task in accordance with the relevant documentation, in particular its warning notices and safety instructions. Qualified
personnel are those who, based on their training and experience, are capable of identifying risks and avoiding
potential hazards when working with these products/systems.
Proper use of Siemens products
Note the following:
WARNING
Siemens products may only be used for the applications described in the catalog and in the relevant technical
documentation. If products and components from other manufacturers are used, these must be recommended or
approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and
maintenance are required to ensure that the products operate safely and without any problems. The permissible
ambient conditions must be complied with. The information in the relevant documentation must be observed.
Trademarks
All names identified by ® are registered trademarks of Siemens AG. The remaining trademarks in this publication
may be trademarks whose use by third parties for their own purposes could violate the rights of the owner.
Disclaimer of Liability
We have reviewed the contents of this publication to ensure consistency with the hardware and software described.
Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the information in
this publication is reviewed regularly and any necessary corrections are included in subsequent editions.
1 Security information......................................................................................................................................9
2 Block parameters EN, ENO, SAMPLE_T...................................................................................................11
3 Startup on S7-300 CPUs............................................................................................................................13
4 CFC blocks.................................................................................................................................................15
5 Logic blocks of the data type BOOL...........................................................................................................17
5.1 BIT_LGC................................................................................................................................17
5.2 AND: AND operation..............................................................................................................18
5.3 OR: OR operation..................................................................................................................19
5.4 XOR: Exclusive-OR operation................................................................................................20
5.5 NAND: NAND operation.........................................................................................................21
5.6 NOR: NOR operation.............................................................................................................22
5.7 NOT: NOT operation..............................................................................................................23
6 Logic blocks of the data type WORD and DWORD....................................................................................25
6.1 WRD_LGC.............................................................................................................................25
6.2 WAND_W: Word AND operation............................................................................................26
6.3 WOR_W: Word OR operation................................................................................................27
6.4 WXOR_W: Word exclusive-OR operation..............................................................................28
6.5 WNAND_W: Word AND operation.........................................................................................29
6.6 WNOR_W: Word NOR operation...........................................................................................30
6.7 WNOT_W: Word NOT operation............................................................................................31
6.8 WAND_DW: Double word AND operation..............................................................................32
6.9 WOR_DW: Double word OR operation..................................................................................33
6.10 WXOR_DW: Double word exclusive-OR operation................................................................34
6.11 WNAND_DW: Double word NAND operation........................................................................35
6.12 WNOR_DW: Double word NOR operation.............................................................................36
6.13 WNOT_DW: Double word NOT operation..............................................................................37
7 Blocks for comparing two input values of the same type............................................................................39
7.1 COMPARE.............................................................................................................................39
7.2 CMP_I: Comparator for INT values........................................................................................40
7.3 CMP_DI: Comparator for DINT values...................................................................................41
7.4 CMP_R: Comparator for REAL values...................................................................................42
ENO
ENO: ENO is the same as BR (Binary Result - refer to the STEP 7 documentation).
ENO = 1 shows a valid result as appropriate to the function. When the operating system and/
or the error-handling routine detects an error in the block program, ENO will be set to 0 to
indicate an invalid result. You can use this information in order to switch to other values (e.g.,
safety values) and to output messages to the OS as required.
If EN = FALSE, then ENO = FALSE.
SAMPLE_T
All blocks with the input parameter SAMPLE_T must be processed in temporally equidistant
tasks, e.g. OB 35: Watchdog interrupt 100 ms. If they are implemented in acyclic tasks, e.g.,
process alarms, these blocks will return incorrect results
Family Purpose
BIT_LGC (Page 17) Logic blocks of the data type BOOL
WRD_LGC Logic blocks of the data type WORD and DWORD
(Page 25)
COMPARE Blocks for comparing two input values of the same type
(Page 39)
CONVERT Blocks for converting data types
(Page 45)
MATH_FP (Page 71) Arithmetic blocks of the data type REAL
MATH_INT Arithmetic blocks of the data type INT and DINT
(Page 97)
FLIPFLOP Flip-flop blocks
(Page 123)
SHIFT (Page 127) Shift blocks
MULTIPLX Multiplexer blocks
(Page 137)
COUNTER Count blocks
(Page 145)
PULSE (Page 151) Blocks for generating or processing pulses
TIME (Page 159) Blocks for acquiring or processing time intervals and timebases
CONTROL Closed-loop-control blocks
(Page 163)
EVENT: Start of the Blocks for system functions
priority class
(Page 185)
Blocks for AS-wide Blocks for AS-wide connections
connections
(Page 195)
You will find information on the ALARM_8P, BSEND and BRCV blocks in the online help for
PCS 7 Standard Library.
Note
The initial value at the output of the CFC blocks is "1", regardless of the values at the inputs.
This means the following logic is supplied with "1" as long as the block is not processed.
Function
This block generates logic AND operations at inputs. The output is 1 if all inputs are 1.
Otherwise, the output is 0. The number of "IN" inputs at the block can be modified.
I/Os
Function
This block generates logic OR operations at inputs. The output is 1 if at least one input is 1. If
all inputs are 0, the output is 0. The number of "IN" inputs at the block can be modified.
I/Os
Function
This block generates logic exclusive-OR operations at inputs. The output is 0 if all inputs have
the same value. Otherwise, the output is 1. The number of "IN" inputs at the block can be
modified.
I/Os
Function
This block generates and inverts logic AND operations at inputs. The output is 0 if all inputs
are 1. The number of "IN" inputs at the block can be modified.
I/Os
Function
This block generates and inverts OR logic operations at inputs. The output is 1 if all inputs are
0. The number of "IN" inputs at the block can be modified.
I/Os
Function
This block inverts the input.
Truth table
IN OUT
0 1
1 0
I/Os
Function
This block generates word logic AND operations at inputs. All input bits of the same significance
are logically linked by AND; the result is written to the corresponding output bit. The number
of "IN" inputs at the block can be modified.
I/Os
Function
This block generates word logic OR operations at inputs. All input bits of the same significance
are logically linked by OR and the result is written to the corresponding output bit. The number
of "IN" inputs at the block can be modified.
I/Os
Function
This block generates word logic exclusive-OR operations at inputs. All input bits of the same
significance are logically linked by exclusive-OR and the result is written to the corresponding
output bit. The bit is 0 if all input bits of the same significance have the same value. Otherwise
the bit is 1. The number of "IN" inputs at the block can be modified.
I/Os
Function
This block generates word logic NOT AND operations at inputs. All input bits of the same
significance are logically linked by AND, inverted and the result is written to the corresponding
output bit. The number of "IN" inputs at the block can be modified.
I/Os
Function
This block generates word logic NOT OR operations at inputs. All input bits of the same
significance are logically linked by OR. The result is then inverted and written to the
corresponding output bit. The number of "IN" inputs at the block can be modified.
I/Os
Function
This block inverts the input word. Each bit of the input is inverted and written to the output bit
of the corresponding significance.
Example
I/Os
Function
This block generates DWORD logic AND operations at inputs. All input bits of the same
significance are logically linked by AND; the result is written to the corresponding output bit.
The number of "IN" inputs at the block can be modified.
I/Os
Function
This block generates DWORD logic OR operations at inputs. All input bits of the same
significance are logically linked by OR and the result is written to the corresponding output bit.
The number of "IN" inputs at the block can be modified.
I/Os
Function
This block generates DWORD logic exclusive-OR operations at inputs. All input bits of the
same significance are logically linked by exclusive-OR and the result is written to the
corresponding output bit. The bit is 0 if all input bits of the same significance have the same
value. Otherwise the bit is 1. The number of "IN" inputs at the block can be modified.
I/Os
Function
This block generates DWORD logic NOT AND operations at inputs. All input bits of the same
significance are logically linked by AND, inverted and the result is written to the corresponding
output bit. The number of "IN" inputs at the block can be modified.
I/Os
Function
This block generates DWORD logic NOT OR operations at inputs. All input bits of the same
significance are logically linked by OR. The result is then inverted and written to the
corresponding output bit. The number of "IN" inputs at the block can be modified.
I/Os
Function
This block inverts the input word. Each bit of the input is inverted and written to the output bit
of the corresponding significance.
I/Os
Function
This block compares two input variables and sets the outputs as follows:
GT = 1 if IN1 > IN2
GE = 1 if IN1 ≥ IN2,
EQ = 1 if IN1 = IN2
LE = 1 if IN1 ≤ IN2
LT = 1 if IN1 < IN2
I/Os
Function
This block compares two input variables and sets the outputs as follows:
GT = 1 if IN1 > IN2
GE = 1 if IN1 ≥ IN2
EQ = 1 if IN1 = IN2
LE = 1 if IN1 ≤ IN2
LT = 1 if IN1 < IN2
I/Os
Function
This block compares two input variables and sets the outputs as follows:
GT = 1 if IN1 > IN2
GE = 1 if IN1 ≥ IN2
EQ = 1 if IN1 = IN2
LT = 1 if IN1 < IN2
LE = 1 if IN1 ≤ IN2
The other four outputs are set to 0 in each case.
I/Os
Function
This block compares two input variables and sets the outputs as follows:
GT = 1 if IN1 > IN2
GE = 1 if IN1 ≥ IN2
EQ = 1 if IN1 = IN2
LE = 1 if IN1 ≤ IN2
LT = 1 if IN1 < IN2
I/Os
Introduction
CFC only allows the interconnection of block outputs (source type) to block inputs (target type)
if both data types are identical (e.g., REAL output <-> REAL input). Conversion blocks must
be used to allow the interconnection of different data types. The input and output data of the
block are of a different type, and it thus converts the input data type according to the data type
set at the output.
Conversion rules
The abbreviated name of the source and target data type, connected by means of an
underscore "_", form the type name.
The table below shows a brief description of conversion rules for specific blocks. If the IN input
value is not within the allowed range, the OUT output value becomes invalid and the test output
ENO = 0 is displayed.
You can evaluate ENO, for example, to provide a substitute/safety value for further processing.
The CONVERT library contains blocks you can use to convert n values of a data type to m
values of another data type (the values of m and n may be equal).
The following blocks convert one value of a data type into one value of another data type:
The following blocks convert several BOOL type values into one BYTE, WORD or DWORD
type value:
The following blocks convert one BYTE, WORD or DWORD type values into several BOOL
type values:
8.2 BY_DW
Function
Copies the byte of IN to the low-byte of OUT and sets the high-bytes to 0.
Troubleshooting
n.a.
I/Os
8.3 BY_W
Function
Copies the byte of IN to the low-byte of OUT and sets the high-byte to 0.
Troubleshooting
n.a.
I/Os
8.4 DI_DW
Function
Copies the bit string of IN to OUT.
Troubleshooting
n.a.
I/Os
8.5 DI_I
Function
Converts the IN bit string to INT and copies the result to OUT.
Troubleshooting
If the values of IN lie outside the range of -32 768 to 32 767, ENO = 0 and OUT is an invalid
value.
I/Os
8.6 DI_R
Function
Converts the value of IN to a REAL number and copies the result to OUT.
Troubleshooting
n.a.
I/Os
8.7 DW_DI
Function
Copies the bit string of IN to OUT.
Troubleshooting
n.a.
I/Os
8.8 DW_R
Method of operation
The block only forwards the bit string and does not change any values. To cause a value
change to REAL, you must use the DW_DI block and then the DI_R block.
Function
Copies the bit string of IN to OUT.
Troubleshooting
Not applicable
I/Os
8.9 DW_W
Function
Copies the low-word of IN to the word of OUT.
Troubleshooting
ENO = 0 if the IN high-word > 0
I/Os
8.10 I_DI
Function
Copies the value of IN to OUT.
Troubleshooting
n.a.
I/Os
8.11 I_DW
Function
Copies the bit string of IN to the low-word of OUT and sets the high-word to 0.
Troubleshooting
n.a.
I/Os
8.12 I_R
Function
Copies the integer of IN to OUT.
Troubleshooting
n.a.
I/Os
8.13 I_W
Function
Copies the bit string of IN to OUT.
Troubleshooting
n.a.
I/Os
8.14 R_DI
Function
Converts the REAL value of IN to OUT.
Troubleshooting
If the value of IN is outsidce the range -2.147483648e+09 und 2.147483647e+09, then ENO
= 0 and OUT is invalid.
I/Os
8.15 R_DW
Method of operation
The block only forwards the bit string and does not change any values. In order to convert
REAL to DWORD, you must use the R_TO_DW block (PCS 7 Library).
Function
Copies the bit string of IN to OUT.
Troubleshooting
Not applicable
I/Os
8.16 R_I
Function
The REAL number at input IN is converted to an INT number and output at output OUT. The
number is rounded as follows: 0.5 → 0, 1.5 → 2, 2.5 → 2, 3.5 → 4, etc.
Troubleshooting
If the value at IN is not in the range –32768 to 32767, then ENO = 0 and OUT is invalid.
I/Os
8.17 W_BY
Function
Copies the low-byte of IN to OUT.
Troubleshooting
If the high-byte > 0, then ENO = 0.
I/Os
8.18 W_DW
Function
Copies the word of IN to the low-word of OUT.
Troubleshooting
n.a.
I/Os
8.19 W_I
Function
Copies the bit string of IN to OUT.
Troubleshooting
n.a.
I/Os
8.20 BO_BY
Function
This block converts the eight Boolean type input values to a BYTE type value and outputs the
result. 8 BOOL -> 1 BYTE conversions are performed as follows:
The i-th bit of the BYTE value is set to 0 (or 1) when the i-th input value is 0 (or 1). (i = 0 to 7).
Troubleshooting
Not applicable
I/Os
8.21 BO_W
Function
This block converts the 16 Boolean type input values to a WORD type value and outputs the
result. 16 BOOL -> 1 WORD conversions are performed as follows:
The i-th bit of the WORD value is set to 0 (or 1) when the i-th input value is 0 (or 1) (i = 0 to
15).
Troubleshooting
Not applicable
I/Os
8.22 BO_DW
Function
This block converts the 32 Boolean type input values to a DWORD type value and outputs the
result. 32 BOOL -> 1 DWORD conversions are performed as follows:
The i-th bit of the DWORD value is set to 0 (or 1) when the i-th input value is 0 (or 1) (i = 0 to
31).
Troubleshooting
Not applicable
I/Os
8.23 BY_BO
Function
This block converts the input value of data type BYTE to 8 values of data type BOOL and
outputs the result in 8 variables. IN bit0 is mapped to OUT0, IN bit1 to OUT1, etc.
Troubleshooting
n.a.
I/Os
8.24 W_BO
Function
This block converts the input value of the WORD data type in 16 values of the BOOL data
type, which are created at the 16 outputs. IN-Bit0 is then converted to OUT0, IN-Bit1 to OUT1
etc.
Troubleshooting
Not applicable
I/Os
8.25 DW_BO
Function
This block converts the input value of the DWORD data type in 32 values of the BOOL data
type, which are created at the 32 outputs. IN-Bit0 is then converted to OUT0, IN-Bit1 to OUT1
etc.
Troubleshooting
Not applicable
I/Os
Note
The value range of real numbers is:
-3.40282e^+38 ... -1.755e^-38 ... 0 ... 1.755e^-38 ... 3.40282e^+38
Function
This block adds the values of inputs and outputs the sum.
OUT = IN1 + IN2
Troubleshooting
ENO = 0 on overflow or underflow.
I/Os
Function
This block subtracts the value at input IN2 from input IN1 and outputs the difference.
OUT = IN1 - IN2
Troubleshooting
ENO = 0 on overflow and underflow.
I/Os
Function
This block multiplies the inputs and outputs the product.
OUT = IN1 * IN2
Troubleshooting
ENO = 0 on overflow and underflow.
I/Os
Function
This block divides the value at input IN1 by the value at input IN2 and outputs the quotient.
OUT = IN1 / IN2
Troubleshooting
ENO is set to 0 on divisions by 0, overflow and underflow.
I/Os
Function
This block compares the inputs and outputs their maximum value.
OUT = MAX {IN1, ... , INn}
Blocks
Name Description
MAX2_R 2 inputs of type REAL
MAX4_R 4 inputs of type REAL
MAX8_R 8 inputs of type REAL
I/Os
Function
This block compares the inputs and outputs their minimum value.
OUT = MIN {IN1, ... , INn}
Blocks
Name Description
MIN2_R 2 inputs of type REAL
MIN4_R 4 inputs of type REAL
MIN8_R 8 inputs of type REAL
I/Os
Function
This block outputs the absolute value of the input.
OUT = | IN |
I/Os
Function
This block calculates and outputs the square root of the input.
OUT = SQRT(IN)
Troubleshooting
ENO = 0 and OUT = 0 if IN < 0.
I/Os
Function
This block calculates and outputs the exponential function of the input. In this equation, "e" is
Euler’s constant 2.71…, the base of the natural logarithm.
OUT = e^IN
Troubleshooting
ENO = 0 on overflow and underflow.
ENO = 0 and OUT = 0 if IN < 0.
I/Os
Function
This block calculates the power of 10IN of the input and send the result to the output.
OUT = 10^IN
Troubleshooting
ENO = 0 with IN1 < -37.9 and IN1 > 38.5
I/Os
Function
This block calculates and outputs the natural logarithm of the input.
OUT = LN (IN)
The variable at input IN must be positive.
Troubleshooting
ENO = 0 on overflow and underflow.
ENO = 0 and OUT = 0 if IN < 0.
I/Os
Function
This block calculates and outputs the base-10 logarithm value of the input.
OUT = LOG10(IN)
The variable at input IN must be positive.
Troubleshooting
ENO = 0 on overflow and underflow.
ENO = 0 and OUT = 0 if IN < 0.
I/Os
Function
This block calculates and outputs the sine of the input. The variable at IN must be a radian
value.
OUT = SIN(IN)
I/Os
Function
This block calculates and outputs the cosine of the input. The variable at IN must be a radian
value.
OUT = COS(IN)
I/Os
Function
This block calculates and outputs the tangent of the input. The variable at IN must be a radian
value.
OUT = TAN(IN)
I/Os
Function
This block calculates and outputs the arc sine of the input. The result is output as a radian
value between -π/2 and +π/2. The range of the function argument must be between 1 and +1.
OUT = ASIN(IN)
I/Os
Function
This block calculates and outputs the arc cosine of the input. The result is output as a radian
value between 0 and π. The range of the function argument must be between -1 and +1.
OUT = ACOS(IN)
Troubleshooting
ENO = 0 at IN < -1 --> OUT = 3.14..
ENO = 0 at IN > 1 --> OUT = 0
I/Os
Function
This block calculates and outputs the arc tangent of the input. The result is output as a radian
value between -π/2 and +π/2. The range of the function argument is the entire REAL number
range.
OUT = ATAN(IN)
I/Os
Function
This block outputs the input variable with inverted sign.
I/Os
Function
This block compares the input variables IN, MAX and MIN. It checks if IN is within or outside
the intervals limited by MIN and MAX. If the low limit MIN of the interval is greater than or equal
to the high limit MAX, the output OUT = MAX and the outputs OUTU and OUTL are set to 1.
IN > MAX represents a violation of the high limit, OUT = MAX, OUTU = 1 and OUTL = 0. IN <
MIN represents a violation of the low limit, OUT = MIN, OUTU = 0, OUTL = 1. If IN is between
MIN and MAX, OUT = IN, OUTU = 0, OUTL = 0 are set.
If the low limit MIN is equal to the high limit, the block behaves as follows:
IN < MAX: OUT = MAX; OUTU = 0; OUTL = 1
IN > MAX: OUT = MAX; OUTU = 1; OUTL = 0
I/Os
Function
This block compares the absolute values of the inputs. If the absolute value of input IN < than
the INTERVAL limit, output QA will be set to 1 and output QN to 0. In this case the input variable
IN is contained in the interval. Otherwise output QA is set to 0 and output QN is set to 1. The
input variable IN is then outside the interval.
I/Os
Function
This block adds input variable IN to output variable OUT, if input CI = 1 and inputs RI and SI
= 0. If RI = 1, OUT = 0. If SI = 1 and RI = 0, then OUT = IN.
Troubleshooting
ENO = 0 on overflow and underflow.
Truth table
RI SI CI OUT ENO
1 X X 0 1
0 1 X IN 1
0 0 1 OUT* + IN 1
0 0 0 OUT* 1
X is a random value
OUT* is the old value from the previous cycle
I/Os
Function
This block sends the input variable IN1 to the output, raised to the power of the input variable
IN2.
OUT = IN1^IN2
Requirement: IN1 > 0
Troubleshooting
M7 goes to STOP with an overshoot or undershoot.
I/Os
Function
This block outputs the average value of the last N input values.
OUT = (Ink + Ink -1 + ... + Ink -n + 1) / N
where INk is the current input value. For the number of input values N the condition
0 < N < 33
must be satisfied.
Startup characteristics
During startup and initial run each element of the buffer for IN and OUT values is set to 0.
I/Os
Note
The value range of data types INT and DINT is
INT: -32 768 ... 32 767
DINT: -2 147 483 648 ... 2 147 483 647
Function
This block adds the values of inputs and outputs the sum.
OUT = IN1 + IN2
Troubleshooting
ENO = 0 on overflow and underflow.
I/Os
Function
This block subtracts input IN2 from input IN1and outputs the difference.
OUT = IN1 - IN2
Troubleshooting
ENO = 0 on overflow and underflow.
I/Os
Function
This block multiplies the inputs and outputs the product.
OUT = IN1 * IN2
Troubleshooting
ENO = 0 on overflow and underflow.
I/Os
Function
This block divides the value at input IN1 by the value at input IN2 and outputs the quotient.
OUT = IN1 / IN2
Troubleshooting
ENO = 0 in the case of division by 0 and –32768 in the case of division by –1.
I/Os
Function
This block outputs the modulo of an integer division DIV_I (Page 102) of input IN1 by input IN2.
Troubleshooting
ENO = 0 in the case of division by 0.
I/Os
Function
This block compares the inputs and outputs their maximum value.
OUT = MAX {IN1, ... , INn}
Blocks
Name Description
MAX2_I 2 inputs of the type INT
MAX4_I 4 inputs of the type INT
MAX8_I 8 inputs of the type INT
I/Os
Function
This block compares the inputs and outputs their minimum value.
OUT = MIN {IN1, ... , INn}
Blocks
Name Description
MIN2_I 2 inputs of the type INT
MIN4_I 4 inputs of the type INT
MIN8_I 8 inputs of the type INT
I/Os
Function
This block outputs the absolute value of the input.
OUT = | IN |
Troubleshooting
ENO = 0 if IN = -32 768
I/Os
Function
This block outputs the input variable with inverted sign.
Troubleshooting
ENO = 0 if IN = -32 768
I/Os
Function
This block compares the input variables IN, MAX and MIN. It checks if IN is within or outside
the intervals limited by MIN and MAX.
If the low limit MIN of the interval is greater than the high limit MAX, the output OUT = MAX
and the outputs OUTU and OUTL are set to 1.
IN ≥ MAX represents a violation of the high limit, OUT = MAX, OUTU = 1 and OUTL = 0. IN
≤ MIN represents a violation of the low limit, OUT = MIN, OUTU = 0, OUTL = 1. If IN is between
MIN and MAX, OUT = IN, OUTU = 0, OUTL = 0 are set.
If MAX = MIN, the outputs OUTU and OUTL will depend on IN:
● OUTU = 1 with IN = MIN = MAX
● OUTL = 1 with IN < MIN = MAX
● OUTU = 1 with IN > Max = MAX
● In addition: OUT = MAX = MIN
Troubleshooting
ENO = 0 with MIN > MAX --> OUT = MAX; OUTU = OUTL = 1
I/Os
Function
This block compares the absolute value of the input IN with the value of the INTERVAL input.
If the absolute amount of input IN < than the INTERVAL limit, output QA will be set to 1 and
output QN to 0. In this case the input variable IN is contained in the interval. Otherwise output
QA is set to 0 and output QN is set to 1. The input variable IN is then outside the interval.
INTERVAL must have a positive value.
If INTERVAL ≤ 0, then QA = 0.
Troubleshooting
ENO = 0 with IN = -32 768
I/Os
Function
This block adds the input variable IN to the output variable OUT when the CI input is set to 1
and the RI and SI inputs are set to 0. If RI = 1, the OUT output is set to 0. If SI = 1 and RI = 0,
then OUT = IN.
Troubleshooting
ENO = 0 on overflow and underflow.
Truth table
RI SI CI OUT ENO
1 X X 0 1
0 1 X IN 1
0 0 1 OUT* + IN 1
0 0 0 OUT* 1
X is any value
OUT* is the old value from the last cycle
I/Os
Function
This block adds the values of inputs and outputs the sum.
OUT = IN1 + IN2
Troubleshooting
ENO = 0 on overflow and underflow.
I/Os
Function
This block subtracts the value at input IN2 from input IN1 and outputs the difference.
OUT = IN1 - IN2
Troubleshooting
ENO = 0 on overflow and underflow.
I/Os
Function
This block multiplies the inputs and outputs the product.
OUT = IN1 * IN2
Troubleshooting
ENO = 0 on overflow and underflow.
I/Os
Function
This block divides the value at input IN1 by the value at input IN2 and outputs the quotient.
OUT = IN1 / IN2
Troubleshooting
ENO = 0 in the case of division by 0 and –2147483648 in the case of division by –1.
I/Os
Function
This block outputs the modulo of an integer division DIV_DI (Page 114) of input IN1 by input
IN2.
Troubleshooting
ENO = 0 in the case of division by 0.
I/Os
Function
This block compares the inputs and outputs their maximum value.
OUT = MAX {IN1, ... , INn}
Blocks
Name Description
MAX2_DI 2 inputs of the type DINT
MAX4_DI 4 inputs of the type DINT
MAX8_DI 8 inputs of the type DINT
I/Os
Function
This block compares the inputs and outputs their minimum value.
OUT = MIN {IN1, ... , INn}
Blocks
Name Description
MIN2_DI 2 inputs of the type DINT
MIN4_DI 4 inputs of the type DINT
MIN8_DI 8 inputs of the type DINT
I/Os
Function
This block outputs the absolute value of the input.
OUT = | IN |
Troubleshooting
ENO = 0 if IN = -2 147 483 648 (smallest negative number)
I/Os
Function
This block outputs the input variable with inverted sign.
Troubleshooting
ENO = 0 if IN = -2 147 483 648
I/Os
Function
This block compares the input variables IN, MAX and MIN. It checks if IN is within or outside
the intervals limited by MIN and MAX.
If the low limit MIN of the interval is greater than the high limit MAX, the output OUT = MAX
and the outputs OUTU and OUTL are set to 1.
IN ≥ MAX represents a violation of the high limit, OUT = MAX, OUTU = 1 and OUTL = 0.
IN ≤ MIN represents a violation of the low limit, OUT = MIN, OUTU = 0, OUTL = 1. If IN is
between MIN and MAX, then OUT = IN, OUTU = 0, OUTL = 0 are set.
If MAX = MIN, the outputs OUTU and OUTL will depend on IN:
● OUTU = 1 with IN = MIN = MAX
● OUTL = 1 with IN < MIN = MAX
● OUTU = 1 with IN > Max = MAX
● In addition: OUT = MAX = MIN
Troubleshooting
ENO = 0 with MIN > MAX --> OUT = MAX; OUTU = OUTL = 1
I/Os
Function
This block compares the absolute value of the input IN with the value of the INTERVAL input.
If the absolute value of the IN input is less than the INTERVAL limit, the QA output is set to 1
and the QN output is set to 0. In this case the input variable IN is contained in the interval.
Otherwise output QA is set to 0 and output QN is set to 1. In this case the input variable IN is
outside of the range of the interval.
INTERVAL must have a positive value.
If INTERVAL is ≤ 0 , then QA = 0.
Troubleshooting
ENO = 0 with IN = -2 147 483 648
I/Os
Function
This block adds the input variable IN to the output variable OUT when the CI input is set to 1
and the RI and SI inputs are set to 0. If RI = 1, the OUT output is set to 0. If SI = 1 and RI = 0,
then OUT = IN.
Troubleshooting
ENO = 0 on overflow and underflow.
Truth table
RI SI CI OUT ENO
1 X X 0 1
0 1 X IN 1
0 0 1 OUT* + IN 1
0 0 0 OUT* 1
X is any value
OUT* is the old value from the last cycle
I/Os
Function
J K
0 0
0 1 0 1
1 0 1 0
1 1
*)
*) The outputs toggle the value in the cycle of the inserted tasks.
I/Os
Function
R S
0 0
0 1 1 0
1 0 0 1
1 1 0 1
I/Os
Function
R S
0 0
0 1 1 0
1 0 0 1
1 1 1 0
I/Os
Function
The bits of input value IN are shifted left by the number of steps specified in input IN. The result
is displayed at the output.
I/Os
Function
The bits of input value IN are shifted left by the number of steps specified in input IN. The result
is displayed at the output.
I/Os
Function
The bits of input value IN are shifted right by the number of steps specified in input IN. The
result is displayed at the output.
I/Os
Function
The bits of input value IN are shifted right by the number of steps specified in input IN. The
result is displayed at the output.
I/Os
Function
The bits of input value IN are rotated left by the number of steps specified in input IN. The
result is displayed at the output.
I/Os
Function
The bits of input value IN are rotated left by the number of steps specified in input IN. The
result is displayed at the output.
I/Os
Function
The bits of input value IN are rotated right by the number of steps specified in input IN. The
result is displayed at the output.
I/Os
Function
The bits of input value IN are rotated right by the number of steps specified in input IN. The
result is displayed at the output.
I/Os
Function
The block is a multiplexer 1 of n for INT values (n = 2, 4, 8). One of the inputs IN0...IN7 is set
to the output, depending on the value at selection input K.
Troubleshooting
ENO = 0 and OUT = 0, if k > (n-1) or k < 0.
Function table
Number of inputs
2 K: 0 1
OUT: IN0 IN1
4 K: 0 1 2 3
OUT: IN0 IN1 IN2 IN3
8 K: 0 1 2 3 4 5 6 7
OUT: IN0 IN1 IN2 IN3 IN4 IN5 IN6 IN7
I/Os
Function
The block is a multiplexer 1 of n for DINT values (n = 2, 4, 8). One of the inputs IN0...IN7 is
set to the output, depending on the value at selection input K.
Troubleshooting
ENO = 0 and OUT = 0, if k > (n-1) or k < 0.
Function table
Number of inputs
2 K: 0 1
OUT: IN0 IN1
4 K: 0 1 2 3
OUT: IN0 IN1 IN2 IN3
8 K: 0 1 2 3 4 5 6 7
OUT: IN0 IN1 IN2 IN3 IN4 IN5 IN6 IN7
I/Os
Function
The block is a multiplexer 1 of n for REAL values (n = 2, 4, 8). One of the inputs IN0...IN7 is
set to the output, depending on the value at selection input K.
Troubleshooting
ENO = 0 and OUT = 0, if k > (n-1) or k < 0.
Function table
Number of inputs
2 K: 0 1
OUT: IN0 IN1
4 K: 0 1 2 3
OUT: IN0 IN1 IN2 IN3
8 K: 0 1 2 3 4 5 6 7
OUT: IN0 IN1 IN2 IN3 IN4 IN5 IN6 IN7
I/Os
Function
The block is a multiplexer 1 of n for BOOL values (n = 2, 4, 8). One of the inputs IN0...IN7 is
set to the output, depending on the value at selection input K.
Troubleshooting
ENO = 0 and OUT = 0, if k > (n-1) or k < 0.
Function table
Number of
inputs
2 K: 0 1
OUT: IN0 IN1
4 K: 0 1 2 3
OUT: IN0 IN1 IN2 IN3
8 K: 0 1 2 3 4 5 6 7
OUT: IN0 IN1 IN2 IN3 IN4 IN5 IN6 IN7
I/Os
Function
This block sets the value of input IN0 (K = 1) or IN1 (K = 0) at the output, depending on the
value at input K.
I/Os
Function
This block sets the value of input IN0 (K = 1) or IN1 (K = 0) at the output, depending on the
value at input K.
I/Os
Function
This block is an edge-triggered up counter. In the case of a rising edge, the counter has the
default value PV at input S. A rising edge at input CU increments the counter. The counter
value is output at CV. The counter is stopped when the maximum INT value (32767) is reached.
A reset signal sets the counter to 0 and restarts the up count.
Q = 0, if CV = 0,
Q = 1 if CV > 0
Startup characteristics
The block's startup behavior is identical to its reset behavior (CV = 0).
Truth table
R CU CV ENO
1 X 0 1
0 1 CV*+1 1
0 0 CV* 1
X is a random value
CV* is the old value from the previous cycle
I/Os
Note
This block exists twice: In the standard library as SFB0 and in the CFC elementary library as
FB24. Both blocks have different behavior:
● The SFB0 type possesses no preassigned value. The PV input is compared with the CV
output for reaching / exceeding. The Q output indicates whether the current counter value
is greater than or equal to PV.
● The FB24 has input PV as preassigned value. Counting starts as of this value. The output
Q is not evaluated.
Function
This block is an edge-triggered down-counter. On a rising edge at input S, the value PV is
written to the counter. A rising edge at input CD decrements the counter. The counter value
is output at CV. The counter is stopped when the minimum INT value is reached. A reset signal
sets the counter to 0.
Q = 0, if CV = 0
Q = 1 if CV > 0
The counter is stopped when CV = 0 is reached. There is no counting in the negative range.
Startup characteristics
The block's startup behavior is identical to its reset behavior (CV = 0).
Truth table
R CD CV ENO
1 X 0 1
0 1 CV*-1 1
0 0 CV* 1
X is a random value
CV* is the old value from the previous cycle
I/Os
Function
This block is an edge-triggered up/down counter. On a rising edge at input S, the value PV is
written to the counter. A rising edge at input CU increments the counter. A rising edge at input
CD decrements the counter. The counter value is output at CV. Outputs QU or QD can be
used to monitor the counter value. The counter is reset with R=1.
QU = 1, if CV < max. INT (32767)
QU = 0 if CV = max. INT (32767)
QD = 0 if CV = – max. INT (-32768)
QD = 1, if CV > - max. INT (-32768)
Startup characteristics
The block's startup behavior is identical to its reset behavior (CV = 0).
Truth table
R CU CD CV ENO
1 X X 0 1
0 1 0 CV*+1 1
0 0 1 CV*-1 1
0 0 0 CV* 1
0 1 1 CV* 1
X is a random value
CV* is the old value from the previous cycle
I/Os
Function
The block starts the timer in the operating mode set by the value at the MODE input:
● Pulse generator
● Extended pulse
● ON delay
● ON delay with memory
● OFF delay
Operating modes
The block only applies the operating mode (MODE) on a rising edge at input I0. This edge
change is also necessary following a CPU restart. The timer counter PTIME is loaded with the
value TIME0 and decremented periodically by the sampling time SAMPLE_T. The status at
the output Q0 changes according to the set MODE once the time has expired. The values at
outputs Q0 = 0 and PTIME = 0 are output via RESET = 1.
Pulse diagrams
MODE=0 pulse
,
5(6(7
4
7 7
7 7,0( W
,
5(6(7
4
7 7 7 7
7 7,0( W
MODE=2 ON delay
,
5(6(7
4
7 7 7 7
7 7,0( W
,
5(6(7
4
7 7 7 7
7 7,0( W
,
5(6(7
4
7 7 7 7
7 7,0( W
I/Os
Note
Cumulation of sampling time SAMPL_T
The TIMER_P block works internally with REAL values. Whenever the sampling time
SAMPL_T cannot be displayed exactly as a REAL number, inaccuracies occur in cumulation.
The sampling time can only be displayed exactly as a REAL number when the decimal places
of the sampling time occur through division by 2, 4, 8, 16 etc.
Examples of exact sampling times: x.5, x.25, x.125, x.0625 etc.
Examples of inexact sampling times: x.1, x.2
"x" represents a positive integer here.
Note
In order to ensure proper operation of the R_TRIG block, it must be installed in a watchdog
interrupt (cyclic task).
Function
This block checks for a rising edge at the input variable and outputs the result. Output Q = 1
if a rising edge is detected at pulse input CLK.
Startup characteristics
The edge bit memory is set to 0 on startup.
Pulse diagram
,
W
4
I/Os
Note
To operate correctly, the F_TRIG block must be installed in a cyclic interrupt (cyclic task).
Function
This block checks for a falling edge at the input variable and outputs the result. Output Q = 1
if a falling edge is detected at pulse input CLK.
Startup characteristics
The edge bit memory is set to 1 on startup.
Pulse diagram
,
W
4
I/Os
Note
To operate correctly, the AFP block must be installed in a cyclic interrupt (cyclic task).
Function
Clock. This block generates pulses according to pulse/break ratio that is to be configured. This
ratio can be configured and is specified in ms units.
Startup characteristics
During startup, the counters and enable bits are set for the periods Q = 0 and Q = 1. Whereby
the enable bit for Q = 0 will be set to 1, the other values to 0.
Pulse diagram
(1
W
7 7 7 7 7 7 7 7 7 7
If EN = 0, output Q remains in the current state. The expired time of T0 or T1 is stopped (T0(1)
or T1(1) in the diagram) and not reset.
If EN = 1, the remaining time runs from T0 or T1 (T0(2) or T1(2) in the diagram).
I/Os
Function
This block measures the time between two calls (maximum: 2 147 483 647 ms).
Note
There must be no date change between the calls otherwise there would be a negative time
difference (00:00:00 – measured time).
I/Os
Function
This block outputs the system time at which the block is called at output TM.
I/Os
16.4 TIME_END: Compares the input time with the actual time
Function
This block indicates the time difference between input TM and the actual system time at output
TM_DIFF. Input TM of this block can be interconnected to output TM of a TIME_BEG block in
order to determine the time between calls to those two blocks.
I/Os
17.2 CONT_C
Introduction
The CONT_C function block is used on SIMATIC S7 programmable logic controllers to control
technical processes with continuous input and output variables. By means of parameter
assignment you can activate or deactivate subfunctions of the PID controller to adapt the
controller to the controlled system.
Application
You can use the controller as a PID fixed-setpoint controller either alone or in multi-loop
feedback controls as a cascade, blending or ratio controller. The functions of the controller are
based on the PID control algorithm of the sampling controller with an analog output signal, if
necessary extended by including a pulse generator stage to generate pulse-duration
modulated output signals for two-step or three-step controllers with proportional final controlling
elements.
Description
Apart from the functions in the setpoint and process variable branches, the function block
implements a complete PID controller with continuous manipulated value output and the option
of influencing the manipulated value manually. The following subfunctions exist:
● Setpoint branch (Page 213)
● Process variable branch (Page 207)
● Error signal (Page 212)
● PID algorithm (Page 211)
● Manual-value processing (Page 205)
● Manipulated-value processing (Page 214)
● Disturbance variable input (Page 215)
Error information
The error-message word RET_VAL is not used.
Input parameters
Output parameters
Additional information
For more information, refer to the section:
CONT_C: Block diagram (Page 169)
17.3 CONT_S
Introduction
The CONT_S function block is used on SIMATIC S7 programmable logic controllers to control
technical processes with binary manipulated-value output signals for integrating final
controlling elements. By means of parameter assignment you can activate or deactivate
subfunctions of the PI step controller to adapt the controller to the process.
Application
You can use the controller as a PI fixed-setpoint controller or in secondary control loops in
cascade, blending or ratio controllers, but not as the master controller. The functions of the
controller are based on the PI control algorithm of the sampling controller supplemented by
the functions for generating the binary output signal from the analog actuating signal.
The I component of the controller can be closed with TN = T#0ms. In this way the block can
be used as a P controller.
So that the controller can work without repeated manipulated value, the manipulated value
calculated internally does not match the final controlling element position. A comparison is
made if the manipulated value (ER * GAIN) is negative. The controller then sets the output
manipulated-value signal down (QLMNDN) until the low limit signal of the repeated
manipulated value (LMNR_LS) is set.
The controller can also be used in a controller cascade as a subordinate position controller.
The final controlling element position is set with the setpoint input SP_INT. In this case the
process-variable input and the integration time parameter (TN) have to be set to zero. A
possible application would be a temperature controller with heating-capacity control via
interpulse period control and cooling-capacity control via a butterfly valve.
In order to close the valve completely, the manipulated value (ER * GAIN) should be negative.
Description
In addition to the functions in the process-variable branch, the function block implements a
complete PI controller with a binary manipulated-value output and the option of influencing the
manipulated value manually. The step controller operates without repeated manipulated value.
The following subfunctions exist:
● Setpoint branch (Page 213)
● Process variable branch (Page 207)
● Error signal (Page 212)
Error information
The error-message word RET_VAL is not used.
Input parameters
Output parameters
Additional information
For more information, refer to the section:
CONT_S: Block diagram (Page 174)
17.4 PULSEGEN
Introduction
The PULSEGEN function block is used to structure a PID controller with pulse output for
proportional final controlling elements.
Application
PID two-step or three-step controllers with pulse-duration modulation can be configured with
the PULSEGEN function block. The function is normally used in conjunction with the
continuous controller CONT_C (Page 164).
&217B& 38/6(*(1
/01 ,19
Description
The PULSEGEN function transforms the input variable INV (=LMN of the PID controller) by
modulating the pulse duration in a pulse train with constant period time. It corresponds to the
cycle time used to update the input variable and must be parameterized in PER_TM.
The duration of a pulse per period time is proportional to the input variable. The cycle assigned
to PER_TM is not identical to the processing cycle of the PULSEGEN function block. Rather,
a PER_TM cycle consists of several PULSEGEN function block processing cycles. In this
context, the number of PULSEGEN calls per PER_TM cycle provides a measure of the
accuracy of the pulse-duration modulation.
You will find more information on pulse duration modulation under: Pulse-duration
modulation (Page 206)
An input variable of 30% and 10 PULSEGEN calls per PER_TM means:
● "One" at the QPOS output for the first three calls of PULSEGEN (30% of 10 calls)
● "Zero" at the QPOS output for seven further PULSEGEN calls (70% of 10 calls)
The pulse width is recalculated at the beginning of each period.
Note
The call frequency must be programmed by the user.
Automatic synchronization
It is possible to synchronize the pulse output automatically with the block that updates the input
variable INV (for example, CONT_C). This ensures that a changing input variable is output as
quickly as possible as a pulse.
The pulse generator always evaluates the input variable INV at intervals corresponding to the
period time PER_TM and converts the value into a pulse signal of corresponding length. Since,
however, INV is usually calculated in a slower cyclic interrupt, the pulse generator should start
the conversion of the discrete value into a pulse signal as soon as possible after the updating
of INV.
To allow this, the block can synchronize the start of the period itself using the following
procedure:
If INV changes and if the block call is not in the first or last two call cycles of a period,
synchronization is performed. The pulse width is recalculated and is output in the next cycle
with a new period.
Automatic synchronization can be disabled by setting the "SYN_ON" input to FALSE.
Note
When a new period starts, the old value of INV (in other words of LMN) will be simulated in
the pulse signal more or less inaccurately following synchronization.
Operating modes
Depending on the parameters assigned to the pulse generator, PID controllers with a three-
step output or with a bipolar or unipolar two-step output can be configured. The following table
illustrates the setting of the switch combinations for the possible modes.
Input parameters
Note
The values of the input parameters are not limited in the block. There is no parameter check.
Output parameters
Error information
The error-message word RET_VAL is not used.
Additional information
You can find additional information in the following sections:
PULSEGEN: Block diagram (Page 180)
PULSEGEN: Three-step control (Page 180)
PULSEGEN: Three-step control, asymmetrical (Page 181)
PULSEGEN: Two-step control (Page 182)
PULSEGEN: Manual operation in two- or three-step control (Page 182)
326B3B21
1(*B3B21
6<1B21
67(3B21 0$1B21
67%,B21
4326B3
,19 41(*B3
3(5B70
3B%B70
5$7,2)$&
Description
In "three-step control" mode, the actuating signal can adopt three states. The values of the
binary output signals QPOS_P and QNEG_P are assigned to the relevant statuses of the final
controlling element. The table shows the example of a temperature control:
Based on the input variable, a characteristic curve is used to calculate a pulse width. The form
of the characteristic curve is defined by the minimum pulse or minimum break time and the
ratio factor. The normal value for the ratio factor is 1.
The "doglegs" in the curves are caused by the minimum pulse or minimum break times. You
will find more information on characteristic curves under:
Symmetrical characteristic for three-step controller (Page 216)
Note
Small absolute values at the input variable LMN that would generate a pulse width shorter than
P_B_TM are suppressed. Large input values that would generate a pulse width longer than
(PER_TM - P_B_TM) are set to 100% or -100%.
The duration of the positive or negative pulses is calculated from the input variable (in %)
multiplied by the period time. Pulse width = INV/100 * PER_TM
Additional information
You can find additional information in the following sections:
PULSEGEN: Three-step control, asymmetrical (Page 181)
PULSEGEN: Two-step control (Page 182)
PULSEGEN: Manual operation in two- or three-step control (Page 182)
Description
The ratio factor RATIOFAC can be used to change the ratio of the duration of positive to
negative pulses. In a thermal process, for example, this would allow different system time
constants for heating and cooling.
The ratio factor also affects the minimum pulse time or period time. A ratio factor < 1 means
that the threshold value for negative pulses is multiplied by the ratio factor.
Additional information
You can find additional information in the following sections:
Asymmetrical characteristic for three-step controller (Page 217)
Description
In two-step control, only the positive pulse output QPOS_P of PULSEGEN is connected to the
on/off final controlling element. Depending on the manipulated-value range being used, the
two-step controller will have a bipolar or a unipolar manipulated-value range.
The negated output signal is available at QNEG_P if the interconnection of the two-step
controller in the control loop requires a logically-inverted binary signal for the actuating pulses.
Additional information
You can find additional information in the following sections:
Characteristic with bipolar range of manipulated values (Page 208)
Characteristic with unipolar range of manipulated values (Page 209)
PULSEGEN: Three-step control (Page 180)
PULSEGEN: Three-step control, asymmetrical (Page 181)
PULSEGEN: Manual operation in two- or three-step control (Page 182)
Description
In manual operation (MAN_ON = TRUE), the binary outputs of the three-step or two-step
controller can be set using the POS_P_ON and NEG_P_ON signals regardless of INV.
Additional information
You can find additional information in the following sections:
PULSEGEN: Three-step control (Page 180)
PULSEGEN: Three-step control, asymmetrical (Page 181)
PULSEGEN: Two-step control (Page 182)
18.2 DELAY
Note
The block can only be used for M7-300/400 run-time systems!
Function
The block generates a software interrupt. It starts the task whose name is set at the TN input.
If a name is specified to which no task has been assigned, an error will be reported during
compilation and consistency checking.
I/Os
Note
The block can only be used for M7-300/400 run-time systems!
Function
This block enables the operation of a calling task without interruptions by other tasks. All
queued start events are delayed either until processing is enabled (via the EDELAY block) or
until the task currently being executed has been completed.
All queued start events are then executed.
Any errors that occur during task processing can be queried via the LASTERR block.
Information on the EDELAY and LASTERR blocks is contained in the following sections:
● EDELAY: Enable signal for delayed start events (Page 188)
● LASTERR: Determining the error code in DELAY, EDELAY, DISCARD,
EDISCARD,P_REASON (Page 191)
Note
The block can only be used for M7-300/400 run-time systems!
Function
This block enables delayed start events. These events must have been delayed initially via
the DELAY block.
Any errors that occur during task processing can be queried via the LASTERR block.
Information on the DELAY and LASTERR blocks is contained in the following sections:
● DELAY: Delaying the start event (Page 187)
● LASTERR: Determining the error code in DELAY, EDELAY, DISCARD,
EDISCARD,P_REASON (Page 191)
Note
The block can only be used for M7-300/400 run-time systems!
Function
This block enables the operation of a calling task without interruptions by other tasks. All
queued start events are discarded, i.e., the tasks are not started. Events already registered
(delayed) are processed. Process interrupts are acknowledged immediately.
All queued start events are discarded either until processing is enabled (via the EDISCARD
block) or until the task currently being executed has been completed.
Any errors that occur during task processing can be queried via the LASTERR block.
Information on the EDISCARD and LASTERR blocks is contained in the following sections:
● EDISCARD: Enable signal for all new start events (Page 190)
● LASTERR: Determining the error code in DELAY, EDELAY, DISCARD,
EDISCARD,P_REASON (Page 191)
Note
The block can only be used for M7-300/400 run-time systems!
Function
This block enables queued start events. These events must have been discarded initially via
the DISCARD block.
Any errors that occur during task processing can be queried via the LASTERR block.
Information on the DISCARD and LASTERR blocks is contained in the following sections:
● DISCARD: All arising start events are discarded (Page 189)
● LASTERR: Determining the error code in DELAY, EDELAY, DISCARD,
EDISCARD,P_REASON (Page 191)
Note
The block can only be used for M7-300/400 run-time systems!
Function
This block returns the error code of the last error that occurred for the following error classes:
● I/O errors
● Errors in the system blocks:
– DELAY: Delaying the start event (Page 187),
– EDELAY: Enable signal for delayed start events (Page 188),
– DISCARD: All arising start events are discarded (Page 189),
– EDISCARD: Enable signal for all new start events (Page 190),
– P_REASON: Determining the cause of the process interrupt (Page 193)
The possible values represent a subset of M7 system software error codes. For additional
information, refer to file M7API.H or to the M7 system software documentation.
I/Os
Note
The block can only be used for M7-300/400 run-time systems!
Function
This block can be used to determine the system time and display it in TIME format at its output.
I/Os
Function
This block can be used to locate the cause of a process interrupt.
The name of the task required is specified at input TN. The block will not have any effect if this
task is not a process interrupt.
Additional information the process alarm had output during its last call is written to the STATE
output. This additional information refers to specific modules and its byte sequence is,
therefore, returned in INTEL format.
The MASK output also returns the interrupt mask configured in CFC for this process-interrupt
task.
Any errors that occur during task processing can be queried via the LASTERR block.
You can find additional information on the LASTERR block in the section: LASTERR:
Determining the error code in DELAY, EDELAY, DISCARD, EDISCARD,P_REASON
(Page 191)
I/Os
Application
The block is used in a CFC chart when AS-wide connections are used and when the error
status of these connections is to be evaluated in the user program.
Insert one instance of the block in the CFC chart on the sending and receiving end for each
AS-wide connection.
Remove the instances when you have deleted the AS-wide connection.
Function
The block will output the error status of the AS-wide connection whose ID was configured at
the NETPRO_ID input.
The block outputs a separate bit for each error. A group error is also available. An error will
also be issued if the specified NETPRO_ID does not exist.
Troubleshooting
The return value RET_VAL is not used.
Input parameters
Output parameters
Additional information on AS-wide connection is available in the help "CFC for SIMATIC S7 >
Creating runtime structures > Creating and working with interconnections > Creating AS-wide
interconnections".
19.2 IK_MANAG
IK_MANAG
Application
The "IK_MANAG block is part of the runtime system to support the AS-wide interconnections;
it is copied during initial creation of an AS-wide interconnection to the block folder of the S7
program.
Therefore this block will not be described in detail.
Additional information on AS-wide connection is available in the help "CFC for SIMATIC S7 >
Creating runtime structures > Creating and working with interconnections > Creating AS-wide
interconnections".
19.3 IK_SEND
IK_SEND
Application
The "IK_SEND block is part of the runtime system to support the AS-wide interconnections; it
is copied during initial creation of an AS-wide interconnection to the block folder of the S7
program.
Therefore this block will not be described in detail.
Additional information on AS-wide connection is available in the help "CFC for SIMATIC S7 >
Creating runtime structures > Creating and working with interconnections > Creating AS-wide
interconnections".
19.4 IK_RCV
IK_RCV
Application
The "IK_RCV block is part of the runtime system to support the AS-wide interconnections; it
is copied during initial creation of an AS-wide interconnection to the block folder of the S7
program.
Therefore this block will not be described in detail.
Additional information on AS-wide connection is available in the help "CFC for SIMATIC S7 >
Creating runtime structures > Creating and working with interconnections > Creating AS-wide
interconnections".
19.5 IK_CP_OU
IK_CP_OU
Application
The "IK_CP_OU block is part of the runtime system to support the AS-wide interconnections;
it is copied during initial creation of an AS-wide interconnection to the block folder of the S7
program.
Therefore this block will not be described in detail.
Additional information on AS-wide connection is available in the help "CFC for SIMATIC S7 >
Creating runtime structures > Creating and working with interconnections > Creating AS-wide
interconnections".
19.6 IK_CP_IN
IK_CP_IN
Application
The "IK_CP_IN block is part of the runtime system to support the AS-wide interconnections; it
is copied during initial creation of an AS-wide interconnection to the block folder of the S7
program.
Therefore this block will not be described in detail.
Additional information on AS-wide connection is available in the help "CFC for SIMATIC S7 >
Creating runtime structures > Creating and working with interconnections > Creating AS-wide
interconnections".
19.7 IK_ALARM
IK_ALARM
Application
The "IK_ALARM block is part of the runtime system to support the AS-wide interconnections;
it is copied during initial creation of an AS-wide interconnection to the block folder of the S7
program.
Therefore this block will not be described in detail.
Additional information on AS-wide connection is available in the help "CFC for SIMATIC S7 >
Creating runtime structures > Creating and working with interconnections > Creating AS-wide
interconnections".
Function
This block compares during runtime the number of process objects (POs) that are recorded
under the "AS RT PO" license with the number of POs that are loaded in the CPU 410-5H
Process Automation ("CPU 410-5H PA").
The block is automatically inserted in CFC "@PA-CPU" during compilation and this CFC is
installed in OB1. The block and CFC are loaded in the "CPU 410-5H PA" during the download
to the AS.
If the number of recorded licenses for POs in the Automation License Manager is lower than
the number of POs that are loaded in the AS, insufficient licensing is indicated by:
● An entry in the diagnostics buffer of the CPU
● Cyclic triggering of a corresponding message in SIMATIC WinCC.
The message is always triggered immediately during the loading process for which
insufficient licensing is detected and when the difference is changed by the loading process.
Afterwards, the message is triggered in intervals of 6 hours.
When the process objects are sufficiently licensed once again, for example, due to a
reduction of the POs required in the AS program or the purchase of additional licenses, the
message is no longer triggered. No "OUTGOING" message is generated.
Note
For the "CPU 410-5H PA", the maximum number of loadable POs are licensed by the
hardware. It is not possible to download a greater number of POs than is licensed by the
hardware into the AS. However, this limit is not relevant for the comparison in block "PA-CPU".
It is possible to switch between manual and automatic operation. In the case of manual
operation the manipulated variable is corrected to a manual value.
The integrator (INT) is set internally to LMN - LMN_P - DISV and the differentiator (DIF) to 0,
and then adjusted internally. This means that switching over to automatic operation will be
smooth.
Pulse-duration modulation
,19
/01
W
4326B3
W
3(5B70
Key
1 PULSEGEN cycle
2 Cycle CONT_C
The process variable can be read in as a peripheral or floating-point value. The function
CRP_IN converts the peripheral value PV_PER into a floating-point format from -100 to +100%
in accordance with the following rule:
Output of CPR_IN = PV_PER * 100/27648
The function PV_NORM normalizes the output of CRP_IN in accordance with the following
rule:
Output of PV_NORM = (output of CRP_IN) * PV_FAC + PV_OFF
The default value of PV_FAC is 1 and that of PV_OFF is 0.
3(5B70
3(5B703B%B70
3B%B70
Key
1 Continuous "Off"
2 Duration of the positive pulse
3 Continuous "On"
3(5B70
3(5B703B%B70
3B%B70
Key
1 Duration of the positive pulse
This function block runs without a repeated manipulated value. The I component of the PI
algorithm and the assumed repeated manipulated value are calculated in one integrator (INT)
and compared as a feedback value with the remaining P component. The difference then goes
to a three-step element (THREE_ST) and to a pulse generator (PULSEOUT), which generates
the pulses for the control valve. The switching frequency of the controller is reduced by adapting
the response threshold of the three-step element.
The PID algorithm functions as a manipulated variable algorithm. The proportional, integral
(INT) and differential (DIF) components are connected in parallel and can be switched in or
out individually. In this way P, PI, PD and PID controllers and even pure I and D controllers
can be configured,
The difference between setpoint value and process variable constitutes the error signal. In
order to suppress a minor sustained oscillation due to quantization of manipulated values (for
example, in the case of pulse duration modulation with PULSEGEN or limited resolution of the
manipulated value by the control valve) the error signal is routed via a dead zone
(DEADBAND). When DEADB_W = 0 the dead band is switched out.
The manipulated value is limited to pre-definable values using the LMNLIMIT function.
Signaling bits are set whenever the limits are exceeded.
The function LMN_NORM normalizes the output of LMNLIMIT in accordance with the following
rule:
LMN = (output of LMNLIMIT) * LMN_FAC + LMN_OFF
The default value of LMN_FAC is 1 and that of LMN_OFF is 0.
The manipulated value is also available in periphery format. The function CRP_OUT converts
the floating-point value LMN into a peripheral value in accordance with the following rule:
LMN_PER = LMN * 27648/100
3(5B70
3(5B703B%B70
3B%B70
Key
1 Duration of the positive pulse
2 Continuous "On"
3 Continuous "Off"
4 Duration of the negative pulse
3(5B70
3(5B703B%B70
3B%B70
3B%B70
3(5B703B%B70
3(5B70
Key
1 Duration of the positive pulse
2 Duration of the negative pulse
COUNTER, 145
CPU 410-5H PA, 203
CTD, 148 F
CTU, 146
F_TRIG, 156
CTUD, 149
Falling edge, 156
Current time, 161
Detection, 156
reading out, 161
Flip-flop, 123
Flip-flop, reset dominant, 125
Flip-flop, set dominant, 126
D Floating point arithmetic blocks, 71
DELAY, 187 FRC_CFC, 194
Description of Description, 194
FRC_CFC, 194
Detection, 155, 156
of the falling edge, 156 I
of the rising edge, 155
I_DI, 55
DI_DW, 49
I_DW, 56
DI_I, 50
I_R, 57
DI_R, 51
I_W, 58
DISCARD, 189
Input time, 162
DIV_DI, 114
comparing with the actual time, 162
DIV_I, 102
Interval, INT, 109
DIV_R, 75
Interval, REAL, 92
Divider, DINT, 114
Interval, symmetrical, DINT, 121
Divider, INT, 102
Inverter, 23
Divider, REAL, 75
Inverter, DINT, 119
Double word logic, 25
Inverter, DWORD, 37
Down counter, 148
Inverter, INT, 107
DW_BO, 70
Inverter, REAL, 90
DW_DI, 52
Inverter, WORD, 31
DW_R, 53
DW_W, 54
J
E JK flip-flop, 124
JK_FF, 124
EDELAY, 188
EDISCARD, 190
EPS_DI, 121
EPS_I, 109
L
EPS_R, 92 LASTERR, 191
EVENT, 186 LIM_DI, 120
Exclusive-OR operation, 20 LIM_I, 108
Exclusive-OR operation, generic, DWORD, 34 LIM_R, 91
Exclusive-OR operation, WORD, 28 Limiter, asymmetrical, DINT, 120
Execution time, 160 Limiter, asymmetrical, INT, 108
measuring time, 160 Limiter, asymmetrical, REAL, 91
EXP, 80 LN, 82
Exponential function, REAL, 80 LOG10, 83
Extended pulse, 152
NEG_I, 107
NEG_R, 90
M NOR, 22
NOR operation, 22
M7 task, 186
NOR operation, generic, DWORD, 36
Start, 186
NOR operation, WORD, 30
MATH_FP, 71
NOT, 23
MATH_INT, 97
Maximum, DINT, 116
Maximum, INT, 104
Maximum, REAL, 76
O
MAXn_DI, 116 OFF delay, 152
MAXn_I, 104 ON delay, 152
MAXn_R, 76 ON delay with memory, 152
Measuring, 160 OR, 19
Execution time, 160 OR operation, 19
Memory word 0, 13 OR operation, generic, DWORD, 33
Minimum, DINT, 117 OR operation, WORD, 27
Minimum, INT, 105
Minimum, REAL, 77
MINn_DI, 117 P
MINn_I, 105
P_REASON, 193
MINn_R, 77
PA-CPU, (See CPU 410-5H PA)
MOD_DI, 115
POW10, 81
MOD_I, 103
Power of 10, REAL, 81
Modulo, DINT, 115
Power of, general, REAL, 94
Modulo, INT, 103
POWXY, 94
MUL_DI, 113
PULSE, 151
MUL_I, 101
Pulse duration modulation, 175
MUL_R, 74
Pulse generator, 152
Multiplexer, BOOL, 141
Pulse generator for proportional final control
Multiplexer, DINT, 139
elements, 175
Multiplexer, INT, 138
PULSEGEN, 175
Multiplexer, REAL, 140
Block diagram,
Multiplier, DINT, 113
Manual operation, 182
Multiplier, INT, 101
Three-step control, 180
Multiplier, REAL, 74
Three-step control asymmetrical, 181
MULTIPLX, 137
Two-step control, 182
MUXn_BO, 141
MUXn_DI, 139
MUXn_I, 138
MUXn_R, 140
R
MW0, 13 R_DI, 59
R_DW, 60
R_I, 61
N R_TRIG, 155
Reading out, 161
NAND, 21
Current time, 161
NAND operation, 21
Rising edge, 155
NAND operation, generic, DWORD, 35
Detection, 155
NAND operation, WORD, 29
ROL_DW, 133
Natural logarithm, REAL, 82
ROL_W, 132
NEG_DI, 119
ROR_DW, 135
ROR_W, 134
Rotate, left, DWORD, 133
Rotate, left, WORD, 132 U
Rotate, right, DWORD, 135
Up counter, 146
Rotate, right, WORD, 134
Up/down counter, 149
RS_FF, 125
W
S
W_BO, 69
SAMP_AVE, 95
W_BY, 62
SEL_BO, 142
W_DW, 63
SEL_R, 143
W_I, 64
SHIFT, 127
WAND_DW, 32
Shift, left, DWORD, 129
WAND_W, 26
Shift, left, WORD, 128
WNAND_DW, 35
Shift, right, DWORD, 131
WNAND_W, 29
Shift, right, WORD, 130
WNOR_DW, 36
SHL_DW, 129
WNOR_W, 30
SHL_W, 128
WNOT_DW, 37
SHR_DW, 131
WNOT_W, 31
SHR_W, 130
WOR_DW, 33
SIN, 84
WOR_W, 27
Sine, REAL, 84
Word logic, 25
SQRT, 79
WRD_LGC, 25
Square root, REAL, 79
WXOR_DW, 34
SR_FF, 126
WXOR_W, 28
Start, 186
M7 task, 186
Startup on S7-300 CPUs, 13
Step control, 170
X
SUB_DI, 112 XOR, 20
SUB_I, 100
SUB_R, 73
Subtractor, DINT, 112
Subtractor, INT, 100
Subtractor, REAL, 73
SYSTEM, 185
SYSTIME, 192
T
TAN, 86
Tangent, REAL, 86
TIME, 160
TIME, group, 159
TIME_BEG, 161
TIME_END, 162
TIMER_P, 152