Copy (COP) - Synchronous Copy (CPS)

This information applies to the
CompactLogix
5370,
ControlLogix
5570,
Compact GuardLogix
5370,
GuardLogix
5570,
CompactLogix
5380,
CompactLogix
5480, and
ControlLogix
5580 controllers. Controller differences are noted where applicable.
The COP and CPS instructions copy the value(s) in the Source to the values in the Dest. The Source remains unchanged.
Available Languages
Ladder Diagram
RSL5K_CPS Ladder Diagram_v31
RSL5K_CPS Ladder Diagram 2_v31
Function Block
This instruction is not available in function block.
Structured Text
COP(Source,Dest,Length);
CPS(Source,Dest,Length);
Operands
IMPORTANT:
Unexpected operation may occur if:
  • Output tag operands are overwritten.
  • Members of a structure operand are overwritten.
  • Except when specified, structure operands are shared by multiple instructions.
Ladder Diagram
Operand
CompactLogix
5370,
ControlLogix
5570,
Compact GuardLogix
5370, and
GuardLogix
5570 controllers
Data Type
CompactLogix
5380,
CompactLogix
5480,
ControlLogix
5580,
Compact GuardLogix
5380, and
GuardLogix
5580 controllers
Data Type
Format
Description
Source
SINT
INT
DINT
LINT
REAL
String type
structure
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
REAL
LREAL
String type
structure
tag
Initial element to copy.
For controllers that support the REF_TO motion data types, the supported axis operand type can be replaced by an equivalent REF_TO type. The Reference (REF) Instruction associates a reference with an axis or coordinate system concrete tag.
Dest
SINT
INT
DINT
LINT
REAL
String type
structure
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
REAL
LREAL
String type
structure
tag
Initial element to be overwritten by the Source
Length
SINT
INT
DINT
SINT
INT
DINT
immediate
tag
Number of Destination elements to copy
Structured Text
Operand
CompactLogix
5370,
ControlLogix
5570,
Compact GuardLogix
5370, and
GuardLogix
5570 controllers
Data Type
CompactLogix
5380,
CompactLogix
5480,
ControlLogix
5580,
Compact GuardLogix
5380, and
GuardLogix
5580 controllers
Data Type
Format
Description
Source
SINT
INT
DINT
LINT
REAL
String type
structure
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
REAL
LREAL
String type
structure
REF_TO_AXIS_VIRTUAL
REF_TO_AXIS_CONSUMED
REF_TO_AXIS_GENERIC_DRIVE
REF_TO_AXIS_SERVO
REF_TO_AXIS_SERVO_DRIVE
REF_TO_AXIS_CIP_DRIVE
tag
Initial element to copy
Dest
SINT
INT
DINT
LINT
REAL
String type
structure
SINT
INT
DINT
LINT
USINT
UINT
UDINT
ULINT
REAL
LREAL
String type
structure
tag
Initial element to be overwritten by the Source
Length
SINT
INT
DINT
SINT
INT
DINT
immediate
tag
Number of Destination elements to copy
See
Structured Text Syntax
for more information on the syntax of expressions within structured text.
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. See
Index Through Arrays
for array-indexing faults.
Execution
Ladder Diagram
Condition/State
Action Taken
Prescan
N/A
Rung-condition-in is false
Set Rung-condition-out to Rung-condition-in.
Rung-condition-in is true
Set Rung-condition-out to Rung-condition-in.
The instruction copies the data.
Postscan
N/A
Structured Text
Condition/State
Action Taken
Prescan
See Prescan in the Ladder Diagram table
Normal execution
See Rung-condition-in is true in Ladder Diagram table.
Postscan
See Postscan in the Ladder Diagram table.
During execution of the COP and CPS instructions, other controller actions may try to interrupt the copy operation and change the source:
If the source or destination is:
And need to:
Then select:
Notes
  • produced tag
  • consumed tag
  • I/O data
  • data that another task can overwrite
  • non-atomic tag that is written to by a remote device
Prevent the source data from changing during the copy operation
CPS
Tasks that attempt to interrupt a CPS instruction are delayed until the instruction is done.
To estimate the execution time of the CPS instruction, refer to the
ControlLogix
System User Manual, publication 1756-UM001.
Use interlock application code to ensure a remote client is not updating the source while the CPS instruction is executing.
Allow the source data to change during the copy operation
COP
None of the above
--------------->
COP
The COP and CPS instructions operate on contiguous memory and perform a straight byte-to-byte memory copy.
When the Source and Dest are different data types the number of bytes copied equals the smaller of:
  • Requested amount equals Length x (the number of bytes in a destination element)
  • The number of bytes in the destination tag
  • For
    Compact GuardLogix
    5380,
    CompactLogix
    5380,
    CompactLogix
    5480,
    ControlLogix
    5580, or
    GuardLogix
    5580 controller
    s: the number of bytes in the source tag
    TIP:
    The end of the destination or source tag is defined as the last byte of the base tag. If the tag is a structure, the end of the tag is the last byte of the last element of the structure. This means the COP and CPS instruction could write past the end of a member array but will never write past the end of the base tag.
