Description
You use the "Unscale" instruction to unscale the floating-point number in the IN parameter into physical units between a low limit and a high limit and convert it into an integer. You use the LO_LIM and HI_LIM parameters to specify the low limit and high limit of the value range to which the input value is unscaled. The result of the instruction is output at the OUT parameter.
The "Unscale" instruction works with the following equation:
OUT = [ ((IN–LO_LIM)/(HI_LIM–LO_LIM)) ∗ (K2–K1) ] + K1
The values of the "K1" and "K2" constants are determined by the signal state at the BIPOLAR parameter. The following signal states are possible at the BIPOLAR parameter:
-
Signal state "1": It is assumed that the value at the IN parameter is bipolar and in a value range between -27648 and 27648. In this case, the constant "K1" has the value -27648.0 and the constant "K2" the value +27648.0.
-
Signal state "0": It is assumed that the value at the IN parameter is unipolar and in a value range between 0 and 27648. In this case, the constant "K1" has the value 0.0 and the constant "K2" the value +27648.0.
When the value at parameter IN is not within the limits defined by HI_LIM and LO_LIM, an error is output and the result is set to the nearest limit.
When the indicated low limit value is greater than the high limit value (LO_LIM > HI_LIM), the result is scaled in reverse proportion to the input value.
Parameters
The following table shows the parameters of the "Unscale" instruction:
|
Parameters |
Declaration |
Data type |
Memory area |
Description |
|
|---|---|---|---|---|---|
|
S7-1200 |
S7-1500 |
||||
|
EN |
Input |
BOOL |
I, Q, M, D, L or constant |
I, Q, M, D, L, T, C or constant |
Enable input |
|
ENO |
Input |
BOOL |
I, Q, M, D, L |
I, Q, M, D, L |
Enable output |
|
IN |
Input |
REAL |
I, Q, M, D, L, P or constant |
I, Q, M, D, L, P or constant |
Input value to be unscaled to an integer value. |
|
HI_LIM |
Input |
REAL |
I, Q, M, D, L, P or constant |
I, Q, M, D, L, P or constant |
High limit |
|
LO_LIM |
Input |
REAL |
I, Q, M, D, L, P or constant |
I, Q, M, D, L, P or constant |
Low limit |
|
BIPOLAR |
Input |
BOOL |
I, Q, M, D, L or constant |
I, Q, M, D, L or constant |
Indicates whether the value at the IN parameter is to be interpreted as bipolar or unipolar. The parameter can assume the following values: 1: Bipolar 0: Unipolar |
|
OUT |
Output |
INT |
I, Q, M, D, L, P |
I, Q, M, D, L, P |
Result of the instruction |
|
RET_VAL |
Output |
WORD |
I, Q, M, D, L, P |
I, Q, M, D, L, P |
Error information |
RET_VAL parameter
The following table shows the meaning of the values of the RET_VAL parameter:
|
Error code* |
Explanation |
|---|---|
|
0000 |
No error |
|
0008 |
The value of the IN parameter is greater than the value of the high limit (HI_LIM) or less than the value of the low limit (LO_LIM). |
|
General error information |
See also: "GET_ERR_ID: Get error ID locally" |
|
* The error codes can be displayed as integer or hexadecimal values in the program editor. You can find information on switching the display formats here: Switching display formats in the program status |
|
Example
The following example shows how the instruction works:
The following table shows how the instruction works using specific operand values:
|
Parameters |
Operand |
Value |
|---|---|---|
|
IN |
Tag_InputValue |
50.03978588 |
|
HI_LIM |
Tag_HighLimit |
100.0 |
|
LO_LIM |
Tag_LowLimit |
0.0 |
|
BIPOLAR |
Tag_Bipolar |
1 |
|
OUT |
Tag_OutputValue |
22 |
|
RET_VAL |
Tag_ErrorCode |
W#16#0000 |