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
| Name | Type | Description |
|---|---|---|
| IN | ANY_NUM | Input value (may be negative) |
Outputs
| Name | Type | Description |
|---|---|---|
| OUT | ANY_NUM | Absolute 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
Siemens (TIA Portal)
Use ABS instruction in TIA Portal.
Allen-Bradley (Studio 5000)
Use ABS instruction in Studio 5000.
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.
Related Function Blocks
SUB (Subtraction)
Subtracts second input from first input, outputs the difference.
View Reference →GT (Greater Than)
Returns TRUE when first input is strictly greater than second input.
View Reference →LT (Less Than)
Returns TRUE when first input is strictly less than second input.
View Reference →ADD (Addition)
Adds two or more numeric values and outputs the sum.
View Reference →MUL (Multiplication)
Multiplies two numeric values and outputs the product.
View Reference →DIV (Division)
Divides first input by second input, outputs the quotient.
View Reference →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.
Instant download - 30-day money-back guarantee - Use on unlimited projects