S5-100U Introduction to STEP 5
You can use the “LC” operation to convert a binary number to a BCD number for timers and
counters.
Example: Comparing a count in counter 1 with decimal number 499
The comparison value must be stored in the accunulator by means of a load
operation. Use the “LKF + 499” statement so that you do not have to convert the
value 499 into other numerical systems (binary or hexadecimal) for the input. The
number 1F3
H
is then stored in the accumulator.
The current count must also be loaded into the accumulator.
L KF+499L KF+499
0 0 0 0 0 0 0 1
1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 1
0 0 0 0 0 1 0 0
1 0 0 1 1 0 0 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 1
LC C 1 L C 1
Incorrect Method:
If you use the “LCC1”
statement, the current count will
be loaded in BCD. The “!=F”
comparison operation results in
a “not equal to” condition since
the comparison uses different
formats.
Correct Method:
The formats are identical if the
“LC1” statement is input.
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
High Byte
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
Low Byte
EWA 4NEB 812 6120-02
7-33