Tietokoneiden näyttöjä, joissa näkyy kuvaa automaatiolaboratorion laitteistosta. Monitoreiden takana näkyy sama laitteisto kuin kuvissa.

timohei.net / My Courses / My Courses / Automation Systems / MetsoDNA Configuration How-to /
cmp and calc blocks

Comparison of floating-point and integer numbers (conversion to "binary value") is done with the cmp block, and calculation with the calc block. Several versions of these exist depending on the data types of the inputs and the number of inputs and outputs.

Free-form blocks in the manual

The help pages for these function blocks can be found as a PDF file from Valmet DNA Manuals:

  • Open the Valmet DNA manuals on the EAS server
  • Select Collection XXXX En. Then click on Application Libraries > Function Blocks > PCS Function Blocks
  • Click on Free-form Function Blocks

Calculation / comparison formula

The outputs of the function block are set according to the formula entered. The formula has the form

OUTPUT_IDENTIFIER = INPUT_IDENTIFIER OPERATOR [INPUT_IDENTIFIER | CONSTANT] [OPERATOR [INPUT IDENTIFIER | CONSTANT]] ... ;

where

  • OUTPUT_IDENTIFIER = the letter or letter-number combination that uniquely identifies the function block's output, for example o or o2
  • INPUT_IDENTIFIER = the letter that uniquely identifies the function block's input, for example a
  • | = or
  • CONSTANT = a numeric constant, for example 50 (integer) or 50.0 (decimal number)
  • OPERATOR = a symbol describing a comparison (cmp) or calculation (calc) operation, for example:
    • Comparison operators for the cmp block:
      • <
      • >
      • <=
      • >=
      • == (equality)
      • != (inequality)
      Example: with the formula
       o = a < b; 
      the output o is set to one when the value of input a is less than the value of input b; otherwise, the output o is set to zero.
  • cmp block logical operators:
    • AND
    • OR
    • XOR
    • NOT
    Example: with the formula
     o = a < b AND a > c; 
    the output o is set to one when a is less than b and greater than c, i.e., the value of input a is between the input values b and c.
  • Calculation operators for the calc block
    • +
    • -
    • *
    • /
    • ** (exponentiation)
    • trigonometric and logarithmic functions
  • ; = semicolon - the formula always ends with a semicolon! This allows the formula to be split over multiple lines:
    o = (a + b) * 3.14 +
        4 * (c + d);

cmp and calc examples

Changing constant values used in the formula with a debugger

If the constant value 1.105 in the previous example needs to be changed with a debugger, for example, this parameter must be given outside the free-form function block. Note the structure of the ana type [fault bits],[floating-point value part] - the fault bits are not given when the value is in the formula. However, they must be given if the value is specified as the initial value of the interface port):

Tips for error situations

If you get error messages with these function blocks, check:

  • that you have used the names a, b, c,... for the inputs and the name o for the output, or in the case of a multi-output function block, names o1, o2, o3,...
  • that you have something connected to all the inputs and outputs that you have used in the formula
  • that all the inputs and outputs that you have something connected to, are used at least once in the formula(s)
  • that you end the formula with a semicolon (;)

The formula can be split over multiple lines. The semicolon indicates where the formula ends.

Updated 25.5.2025

<<  Previous Page
(5) Binary Output BOU8
Sivu 6/15Next Page >>
(7) cng Function Block (conditional jump)
© Timo Heikkinen | timo piste heikkinen at oamk piste fi