Omron SYSMAC CVM1 Series Operation Manual page 265

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

Advertisement

BCD Calculation Instructions
Example
The following example shows how to use DIVL(77) to calculate the average of
100 four-digit numbers. These numbers are added and divided using the long
versions of the instructions so that the answer can be rounded to preserve accu-
racy. This example illustrates not only the use of DIVL(77), but also the use of
several other instructions and the use of indirect addressing.
The following words and bits are used in this program.
Bit/word
CIO 000000
D00101 and D00102
D00000
A50005 through A50007
(Less Than, Equals, and
Greater Than Flags)
CIO 0200 and 0201
D00103 through D00105
CIO 0010 through CIO 0012
When CIO 000000 is ON in the following example, the first two lines in the pro-
gram clear words used in the remainder of the program. The remainder of the
instruction block from CMP(020) adds consecutive numbers indirectly ad-
dressed through D00000. The numbers are moved to CIO 0200 so that long
addition is possible (CIO 0201 is always zero).
When 100 numbers have been added, the CMP(020) instructions end the addi-
tion and start the division, rounding, and output procedure. The result is rounded
by incrementing D00103 when the remainder from the division is greater than
0049. Finally, XFER(040) is used to places the results in I/O words for output to
an external device, e.g., a display device.
Application
Controls execution of the program.
Hold the result of the addition.
Points to the next word to be added.
Control execution in combination with CMP(020) to
end addition and initiate division when the 100th
number has been added and to add 1 when rounding
up the result is required.
Hold the next values to be added.
Hold the results of division (D00105 is remainder).
CIO 0012 outputs the average and CIO 0010 and
0011 output the sum of the 100 numbers.
Section 5-18
247

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sysmac cv seriesSysmac cvm1d series

Table of Contents