Technical Article

PLC Program Commands: Move and Copy Instructions

July 28, 2022 by Jon Peterson

Moving data is a critical function of PLCs. In this article, we’ll talk about Move, Masked Move, Copy File, and Synchronous Copy File and show how they can be used to move individual pieces of data and entire arrays. 

See our previous articles covering PLC programming commands:



Up and Down Counters

Math Instructions

Trigonometry Instructions

Comparison Instructions


The Function of MOV and COP Style Instructions 

Moving and Copying instructions are designed to provide the user with an easy method to move data from one location to another. The Move (MOV) and Masked Move (MVM) instructions are designed to move individual pieces of data—a single REAL to a single REAL or a single INT to a single INT. The Copy File (COP) and Synchronous Copy File (CPS) are designed to move and manipulate entire arrays

The two families of instructions, Moves and Copies, work together to fill the needs of data transportation. Some are heavier weight, meaning they take far more processor time, while some are much lighter weight but with added limitations. We’ll talk about MOV, MVM, COP, and CPS and show how they can be used.


Data Handling Real-World Examples

All Examples Illustrate Rockwell Automation RSLogix 5000 / Studio 5000 Logix Designer

It’s not hard to find a reason to need data handling instructions. Right off the bat, we can turn to the need for data acquisition and effective data storage. Need to store the length of a board? Put it in an array. Need to store the number of pieces-per-minute for the previous hour? We can do that too! Let’s build a case study that can demonstrate the instructions. 

The operations manager needs you to store the last 20 measurements that went through a machine out in the factory. They need to be stored in an array for easy access from the operator’s touchscreen interface. Let’s look at the instructions and then build a piece of code that will work for the ops manager.  


Using the Move (MOV) Instruction

One of Rockwell Automation’s most basic ways of transferring data from place to place is by using the MOV instruction. As a rule of thumb, if you need to move a single piece of data, use a MOV. If you are using older controllers such as the CompactLogix 5370 or ControlLogix 5570, you can only move a SINT, INT, DINT, and REAL. If you are using anything newer, you can move a vast array of data types. Take a look at your help menu when using the instruction and you can get a full list.

In the logic I put together below, you can see a trigger that has a one-shot in front of it that moves the data from an input card into the CurrentMeasurement bit. If the entire input card is being used to generate the measurement, then this will work perfectly. 

But what if we are only using a few bits out of the 16 bits available? For that, we need a different instruction. The Masked Move.


putting trigger with a one-shot in front of the MOV instruction

Figure 1. By putting a trigger with a one-shot in front of the MOV instruction, the data from an input card moves into the CurrentMeasurement bit.


Using the Masked Move (MVM) Instruction

A MVM acts just like its name describes. It moves data that flows through the mask. But how does a mask work? 

To try and describe it, I’ve made two different pictures. Figure 2 shows an integer of data from an input card without a mask. I listed the input number, the binary value of each, and the resulting decimal value. This can all be seen in the tag monitor in Studio 5000. 


Integer of data from an input card without a mask

Figure 2. Integer of data from an input card without a mask.

Now let’s look at the same integer of data through a mask. If you think about wearing a halloween mask, you naturally have holes in it to see through. A data mask works the same way; it allows you to see through some holes and view the data on the other side. If a mask has a 1 in the bit, we can look through it to see if there is a 1 or a 0. If there is a 1 on the other side, we set the bit true. If there is a 0 on the other side of the mask, we leave the bit 0. 

Another way some people might better understand this is if we turned every pair of bits into an AND gate. 


1 AND 1 get you a 1. 

1 AND 0 get you a 0. 

0 AND 1 get you a 0.


Now let’s look at a piece of data through a mask in Figure 3.


Integer of data from an input card with a mask

Figure 3. Integer of data from an input card with a mask.


To make it a little more clear I’ve made the same set of data with color coding in Figure 4. 


integer of data from an input card with a mask

