COP (copy)

Copies the binary data in the source element to the destination element. The source element remains unchanged.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the L20E, L50E, and L70E controllers.
COP
COP
COP parameters
Parameter
Parameter Type
Data Type
Description
Enable
Input
BOOL
Instruction block enable. COP is level triggered.
  • TRUE: Perform copy.
  • FALSE: The function block is idle.
Src
Input
BOOL
SINT
USINT
BYTE
INT
UINT
WORD
DINT
UDINT
DWORD
REAL
TIME
DATE
STRING
LWORD
ULINT
LINT
LREAL
The source element for copying, one-dimensional array or non-array.
If the source is a STRING data type the destination must be a either a STRING data type or a USINT (UCHAR and BYTE) data type. If it is not, a data type mismatch is reported.
SrcOffset
Input
UINT
The input parameter that defines the starting point of a one-dimensional array within the source data to start the copying process.
Set the offset to 0:
  • If it is not an array data type, or
  • To copy from the first element for a one-dimensional array data type.
Dest
Input
BOOL
SINT
USINT
BYTE
INT
UINT
WORD
DINT
UDINT
DWORD
REAL
TIME
DATE
STRING
LWORD
ULINT
LINT
The destination element to store the copied value from the one-dimensional array or non-array source element.
If the destination is a STRING data type, the source must be either a STRING data type or a USINT (UCHAR and BYTE) data type. If it is not, a data type mismatch is reported.
DestOffset
Input
UINT
The input parameter that defines the starting point within the destination data to store the copied elements.
Set the offset to 0:
  • If it is not an array data type, or
  • To copy from the first element for a one-dimensional array data type.
Length
Input
UINT
The number of destination elements to copy.
When the destination is a STRING data type, it indicates the number of strings to be copied.
Swap
Input
BOOL
Byte-swapping happens before extracting and manipulating high and low 8-bit parameters
  • With Swap enabled, the byte order is reversed before the high and low bytes are processed. For instance, a 16-bit value like 0x1234, with high byte 0x12 and low byte 0x34, would have its byte order reversed to 0x3412.
  • With Swap disabled, the high and low bytes remain in their original order. For instance, in a 16-bit value like 0xABCD, where the high byte is 0xAB and the low byte is 0xCD, the byte order stays the same.
A swap operation does not occur if:
  • The source data type or the destination data type is a STRING, or
  • Both the source and the destination are 1-byte length data.
Sts
Output
UINT
Status of the copy operation. The definitions for the Sts parameter are defined in COP status codes.
ENO
Output
BOOL
Enables output.
Applies only to ladder diagram programs.
COP status codes (Sts)
COP Status code
Status description
0x00
No action taken (not enabled).
0x01
COP function block success.
0x02
Destination has spare bytes when copying from String.
0x03
Source data are truncated.
0x04
Copy length is invalid.
0x05
Data type mismatch when there is String Data type as either source or destination.
0x06
Source data size is too small for copy.
0x07
Destination data size is too small for copy.
0x08
Source Data offset is invalid.
0x09
Destination Data offset is invalid.
0x0A
Data is invalid in either source or destination.

COP examples

COP function block diagram example
COP function block diagram example
COP ladder diagram example
COP ladder diagram example
COP structured text example
COP structured text example
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal