Skip to content

ABS — Absolute Value

Category
Compute
Type
Output
Availability
All platforms

ABS instruction block: Source Error, Dest Abs_Error


ABS (Absolute Value) writes the magnitude of Source to Dest every scan its rung is true: a negative value loses its sign, a positive value is copied unchanged. It is an output instruction with no state and no status bits. Use ABS when only the size of a difference matters, such as a deviation alarm that should fire whether the reading is high or low. Do not use ABS to clamp a value at zero; that keeps −5 as 5, not 0. Use a LES test and a MOV for a floor.


Operand Type Format Valid Range Required Description
Source Any numeric tag, member, element or bit, or a literal Tag, Tag.Member, Tag[n], Tag.bit, or a literal Any resolvable numeric reference Yes The value whose magnitude is wanted.
Dest A writable numeric tag, member or element Tag, Tag.Member, Tag[n] SINT, INT, DINT or REAL; not a literal, not an input pin Yes Where the magnitude is written.

Dest may be the same tag as Source. A REAL Source keeps its fraction when Dest is REAL and loses it when Dest is a whole-number type.

Range edge. The most negative value of a whole-number type has no positive twin: ABS of −32768 in an INT stays −32768. A REAL has no such edge.


Nothing. Dest keeps its power-up value.

The instruction does nothing. Dest holds its last value.

Source is read and its magnitude is written to Dest every scan the rung is true.

Nothing.


Scenario: A temperature loop computes the difference between setpoint and measurement. A deviation alarm should fire when that difference is large in either direction, so the sign is removed before the compare.

Tags:

  • Eval — Evaluate deviation, BOOL
  • Error — Setpoint minus measurement, INT
  • Abs_Error — Size of the error, INT

Rung 1:

—] [Eval———[ABS Error Abs_Error]———

Scan 1 — Eval = 0. Error reads −37, the measurement is above setpoint. The rung is false: Abs_Error holds 0.

Figure 1 — ABS rung false: Error −37, Abs_Error 0, rung dark

Scan 2 — Eval = 1. Abs_Error reads 37. A GRT Abs_Error 25 on the next rung fires the alarm for a reading 37 degrees high or 37 degrees low alike.

Figure 2 — ABS rung true: Abs_Error reads 37, rung lit


  • NEG — Negate
  • SUB — Subtract (the usual source of a signed error)
  • LIM — Limit Test (a deadband without ABS)
  • CPT — Compute (ABS(Setpoint − Actual) in one instruction)
  • Compute Instructions — Category index

Deadband in one line. LIM −25 Error 25 is true inside the band without computing the magnitude at all. ABS earns its place when the magnitude is used more than once.

The block never colours. Watch the rung wire and the Dest value line.

Applies to LadderIDE >=1.2.2 · Last reviewed 2026-09-11 · Screenshots verified 2026-09-11