Figure 4. Integer of data from an input card with a mask. Notice that ‘1’ and ‘1’ result in ‘0’, but both ‘0’ and ‘1’ and ‘1’ and ‘0’ result in ‘0’.


If we had to measure the length of something with inputs 0, 2, and 3, we can pick and choose the bits we need with a mask. The mask is entered as a decimal number, so you will have to calculate the binary to decimal values. To do this, I always create an INT in the program and manually toggle the bits for my mask and then copy the resulting number in the tag monitor to ensure I get my value right.

The way we set up the instruction for use in the logic is similar to the standard MOV—we just need to add the mask in the middle.


MVM is similar to MOV but includes 'Mask' in between 'Source' and 'Dest'

Figure 5. MVM is set up similar to MOV but includes ‘Mask’ in between ‘Source’ and ‘Dest.’


Using the Copy File (COP) Instruction

Ready for something simpler? I sure am. The COP instruction is akin to the Move instruction, but we use it for arrays. You might recall earlier I mentioned that if you need to move a single piece of data, use the Move. If you need to move a huge array, use a Copy File. The way Rockwell does this is by selecting a start point of the source array, a start point of the destination array, and a length of the array you're taking.

Let’s say you have three, 20 INT, arrays that you need to compile into a single array. You might have SourceArray1[0] move into DestinationArray[0], with a length of 20. Then you can move SourceArray[2] into DestinationArray[20] with a length of 20. Then finish up with SourceArray[3] moving into DestinationArray[40] with another length of 20. Using a Copy File will allow arrays to be moved and compiled in a variety of ways. 

Below is an example of how to use the COP instruction in logic. It’s fairly simple. The important thing is to remember your one-shots. We generally don’t want heavyweight instructions like COPs to run on every scan. Lower speed controllers will end up with longer scan times because of this.



The COP instruction is used for arrays instead of individual pieces of data

Figure 6. The COP instruction is used for arrays instead of individual pieces of data and requires the length of the array you’re taking.


Using the Synchronous Copy File (CPS) Instruction

The CPS instruction is very similar to the COP. You’ll even notice there is no visual difference in the tags. The difference between the COP and the CPS is that a COP instruction can have its array manipulated while performing a copy. The CPS instruction locks down the array and puts any manipulations to that array on hold until it is done. This can be required if you are moving arrays around that are long and must stay in perfect order. 

Be aware that the good part of the CPS instruction can also be the bad part. It can put important stuff on hold for many microseconds while it is finishing. This can cause very random problems or seemingly unexplainable problems. Scan time issues are some of the hardest to figure out. 

Below I have drawn up another logic picture showing how to use this instruction. It is visually identical to the COP instruction. 


CPS instruction is similar to the COP

Figure 7. The CPS instruction is like the COP instruction with the difference being when an array can be manipulated. In a COP instruction, an array can be manipulated during a copy. In a CPS instruction, manipulations to an array do not take place until after the copy is done.


Data Handling in PLC Programming

Moving data is a critical function of PLCs. Get to know how your PLC moves data and always be aware of scan time problems when moving big blocks of arrays. Don’t forget to use your help data, especially in Studio 5000! 

Until next time, keep learning! 


Want to test your knowledge of PLCs? You think you N.O. a lot about ladder logic? Are you a normally-open or normally-closed minded engineer?

Check out our PLC Programming worksheet!

Featured image modified and used courtesy of Elmschrat Coaching-Blog
  • L
    LivB99 September 25, 2023

    I am getting the decimal value for Figure 2 as 48524. Can you explain the steps you took to get 12733? Thank you

    Like. Reply
    • D
      David Peterson September 25, 2023
      It looks like the way he wrote the binary number is with the lowest bit on the left, not on the right like it appears in most PLC environments. I just made an INT and filled it with those bits, starting with .0 on the left and going to .15 on the right, and the value does come out to 12733. If you fill the INT in right to left order, it's the 48524 that you got in your test.
      Like. Reply