2-277
2 Instructions
CP1E CPU Unit Instructions Reference Manual(W483)
Data Control Instructions
2
SCL
Flags
Function
SCL(194) is used to convert the unsigned binary data contained in the source word S into unsigned
BCD data and place the result in the result word R according to the linear function defined by points
(As, Ar) and (Bs, Br). The address of the first word containing the coordinates of points (As, Ar) and (Bs,
Br) is specified for the first parameter word P1. These points define by 2 values (As and Bs) before scal-
ing and 2 values (Ar and Br) after scaling.
The following equations are used for the conversion.
Points A and B can define a line with either a positive or negative slope. Using a negative slope enables
reverse scaling.
The result will be rounded to the nearest integer. If the result is less than 0000, 0000 will be output as
the result.
If the result is greater than 9999, 9999 will be output.
Hint
SCL(194) can be used to scale the results of analog signal conversion values from Analog Input
Units according to user-defined scale parameters. For example, if a 1 to 5-V input to an Analog Input
Unit is input to memory as 0000 to 0FA0 hexadecimal, the value in memory can be scaled to 50 to
200°C using SCL(194).
SCL(194) converts unsigned binary to unsigned BCD. To convert a negative value, it will be neces-
sary to first add the maximum negative value in the program before using SCL(194) (see example).
SCL(194) cannot output a negative value to the result word, R. If the result is a negative value, 0000
will be output to R.
Name Label Operation
Error Flag P_ER ON if the contents of P1 (Ar) or P1+1 (Br) is not BCD.
ON if the contents of P1+1 (As) and P1+3 (Bs) are equal.
OFF in all other cases.
Equals Flag P_EQ ON if the result is 0.
OFF in all other cases.
× BCD conversion of (Bs – S)
(Br – Ar)
R = Bd – BCD conversion of (Bs – As)
P
P1+1
P1+2
P1+3
R (unsigned BCD)
Converted value
Converted value
S (unsigned binary)
Point B
Point A
Ar(BCD)
As(BIN)
Br(BCD)
Bs(BIN)
As
Br
Ar
Bs
Scaling is performed according to
the linear function defined by points
A and B.