Learn PLCs free
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;

20 Production-Ready Ladder Logic Templates

Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.

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.

Stop Writing Ladder Logic From Scratch

Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.

20
Ready-Made Templates
LD + ST
Both Languages Included
$29
One-Time Purchase
Get Instant Access -- $29

Instant download - 30-day money-back guarantee - Use on unlimited projects

Free PLC simulator

Wire this block up and run it

Drop the instruction into a rung, hit Run, and watch it execute in your browser. 12 guided lessons across 8 PLC dialects — free account, no credit card.

Practice PLCs free →