Compute CPT

Dest = the result of an expression, like (A − B) / 2.

TagAfter two scans
A10
B3
Result3

How it works

While the rung is true, works out the expression and writes it to Dest. Use + - * / % and brackets. * / % come before + -. If any value is a REAL the result is a REAL, and an integer Dest is rounded. A fault, such as dividing by 0, leaves Dest unchanged.

How it's used

Use CPT when a formula has several steps.

TagValue
Temp170
Temp276
AvgTemp73

AvgTemp = (Temp1 + Temp2) / 2 = 73.

Operands

OperandData typeRead or write
DestSINT, INT, DINT, LINT, REALWrites

Common mistakes

  • Expecting a later step to fix an overflowEach step is checked, so (2147483647 + 1) - 2 faults at the +.