Bcd Subtract - Sub(31) - Omron SYSMAC C20P Operation Manual

Sysmac programmable controllers
Hide thumbs Also See for SYSMAC C20P:
Table of Contents

Advertisement

BCD Calculations
5–16–2 BCD Subtract – SUB(31)
Description
Flags
Caution
Example
92
If a carry is generated, SR 1904 (CY) is turned ON and the constant 0001 is
transferred to DM 06. If a carry is not generated SR 1904 remains OFF and
the constant 0000 is transferred to DM 06.
Ladder Symbol
SUB(31)
Mi
Su
R
When the execution condition is OFF, SUB(31) is not executed and the next
instruction is moved to. When the execution condition is ON, SUB(31) sub-
tracts the contents of Su and CY from Mi and places the result in R. If the
result is negative, CY is set and the 10's complement of the actual result is
placed in R. To convert the 10's complement to the true result, subtract the
content of R from zero (see example below).. This instruction will be ex-
ecuted every scan as long as the execution condition remains ON. If the in-
struction is to be executed only once then it must be used in conjunction with
DIFU(13) or DIFD(14).
Mi – Su – CY
ER:
Mi and/or Su is not BCD.
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 (CY) with CLC(41) before executing SUB(31)
if its previous 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 convert the output result to the true value, subtract the value
in R from 0.
When 0002 is ON, the following diagram clears CY, subtracts the contents of
DM 01 and CY from the content of IR 10 and places the result in HR 2.
If CY is set by executing SUB(31), the result in HR 2 is subtracted from zero
(note that CLC(41) is again required to obtain an accurate result), the result
is placed back in HR 2, and HR 300 is turned ON to indicate a negative re-
sult.
If CY is not set by executing SUB(31), the result is positive, the second sub-
traction is not performed and HR 300 is not turned ON. HR 300 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 rescanned.
Section 5–16
Operand Data Areas
Mi : Minuend word (BCD)
IR, SR, DM, HR, TC, #
Su : Subtrahend word (BCD)
IR, SR, DM, HR, TC, #
R : Result word
IR, DM, HR
CY
R

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sysmac c28pSysmac c40pSysmac c60p

Table of Contents