RSLogix CPS/COP providing unexpected results

Pete_S

Member
Join Date
Mar 2015
Location
Portland Maine
Posts
76
Hello All,

My understanding from the RSLogix help file is that copy functions (COP & CPS) will perform a bit by bit copy from one memory location to another, with no consideration of data type (IE a COP/CPS of a Float to a DINT will produce garbage). The only difference between the 2 functions is the CPS will interrupt the scan until the function completes where the COP function will run in parallel with current scan. So I was very confused when I attempted to use a CPS(and COP just for s&g) to copy a float tag (with value of 0.0)into all elements of a float array and saw results shown in attached screen capture. I have no other logic operating on these tags so I would have expected both functions to write the exact value of the source of the function into the destination of the function. Can someone please tell me what I am missing? Thanks

Rockwell Automation PLC Config Legacy PKS-2015-10-22-15-35-01.png
 
...I was very confused when I attempted to use a CPS(and COP just for s&g) to copy a float tag (with value of 0.0)into all elements of a float array and saw results shown in attached screen capture....

The instruction you are actually looking for is a File fiLL instruction (FLL). Per the instruction help file: The FLL instruction fills elements of an array with the Source value. The Source remains unchanged.

My guess is that the value of Actual[0] is 0.0, right? The reason why you have seemingly random data in the other array elements is because the COP instruction copied the other 49 * 4 bytes of contiguous data following the "zero" tag in processor memory and placed them in the other 49 array elements.

The COP & CPS instructions are very useful, just not in this particular instance.
 
Post a better screen shot or perhaps two - the image is too small to read.

COP instructions can be interrupted by other tasks or IO updates which may cause inconsistent data in the destination.

CPS instructions will not be interrupted by other tasks or IO updates so the destination data is consistent.
 
The instruction you are actually looking for is a File fiLL instruction (FLL). Per the instruction help file: The FLL instruction fills elements of an array with the Source value. The Source remains unchanged.

My guess is that the value of Actual[0] is 0.0, right? The reason why you have seemingly random data in the other array elements is because the COP instruction copied the other 49 * 4 bytes of contiguous data following the "zero" tag in processor memory and placed them in the other 49 array elements.

The COP & CPS instructions are very useful, just not in this particular instance.

Giddy up, that was it thanks! I had assumed that the length was in reference to the destination, not the source per this verbage in instruction help:

Length
DINT
immediate

tag
number of Destination elements to copy


Is there a way to see what is in "undefined" contiguous memory in RSLogix?
 
Last edited:
I had assumed that the length was in reference to the destination, not the source.
Your assumption is correct. COP & CPS instructions look at the number of bytes contained within the Destination tag data type, multiply by the length and then copy that many contiguous bytes from the source. Where folks have gotten into trouble is when the Source & Destination data types differ. Gotta be careful!

Your issue centered on the desire to duplicate the same 4 bytes of data 50 times over, not copy & paste 200 consecutive bytes!

Is there a way to see what is in "undefined" contiguous memory in RSLogix?
That's above my pay grade. I'm sure someone around here may know that answer, but not me!
 
Hello All,

My understanding from the RSLogix help file is that copy functions (COP & CPS) will perform a bit by bit copy from one memory location to another, with no consideration of data type (IE a COP/CPS of a Float to a DINT will produce garbage). The only difference between the 2 functions is the CPS will interrupt the scan until the function completes where the COP function will run in parallel with current scan.

Some clarification of the difference between COP and CPS. The COP instruction may be interrupted partway thru execution by higher priority tasks. Once the CPS instruction begins execution, it will not be interrupted until it is complete. There are no true parallel operations in a ControlLogix, it time slices. If you only have one continuous task, it still gets interrupted by overhead/communications. Actually it gets interrupted quite a bit.
 
Some clarification of the difference between COP and CPS. The COP instruction may be interrupted partway thru execution by higher priority tasks. Once the CPS instruction begins execution, it will not be interrupted until it is complete. There are no true parallel operations in a ControlLogix, it time slices. If you only have one continuous task, it still gets interrupted by overhead/communications. Actually it gets interrupted quite a bit.
HI mellis,
Thanks for the clarification. When I mentioned parallel operations I was referencing the ability of the source and destination of the COP to change in subsequent logic before the function completes.
What communications have the ability to interrupt a continuous task (CIP,DDE, secret)? Is there buffering involved in the CPS to protect the source/destination from changing due to communication interrupting a task?
 
HI mellis,
Thanks for the clarification. When I mentioned parallel operations I was referencing the ability of the source and destination of the COP to change in subsequent logic before the function completes.

You are missing the point... all instructions will complete before subsequent logic is executed. But that doesn't mean they can't be "interrupted" in their execution by a higher-priority task or machine function.... CPS provides the functionality of suspending interrupt processing while it executes to completion, thus guaranteeing the validity of the data-set it is copying to and from..


What communications have the ability to interrupt a continuous task (CIP,DDE, secret)? Is there buffering involved in the CPS to protect the source/destination from changing due to communication interrupting a task?

Since the Continuous task has, by design, the lowest priority, and it can't be changed, then all communications can interrupt the continuous task, including I/O exchange. There is no buffering involved when the CPS instruction executes, but because it suspends interrupt handling, and the System Overhead Time-Slice (during which communications with other devices and I/O data is updated) during its execution, then nothing can change the source or destination data while it executes.
 
You are missing the point... all instructions will complete before subsequent logic is executed. But that doesn't mean they can't be "interrupted" in their execution by a higher-priority task or machine function.... CPS provides the functionality of suspending interrupt processing while it executes to completion, thus guaranteeing the validity of the data-set it is copying to and from..

daba,

Thanks for the clarification.
 

Similar Topics

So I'm trying to do some arithmetic with arrays of DINTs. However, I'm running into a problem. I’m trying to create a copy of let’s call it...
Replies
2
Views
6,346
Hi, I wish to verify the CPS instruction using RSLogix 5000 v20 on Controllogix PLC. Is there any method i could do this and generate a...
Replies
1
Views
4,262
I'm new here to PLCs and to this board and I ran into a situation yesterday that I couldn't find an explaination for, so I hope someone out there...
Replies
2
Views
3,188
Hello, I am trying to read a barcode scanner input using a cognex dataman 280 barcode reader, store it another string, the compare with another...
Replies
1
Views
71
Hi Everyone, I am not proficient in RSLogix 500 so I have a question regarding the evaluation of N7:0 data as an input. So as I understand in...
Replies
1
Views
108
Back
Top Bottom