Math (output instruction)
ABS: Absolute Value
Writes A with any negative sign removed.
Also called: absolute value, magnitude.
ABS(number, a, real)Arguments
| Name | What it is | Accepts | Default |
|---|---|---|---|
| destination | What the instruction acts on | a register | required |
| a | Source | a number or a tag | 0 |
| real | Floating point | true or false | false |
Arguments are positional and this table is generated from the simulator's own instruction registry, so it always matches what the engine accepts.
What it does
ABS answers how far, not which way. It is the instruction that turns a signed error into a distance.
That makes it the second half of nearly every deviation alarm. Subtract to get the error, take its magnitude, then compare against a band. Without the ABS the comparison only ever catches deviation in one direction, and the alarm that was meant to say the process has drifted stays silent for half of the ways it can drift.
Give the result its own tag. If the sign is still needed elsewhere, and in control it usually is, overwriting the signed error with its magnitude quietly breaks whatever was using it.
A rung you can run
A deviation alarm that catches both directions
SUB(Temp_Error,Oven_Temp,Temp_Setpoint)
ABS(Temp_Deviation,Temp_Error)
GRT(Temp_Deviation,10)XIC(Heat_Enable)TON(Dev_Delay,5000)
XIC(Dev_Delay.DN)OTE(Temp_Deviation_Alarm)Set Temp_Setpoint to 180 and Heat_Enable on, then try Oven_Temp at 165 and at 195. Both are 15 out, both raise the alarm, and the five second on-delay means a brief excursion on the way to setpoint does not. The signed error is still there in Temp_Error for anything that needs to know which way.
Run this rung in the simulatorWhat it is called on other controllers
| Platform | Equivalent |
|---|---|
| Rockwell (Studio 5000) | ABS |
| Siemens (TIA Portal) | ABS |
| Mitsubishi (GX Works) | ABS |
| CODESYS and IEC 61131-3 | ABS |
Common mistakes
- Comparing a signed error directly. An error of -30 satisfies a test for less than 5, so a deviation alarm without ABS passes happily while the process runs a long way under setpoint.
- Writing the magnitude back over the signed value. Anything downstream that needed to know which way the error went now cannot, and the fault appears somewhere else entirely.
Practise it
Interactive exercises that use ABS. Each one checks your ladder against a real scan.