IMPORTANT:
Test and confirm that the instruction does not change data that it should not change.
Examples
Example 1
Copy an array.
When enabled, the COP instruction copies 40 bytes from array_4 to array_5.
array_4 is a DINT (4 bytes per element) and contains 10 elements (total size = 40 bytes)
array_5 is a DINT (4 bytes per element) and contains 10 elements (total size = 40 bytes).
The Length says 10 destination elements should be copied so 40 bytes are copied.
Ladder Diagram
RSL5K_COP and CPS Ladder Diagram Example 1_v31
Structured Text
COP(array_4[0],array_5[0],10);
Example 2
Copy a structure.
When enabled, the COP instruction copies the structure timer_1 into element 5 of array_timer.
timer_1 is a TIMER (total size = 12 bytes).
array_timer is a TIMER (12 bytes per element) and contains 10 elements (total size = 120 bytes).
The Length says 1 destination elements so 12 bytes are copied.
Ladder Diagram
RSL5K_COP and CPS Ladder Diagram Example 2_v31
Structured Text
COP(timer_1,array_timer[5],1);
Example 3
Copy array data while preventing the data from being changed until the copy is complete.
The project_data array (100 elements) stores a variety of values that change at different times in the application. To send a complete image of project_data at one instance in time to another controller, the CPS instruction copies project_data to produced_array. While the CPS instruction copies the data, no I/O updates or other tasks can change the data. The produced_array tag produces the data on a ControlNet network for consumption by other controllers.
project_data is a DINT (4 bytes per element) and contains 100 elements (total size = 400 bytes)
produced_array is a DINT (4 bytes per element) and contains 100 elements (total size = 400 bytes).
The Length says 100 destination elements so 400 bytes are copied.
Ladder Diagram
RSL5K_COP and CPS Ladder Diagram Example 3_v31
Structured Text
CPS(project_data[0],produced_array[0],100);
Example 4
Copy data to a produced tag while preventing the data from being sent until the copy is complete.
Local:0:I.Data stores the input data for the DeviceNet network that is connected to the 1756-DNB module in slot 0. To synchronize the inputs with the application, the CPS instruction copies the input data to input_buffer. While the CPS instruction copies the data, no I/O updates can change the data. As the application executes, it uses for its inputs the input data in input_buffer.
Local:O:I.Data is a DINT (4 bytes per element) and contains 2 elements (total size = 8 bytes)
input_buffer is a DINT (4 bytes per element) and contains 20 elements (total size = 80 bytes).
The Length says 20 destination elements should be copied (4 X 20 = 80 bytes). However the source can only provide 8 bytes so 8 bytes are copied.
Ladder Diagram
RSL5K_COP and CPS Ladder Diagram Example 4_v31
Structured Text
CPS(Local:0:I.Data[0], input_buffer[0], 20);
Example 5
Initialize an array structure, initialize the first element and the use COP to replicate it to the rest of the array.
COP and CPS Example 5
This example initializes an array or timer structures. When enabled, the MOV instructions initialize the .PRE and .ACC values of the first array_timer element. When enabled, the COP instruction copies a contiguous block of bytes, starting at array_timer[0]. The length is nine timer structures.
array_timer is a TIMER (12 bytes per element) and contains 15 elements (total size = 180 bytes)
The Length says 10 destination elements so 120 bytes are copied.
Ladder Diagram
RSL5K_COP and CPS Ladder Diagram Example 5_v31
Structured Text
IF S:FS THEN
array_timer[0].pre := 500;
array_timer[0].acc := 0;
COP(array_timer[0],array_timer[1],10);
END_IF;
Example 6
Copy different sized arrays.
When enabled, the COP instruction copies bytes from SINT array_6 to DNT array_7.
array_6 is a SINT (1 byte per element) and contains 5 elements (total size = 5 bytes)
array_7 is a DINT (4 bytes per element) and contains 10 elements (total size = 40 bytes).
The Length says 20 destination elements should be copied (4 X 20 = 80 bytes). However the dest can only accept 40 bytes and the source can only provide 5 bytes so 5 bytes are copied.
Ladder Diagram
RSL5K_COP and CPS Ladder Diagram Example 1_v31
Structured Text
COP(array_4[0],array_5[0],10);
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.