Skip to main content

Scale (WORD)

Instruction Parameters

Supported PLC Series

XPnA/1RXPnBXPnEXPnFCP3A/B/P/U
CP4A~D/U
CPnECPnFBPPLC-S

Supported Data Registers

MXYKLFTCSZRQD@DConstant
S-----
D------
P------
n-

Supported Flags

FlagBitSupport
ErrorF11.0
ZeroF11.1-
CarryF11.2-

Number of Steps

Steps
5

Operands

OperandDescription
SThe first operand.
Entries are only WORD data registers.
This is the data to be scaled.

The signed value range is -32,768 ~ 32,767 (216).
The unsigned value range is 0 ~ 65,535 (216-1).
The Hexadecimal value range is H0000 ~ HFFFF.
DThe second operand.
Entries are only WORD data registers.
This is where the result of the scaling is saved.
PThe third operand.
Entries are only WORD data registers.
This is the data table that defines the linear function for scaling.
This requires 4 WORD data registers.
nThe 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 RegisterDescriptionAxis
PRange start point of the data to be scaled.
Raw minimum value.
Start S
X
P+1Range end point of the data to be scaled.
Raw maximum value.
End S
X
P+2Range start point of scaled data.
Scaled minimum value.
Start D
Y
P+3Range 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 SCL and SCLP 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.

Examples