Scale (REAL)
Instruction Parameters
Supported PLC Series
| XPnA/1R | XPnB | XPnE | XPnF | CP3A/B/P/U CP4A~D/U | CPnE | CPnF | BP | PLC-S |
|---|---|---|---|---|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ | - | - | - | - | ✓ |
Supported Data Registers
| M | X | Y | K | L | F | T | C | S | Z | R | Q | D | @D | Constant | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| S | ✓ | ✓ | ✓ | ✓ | ✓ | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - |
| D | ✓ | - | ✓ | ✓ | ✓ | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - |
| P | ✓ | - | ✓ | ✓ | ✓ | - | - | - | - | ✓ | ✓ | ✓ | ✓ | ✓ | - |
| n | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | - | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Supported Flags
| Flag | Bit | Support |
|---|---|---|
| Error | F11.0 | ✓ |
| Zero | F11.1 | - |
| Carry | F11.2 | - |
Number of Steps
| Steps |
|---|
| 5 |
Operands
| Operand | Description |
|---|---|
| S | The first operand. Entries are only REAL data registers. This is the data to be scaled. The value range is -1.7014118e+38 ~ 3.4028237e+38 (2-127 ~ 2128). |
| D | The second operand. Entries are only REAL data registers. This is where the result of the scaling is saved. |
| P | The third operand. Entries are only REAL data registers. This is the data table that defines the linear function for scaling. This requires 4 REAL data registers. |
| n | The fourth operand. Entries are WORD data registers or constants. This is the number of data registers, starting at D, to scale. |
Notice
Error Flag (F11.0) Notice
The error flag, F11.0, will be ON for one scan when the address of the data register assigned by @D exceeds the range of the data register, D. The range of the data register, D, is dependent on the CPU type.
F11.0 turns ON when the value of S exceeds the scaling range defined in P or when D exceeds its defined range.
The value assigned to n must not exceed the range of the corresponding data register. If the assigned value exceeds the range of the area assigned to the data registers S and D, it may cause a PLC CPU STOP command.
Scaling Table (P)
The P operand data register stores data in the following:
| Data Register | Description | Axis |
|---|---|---|
| P P+1 | Range start point of the data to be scaled. Raw minimum value. Start S | X |
| P+2 P+3 | Range end point of the data to be scaled. Raw maximum value. End S | X |
| P+4 P+5 | Range start point of scaled data. Scaled minimum value. Start D | Y |
| P+6 P+7 | Range end point of scaled data. Scaled maximum value. End D | Y |
Scaling Equations
The equations for scaling are as follows:
- Destination (D) = Source (S) × Gradient + Offset
- Gradient = (End D - Start D) ÷ (End S - Start S)
- Offset (Y-intercept) = End D - Gradient × End S
Instruction Behavior
The ESCL and ESCLP instructions behave as follows:
- When the data assigned to the data register S exceeds the range between Start S and End S, the data is converted into the value assigned to Start D or End D.
- The value is converted to Start D when the value assigned to the data register S is less than Start S.
- The value is converted to End D when the value assigned to the data register S is greater than End S.
- When Gradient is negative, the data assigned to the data register S is converted into the value assigned to End D and Start D.
- The value is converted to End D when the value assigned to the data register S is less than Start S.
- The value is converted to Start D when the value assigned to the data register S is greater than End S.
- The value assigned to n must not exceed the range of the corresponding data register.
- If the assigned value exceeds the range of the area assigned to the data registers S and D, it may cause a PLC CPU STOP command.