CALCULATE (Calculate)
S7-1200 Programmable controller
V20
11/2024
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
2                                                                                                     , 11/2024
               conditions must be complied with. The information in the relevant documentation must be
               observed.
Trademarks
              All names identified by ® are registered trademarks of Siemens Aktiengesellschaft. 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.
              Siemens Aktiengesellschaft
                                                                             Copyright © Siemens 2024.
              Digital Industries
                                             11/2024 Subject to change       All rights reserved
              Postfach 48 48
              90026 NÜRNBERG
              GERMANY
, 11/2024                                                                                                   3
Table of content
1     CALCULATE (Calculate)          6
4                             , 11/2024
, 11/2024   5
CALCULATE (Calculate)
       Table 1. CALCULATE instruction
                                                                                                1
        LAD / FBD    SCL                         Description
                     Use the standard SCL        The CALCULATE instruction lets you create a math
                     math expressions to         function that operates on inputs (IN1, IN2, .. INn) and
                     create the equation.        produces the result at OUT, according to the equation
                                                 that you define.
                                                    Select a data type first. All inputs and the output
                                                    must be the same data type.
                                                    To add another input, click the icon at the last
                                                    input.
       Table 2. Data types for the parameters
        Parameter       Data type1
        IN1, IN2, ..INn SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal, Byte, Word, DWord
        OUT             SInt, Int, DInt, USInt, UInt, UDInt, Real, LReal, Byte, Word, DWord
       1 The IN and OUT parameters must be the same data type (with implicit conversions of the input
       parameters). For example: A SINT value for an input would be converted to an INT or a REAL
       value if OUT is an INT or REAL
       Click the calculator icon to open the dialog and define your math function. You enter your
       equation as inputs (such as IN1 and IN2) and operations. When you click "OK" to save the
       function, the dialog automatically creates the inputs for the CALCULATE instruction.
       The dialog shows an example and a list of possible instructions that you can include based on
       the data type of the OUT parameter:
6                                                                                                , 11/2024
              Note:
              You also must create an input for any constants in your function. The constant value would
              then be entered in the associated input for the CALCULATE instruction.
              By entering constants as inputs, you can copy the CALCULATE instruction to other locations
              in your user program without having to change the function. You then can change the
              values or tags of the inputs for the instruction without modifying the function.
            When CALCULATE is executed and all the individual operations in the calculation complete
            successfully, then the ENO = 1. Otherwise, ENO = 0.
, 11/2024                                                                                                  7