Omron SYSMAC CVM1 Series Operation Manual page 258

Duplex system
Hide thumbs Also See for SYSMAC CVM1 Series:
Table of Contents

Advertisement

BCD Calculation Instructions
Example
0000
TR0
02
A500
04(CY)
A500
04(CY)
0021
00
240
Note Be sure to clear the carry flag with CLC(079) before executing SUB(071) if its
previous status is not required, and check the status of CY after doing a subtrac-
tion with SUB(071). If CY is ON as a result of executing SUB(071) (i.e., if the re-
sult is negative), the result is output as the 10's complement of the true answer.
To convert the output result to the true value, subtract the value in R from 0.
When CIO 000002 is ON in the following example, the following ladder program
clears CY, subtracts the contents of D00100 and CY from the content of
CIO 0010, and places the result in CIO 0200.
If CY is set by executing SUB(071), the result in CIO 0200 is subtracted from
zero (note that CLC(079) is again required to obtain an accurate result), the re-
sult is placed back in CIO 0200, and CIO 002100 is turned ON to indicate a neg-
ative result.
If CY is not set by executing SUB(071), the result is positive, the second subtrac-
tion is not performed, and CIO 002100 is not turned ON. CIO 002100 is pro-
grammed as a self-maintaining bit so that a change in the status of CY will not
turn it OFF when the program is re-scanned.
In this example, differentiated forms of SUB(071) are used so that the subtrac-
tion operation is performed only once each time CIO 000002 turns ON. When
another subtraction operation is to be performed, CIO 000002 will need to be
turned OFF for at least one scan (resetting CIO 002100) and then turned back
ON.
(071)
SUB
0010
D00100
(071)
SUB
#0000
0200
The first and second subtractions for this diagram are shown below using exam-
ple data for CIO 0010 and D00100.
Note
The actual SUB(071) operation involves subtracting Su and CY from 10,000
plus Mi. For positive results the leftmost digit is truncated. For negative re-
sults the 10s complement is obtained. The procedure for establishing the cor-
rect answer is given below.
First Subtraction
CIO 0010
D00100
CY
CIO 0200
CY
(079)
CLC
First
subtraction
0200
(079)
CLC
Second
subtraction
0200
0021
00
Turned ON to
indicate nega-
tive result.
1029
– 3452
– 0
7577
(1029 + (10000 – 3452))
1
(negative result)
Section 5-18
Address Instruction
Operands
00000
LD
000002
00001
OUT
00002
CLC(079)
00003
SUB(071)
D00100
00004
AND
A50004
00005
CLC(079)
00006
SUB(071)
#0000
00007
LD
00008
AND
A50004
00009
OR
002100
00010
OUT
002100
TR0
0010
0200
0200
0200
TR0

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sysmac cv seriesSysmac cvm1d series

Table of Contents