EN/ENO boxes have an enable input EN and an enable output ENO. The enable input can be used to control processing of the box. If an error occurs while the box is being processed, this is displayed at the enable output. Fig. 7.23 provides an over- view of the “basic” functions implemented with EN/ENO boxes.
The parameters of the EN/ENO boxes must all be connected. The enable input EN and the enable output ENO are not parameters of the box function. They are used for processing boxes and are added to the box function by the program editor.
An EN/ENO box can be positioned on its own in a network, with or without connec- tion of the EN input or the ENO output. The ENO output can be connected to the EN input of the following box. By means of a contact at the beginning of this “main cur- rent path”, it is possible to switch processing of the complete current path on and off. The signal state of the ENO output of the last box indicates by means of a “1”
that the complete sequence has been processed without errors.
The ENO output of a box can be connected in parallel with the ENO output of a dif- ferent box if the boxes are present in separate current paths which commence on the left-hand power rail. “Current” then flows in the subsequent path if one of the two boxes has completed the processing without errors.
If an EN/ENO box is positioned in a T branch, its ENO output can no longer be returned to the path at which the T branch commences.
A detailed description of EN and ENO and how one can use the EN/ENO mechanism with self-created blocks can be found in Chapter 7.6.2 “EN/ENO mechanism with LAD” on page 309. The block calls in the ladder diagram, which are also shown as EN/ENO boxes, are described in Chapter 14.4 “Calling of code blocks” on page 576.
Fig. 7.23 Overview of boxes with enable input EN and enable output ENO MOVE
Data type SHR CONV
Real Data type EXP
ADD
Data type XOR EN
EN
EN EN
EN IN
IN N
IN IN1
IN1 IN2
IN2 ENO
ENO
ENO ENO
ENO OUT1
EN IN
ENO OUT1
OUT
OUT OUT
OUT Boxes with EN input and ENO output
DType to DType
Transfer functions Arithmetic functions Math functions
Conversion functions Shift functions Logical operations
7.5.1 Transfer function, MOVE
The transfer function MOVE transfers the value of one tag to another.
For programming, drag the symbol of the MOVE function with the mouse from the program elements catalog under Basic instructions > Move operations to the work- ing area.
A detailed description of the transfer function is provided in Chapter 13.2 “Transfer functions” on page 508.
In Fig. 7.24, the #Messages tag is transferred from the data block “Data.LAD” to the
“Message_bits” tag in the bit memory address area.
7.5.2 Arithmetic functions
An arithmetic function for numerical values implements the basic arithmetical operations with the data formats INT, DINT, and REAL in the user program. A detailed description of these arithmetic functions is provided in Chapter 13.4 “Arithmetic functions” on page 521.
For programming, drag one of the arithmetic functions (ADD, SUB, MUL, DIV, or MOD) with the mouse from the program elements catalog under Basic instruc- tions > Math functions to the working area. You can set the function (ADD, SUB, MUL, Fig. 7.24 Example of a transfer function in the ladder logic
Fig. 7.25 Example of an arithmetic function in the ladder logic
DIV, or MOD) and the data type (INT, DINT, or REAL) using drop-down lists which you can open using the small yellow triangle when the box is selected. The data type is also automatically set when the first actual value is created.
In Fig. 7.25, the upper limit of a measured value is monitored. A hysteresis is intro- duced to ensure that the #Measurement_too_high message does not “pulsate” when the measured value changes rapidly around the upper limit. The message #Mea- surement_too_high is only canceled when the measured value has dropped again below the upper limit by the magnitude of the hysteresis.
7.5.3 Math functions
The mathematical functions comprise, for example, trigonometric functions, expo- nential functions, and logarithmic functions with tags in data format REAL. A de- tailed description of these math functions is provided in Chapter 13.5 “Math func- tions” on page 527.
For programming, drag one of the mathematical functions (NEG, ABS, SQR, SQRT, LN, EXP, SIN, COS, TAN, ASIN, ACOS, or ATAN) with the mouse from the program elements catalog under Basic instructions > Math functions to the working area. You can set the function (NEG, ABS, SQR, SQRT, LN, EXP, SIN, COS, TAN, ASIN, ACOS, or ATAN) using drop-down lists which you can open using the small yellow triangle when the box is selected. The data type is permanently set to REAL.
Fig. 7.26 shows the calculation of the reactive power according to the equation
#Reactive_power = #Voltage #Current sin(#phi).
Fig. 7.26 Example of math functions in the ladder logic
7.5.4 Conversion functions
The conversion functions convert the data formats of tags. A detailed description of the conversion functions is provided in Chapter 13.6 “Conversion functions” on page 531.
Table 7.1 shows the data type conversions possible with LAD.
For programming, drag one of the conversion functions (CONVERT, ROUND, CEIL, FLOOR, or TRUNC) with the mouse from the program elements catalog under Basic instructions > Conversion operations to the working area. You can set the function and data types using drop-down lists which you can open using the small yellow tri- angle when the box is selected. If the first actual value created has a permissible da- ta type, the data type is also set automatically.
The conversion function T_CONV for data type conversion of date/time can be found in the program elements catalog under Extended instructions > Date and time_of_day.
Table 7.1 Data type conversion with LAD to
from BOOL BYTE WORD DWORD INT DINT REAL TIME S5TIME DT TOD DATE CHAR STRING BCD16 BCD32
BOOL
BYTE IX IX IO
WORD IX IO IO IO
DWORD IO IO IO
INT IO C S C
DINT IO C IO S C
REAL R S
TIME IO IO T
S5TIME IO T
DT T1) T T
TOD IO
DATE IO
CHAR IO
STRING S S S
BCD16 C
BCD32 C
Data type conversion is possible: IX Implicitly and independent of attribute IEC check IO Implicitly with deactivated attribute IEC check C Explicitly with CONV
R Explicitly with ROUND, CEIL, FLOOR, and TRUNC T Explicitly with T_CONV, 1) Conversion to day of week S Explicitly with S_CONV
Additionally: ATH, HTA, SCALE, UNSCALE
The conversion function S_CONV for data type conversion of character strings can be found in the program elements catalog under Extended instructions > String + Char.
Fig. 7.27 shows an example of the conversion functions. A measured value present in data format INT is first expanded to the data format DINT and then converted in- to the BCD format.
7.5.5 Shift functions
The shift functions shift the content of tags bit-by-bit to the left or right. A detailed description of the shift functions is provided in Chapter 13.7 “Shift functions” on page 544.
For programming, drag one of the shift functions (SHL, SHR, ROL, or ROR) with the mouse from the program elements catalog under Basic instructions > Shift and rotate to the working area. You can set the function (SHL, SHR, ROL, and ROR) and data types using drop-down lists, which you can open using the small yellow trian- gle when the box is selected. The data type is also automatically set when the first actual value is created.
In Fig. 7.28, the respective three decades of two numbers present in BCD format of a SIMATIC counter are joined without gaps. Using the shift function SHL – set to Fig. 7.27 Example of the conversion functions in the ladder logic
Fig. 7.28 Example of the shift functions in the ladder logic
data type DWORD! – the #Quantity_high tag is shifted to the left by 12 bits, corre- sponding to three decades. A small square on the input parameter IN indicates that the data type of the applied tag (WORD in the example) does not agree with the data type of the function (DWORD in the example) and has to be converted implicitly. The bottom three decades (the #Quantity_low tag) are subsequently added by a double- word logic operation according to OR and output to the #Quantity_display tag.
7.5.6 Word logic operations
The word logic operations link each bit of two tags according to an AND, OR, or exclusive-OR function. A detailed description of the word logic operations is provid- ed in Chapter 13.8.1 “Word logic operations” on page 549.
For programming, drag one of the word logic operations (AND, OR, XOR, INV) with the mouse from the program elements catalog under Basic instructions > Word logic operations to the working area. You can set the function (AND, OR and XOR with AND, OR and XOR, INV is fixed) and the data type (WORD and DWORD with AND, OR and XOR, INT and DINT with INV) via drop-down lists which you can open using the small yellow triangle when the box is selected. The data type is also automatically set when the first actual value is created.
Fig. 7.29 shows how you can program 32 edge evaluations simultaneously for ris- ing and falling edges. The message bits are collected in a doubleword Messages, which is present in data block “Data.LAD”. The edge trigger flags Messages_EM are
Fig. 7.29 Example of word logic operations in the ladder logic
also present in this data block. If the two doublewords are linked by an XOR logic operation, the result is a doubleword in which each set bit represents a different as- signment of Messages and Messages_EM, in other words: the associated message bit has changed. In order to obtain the positive signal edges, the changes are linked to the messages by an AND logic operation. The bit is set for a rising signal edge wher- ever the message and the change each have a “1”. This corresponds to the pulse flag of the edge evaluation. If you do the same with the negated message bits – the mes- sage bits with signal state “0” are now “1” – you obtain the pulse flags for a falling edge. At the end it is only necessary for the edge trigger flags to track the messages (last network in Fig. 7.29).