Block that calculates the Value module, storing the result in Result.
Ladder Representation
![]()
Block Structure
Variable Type |
Name |
Data Type |
Description |
VAR_INPUT |
EN |
BOOL |
Block enabling |
Value |
BYTE USINT SINT WORD UINT INT DWORD UDINT DINT REAL |
Reference variable for the operation |
|
VAR_OUTPUT |
Done |
BOOL |
End of operation |
Result |
BYTE USINT SINT WORD UINT INT DWORD UDINT DINT REAL |
Variable that stores the result of the operation |
Operation
When this block has a TRUE value in EN, it sends to the Result output the absolute value of the Value variable. If no errors, the Done variable is set. If there is any error in the operation, Done is not set, staying in FALSE status, while Result remains with its value unchanged.
When EN has FALSE value, Result remains unchanged and Done remains in FALSE.
Block Flowchart

Example in Ladder

The above example calculates the absolute value of the VALUE variable whose initial value is -45, storing the final result, 45, in RESULT.

The above example calculates the absolute value of the VALUE variable whose initial value is -45. The final result, 128, cannot be stored in RESULT, because it is outside the limits of accepted values by SINT type. Therefore, RESULT remains unchanged and the output is disabled.
Example in ST
The example below displays the instructions for applying the example above in the ST language.
VAR VALUE : SINT := 45; RESULT : SINT; END_VAR
RESULT := FB_ABS(EN:=DI1, Value:=VALUE, Done=>DO1);
|
|---|