Data Manipulation Instructions Chapter 10 201
can be placed in two broad categories: data transfer and
data comparison.
The manipulation of entire words is an important fea-
ture of a programmable controller. This feature enables
PLCs to handle inputs and outputs containing multiple bit
con gurations such as analog inputs and outputs. Arith-
metic functions also require data within the programma-
ble controller to be handled in word or register format.
To simplify the explanation of the various data manipula-
tion instructions available, the instruction protocol for the
Allen-Bradley SLC 500 families of PLCs will be used.
Again, even though the format and instructions vary with
each manufacturer, the concepts of data manipulation re-
main the same.
Figure10-2 shows the Move/Logical menu tab for the
SLC 500 PLC and its associated RSLogix software. The
commands can be summarized as follows:
MOV (Move) —Moves the source value to the
destination.
MVM (Masked Move) —Moves data from a source
location to a selected portion of the destination.
AND (And) —Performs a bitwise AND operation.
OR (Or) —Performs a bitwise OR operation.
XOR (Exclusive Or) —Performs a bitwise XOR
operation.
NOT (Not) —Performs a bitwise NOT operation.
CLR (Clear) —Sets all bits of a word to zero.
10.2 Data Transfer Operations
Data transfer instructions simply involve the transfer of
the contents from one word or register to another. Fig-
ure10-3 a and b illustrate the concept of moving numeri-
cal binary data from one memory location to another.
Figure10-3 a shows the original data are in register N7:30
and N7:20. Figure10-3 b shows that after the data trans-
fer has occurred register N7:20 now holds a duplicate of
the information that is in register N7:30. The previously
existing data stored in register N7:20 have been replaced
with those of N7:30. This process is referred to as writing
over the existing data.
10.1 Data Manipulation
Data manipulation instructions allow numerical data
stored in the controller’s memory to be operated on within
the control program. This category of word operation in-
structions allows the user to truly exploit the computer
capabilities of the PLC.
The use of data manipulation extends a controller’s ca-
pability from that of simple on/off control based on bi-
nary logic, to quantitative decision making involving data
comparisons, arithmetic, and conversions—which in turn
can be applied to analog and positioning control.
There are two basic classes of instructions to accom-
plish data manipulation: instructions that operate on word
data and those that operate on le, or block, data, which
involve multiple words.
Each data manipulation instruction requires two or
more words of data memory for operation. The words of
data memory in singular form may be referred to either
as registers or as words, depending on the manufacturer.
The terms table or l e are generally used when a consecu-
tive group of related data memory words is referenced.
Figure10-1 illustrates the difference between a word and
a le. The data contained in les and words will be in
the form of binary bits represented as series of 1s and 0s.
A group of consecutive elements or words in an Allen-
Bradley SLC 500 are referred to as a le.
The data manipulation instructions allow the move-
ment, manipulation, or storage of data in either single- or
multiple-word groups from one data memory area of the
PLC to another. Use of these PLC instructions in applica-
tions that require the generation and manipulation of large
quantities of data greatly reduces the complexity and
quantity of the programming required. Data manipulation
Figure 10-1 Data fi les, words, and bits.
1
1
0
1
1
0
0
1
0
1
1
1
0
0
0
0
1
1
0
0
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
0
0
1
1
1
1
1
0
1
0
1
0
1
1
1
0
1
0
1
0
1
1
1
0
0
0
0
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
0
0
0
0
1
0
1
1
1
1
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
0
1
0
1
0
1
0
1
0
0
1
1
1
1
0
1
1101101110101011
Binary bit
Word or
register
File or
table
Section of
memory map
Figure 10-2 Move/Logical menu tab.
MOV MVM AND OR XOR NOT
Move/LogicalCompare Compute/Math
CLR
File/Misc
pet10882_ch10_200-225.indd 201pet10882_ch10_200-225.indd 201 7/27/10 10:45 PM7/27/10 10:45 PM