Try a PLC free — no signup
Math OperationsBeginnerIEC 61131-3

ABS (Absolute Value)

Returns the absolute (non-negative) value of the input.

The ABS (Absolute Value) function returns the non-negative magnitude of the input value. Negative values become positive; positive values remain unchanged. ABS is essential for error magnitude calculations, deviation measurement regardless of direction, and ensuring positive values for distance and speed calculations in PLC programs.

Parameters

Inputs

NameTypeDescription
INANY_NUMInput value (may be negative)

Outputs

NameTypeDescription
OUTANY_NUMAbsolute value of input (always >= 0)

Ladder Logic Example

// Ladder Logic - ABS (Error Magnitude)
//
// |----[SUB]--------[ABS]---------|
// | IN1: Setpoint   IN: Error     |
// | IN2: PV         OUT: Abs_Err  |

Structured Text Example

Error := Setpoint - Process_Value;
Error_Magnitude := ABS(Error);

IF Error_Magnitude > Tolerance THEN
    Out_Of_Spec := TRUE;
END_IF;

Free · no signup to try

Run this block in your browser

Try the instruction on a live rung before you copy it into a project — nothing to install.

Try it in your browser — no signup

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad

Platform-Specific Implementation

S

Siemens (TIA Portal)

Use ABS instruction in TIA Portal.

AB

Allen-Bradley (Studio 5000)

Use ABS instruction in Studio 5000.

C

CODESYS

Use ABS() function in ST.

Common Applications

  • Error magnitude calculation
  • Deviation monitoring
  • Speed (magnitude of velocity)
  • Distance calculation
  • Tolerance band checking

Frequently Asked Questions

What is ABS (Absolute Value) in PLC programming?

Returns the absolute (non-negative) value of the input. The ABS (Absolute Value) function returns the non-negative magnitude of the input value. Negative values become positive; positive values remain unchanged.

What are common applications of ABS (Absolute Value)?

ABS (Absolute Value) is commonly used for: Error magnitude calculation, Deviation monitoring, Speed (magnitude of velocity), Distance calculation, Tolerance band checking.

How do I use ABS (Absolute Value) in different PLC platforms?

Siemens: Use ABS instruction in TIA Portal. Allen-Bradley: Use ABS instruction in Studio 5000. CODESYS: Use ABS() function in ST.

Free · no signup to try

Wire this block up and run it

Drop the instruction into a rung, press Run and watch it execute in your browser — then adapt it to your vendor tool.

Try it in your browser — no signup

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad