CPT Compute an expression (CPT)

Also called: compute, expression, formula, math expression

OUT := an expression written as text (+ − * / MOD, parentheses).

What it does

The CPT block computes a whole expression and writes the result into OUT when the rung is 1.

When to use it

For a formula with several operations: scaling, average, unit conversion.

Operands

European mnemonicAmerican mnemonicNameData typeDirectionRequiredMeaning
ENENEnableBOOLInputYesRung condition: the computation runs only when power flow is 1.
ExpressionExpressionExpressionANY_MAGNITUDEInputYesExpression, for example (V1 + V2) * 2.
OUTOUTDestinationINT, DINT, REAL, TIME / DINTOutputYesDestination: its type sets the type of the computation.
ENOENOEnable outBOOLOutputNo0 on division by zero.
MnemonicNameData typeDirectionRequiredMeaning
ENEnableBOOLInputYesRung condition: the computation runs only when power flow is 1.
ExpressionExpressionANY_MAGNITUDEInputYesExpression, for example (V1 + V2) * 2.
OUTDestinationINT, DINT, REAL, TIMEOutputYesDestination: its type sets the type of the computation.
ENOEnable outBOOLOutputNo0 on division by zero.
MnemonicNameData typeDirectionRequiredMeaning
ENEnableBOOLInputYesRung condition: the computation runs only when power flow is 1.
ExpressionExpressionANY_MAGNITUDEInputYesExpression, for example (V1 + V2) * 2.
OUTDestinationINT, DINT, REALOutputYesDestination: its type sets the type of the computation.
ENOEnable outBOOLOutputNo0 on division by zero.

Example

European style
American style

When S1 is 1, V3 := (V1 + V2) × 2.

Try it in the simulatorThe example opens in the free simulator; your own program stays as it was.

Behaviour in detail

European (IEC) and American styles

CPT (compute) comes from the American style. In the European style you would rather write a chain of ADD, MUL… blocks or structured text; here CPT is offered in both styles.

See also