Omron C200HX Operation Manual page 250

Hide thumbs Also See for C200HX:
Table of Contents

Advertisement

BCD Calculations
Flags
Caution
!
Example
TR 0
00002
25504
25504
HR 2100
232
ER:
Mi and/or Su is not BCD.
Indirectly addressed DM word is non-existent. (Content of DM word is
not BCD, or the DM area boundary has been exceeded.)
CY:
ON when the result is negative, i.e., when Mi is less than Su plus CY.
EQ:
ON when the result is 0.
Be sure to clear the carry flag with CLC(41) before executing SUB(31) if its pre-
vious status is not required, and check the status of CY after doing a subtraction
with SUB(31). If CY is ON as a result of executing SUB(31) (i.e., if the result is
negative), the result is output as the 10's complement of the true answer. To con-
vert the output result to the true value, subtract the value in R from 0.
When 00002 is ON, the following ladder program clears CY, subtracts the con-
tents of DM 0100 and CY from the content of 010 and places the result in HR 20.
If CY is set by executing SUB(31), the result in HR 20 is subtracted from zero
(note that CLC(41) is again required to obtain an accurate result), the result is
placed back in HR 20, and HR 2100 is turned ON to indicate a negative result.
If CY is not set by executing SUB(31), the result is positive, the second subtrac-
tion is not performed, and HR 2100 is not turned ON. HR 2100 is programmed as
a self-maintaining bit so that a change in the status of CY will not turn it OFF
when the program is recycled.
In this example, differentiated forms of SUB(31) are used so that the subtraction
operation is performed only once each time 00002 is turned ON. When another
subtraction operation is to be performed, 00002 will need to be turned OFF for at
least one cycle (resetting HR 2100) and then turned back ON.
CLC(41)
@SUB(31)
First
subtraction
010
DM 0100
HR 20
CLC(41)
@SUB(31)
Second
subtraction
#0000
HR 20
HR 20
HR 2100
Turned ON to indicate
negative result.
The first and second subtractions for this diagram are shown below using exam-
ple data for 010 and DM 0100.
Section 5-19
Address Instruction
Operands
00000
LD
00001
OUT
TR
00002
CLC(41)
00003
@SUB(31)
DM
HR
00004
AND
00005
CLC(41)
00006
@SUB(31)
#
HR
HR
00007
LD
TR
00008
AND
00009
OR
HR
00010
OUT
HR
00002
0
010
0100
20
25504
0000
20
20
0
25504
2100
2100

Advertisement

Table of Contents
loading

This manual is also suitable for:

C200hgC200he

Table of Contents