Absolute value ABS
Dest = Source without its sign.
ABSOLUTE_VALUE
SourceGlobal.Error-8DestGlobal.ErrorAbs8
| Tag | After two scans |
|---|---|
| Error | -8 |
| ErrorAbs | 8 |
How it works
While the rung is true, writes Source without its minus sign, so -8 becomes 8. A false rung changes nothing.
How it's used
Use ABS when only the distance from a target matters, not the side.
SUB
AGlobal.Level42BGlobal.Target50DestGlobal.Error-8
ABSOLUTE_VALUE
SourceGlobal.Error-8DestGlobal.ErrorSize8
GRT
AGlobal.ErrorSize8B5
Global.OffTargetOTE
| Tag | Value |
|---|---|
| Level | 42 |
| Target | 50 |
| Error | -8 |
| ErrorSize | 8 |
| OffTarget | 1 |
Level is 8 below the target. ErrorSize is 8, so OffTarget is on.
Operands
| Operand | Data type | Read or write |
|---|---|---|
| Source | DINT, REAL or a number | Reads |
| Dest | DINT, REAL | Writes |
Common mistakes
- Using the smallest DINT-2147483648 has no positive DINT, so it is a fault.