Many Copy instruction VS 2 copy instructions

Darkzadow

Member
Join Date
Nov 2011
Location
Phily
Posts
94
Hi Forum,

I am shifting an array of 50 UDT so each element is one position lower than it used to be, and the final element is overwritten. I was wondering how the PLC 5000 would handle 49 copy instructions vs 2 large copy instruction(to a temp array and then back). Aside from using extra memory for a temporary array would the copy to temp array be faster slower than the 49 single copies. And any other differences the 2 methods would have.

Thanks
Dz
 
I would use the temp array. I would expect the 49 single copies to be significantly slower, especially depending on how you implement it. Were you thinking of doing a For loop in one single can, or brute force them out? Sometimes these things are more easily answered by making some test code and running it. Have it do each 10 to 100 times in a row to make the timing differences more pronounced.
 
If you are copying down then you should be able to do it with a single copy.

COP MYTAG[1] MYTAG[0] 49

Mytag[1] is copied to Mytag[0]
Mytag[2] is copied to Mytag[1]
.
.
Mytag[49] is copied to Mytag[48]

Oldest data is at Mytag[0] and newest data goes to Mytag[49]


When you copy up as in
COP MYTAG[0] MYTAG[1] 49
then you end up overwriting the array with a copy of MYTAG[0].

If you are concerned about performance use the single copy method and put your newest data at the end of the array instead of at the beginning.
 
I am copying up. :( the overwrite issue was annoying. The single copies are indeed faster. I am not trying to complete in a single scan. just before I insert new data. :) I was wondering if there were any other nuances such as interrupted execution issues, command load and execution time, and memory allocation problems.

I am moving to the single copy cause it is much easier to read, and is faster. I would emulate a queue with a moving start pointer but too many other systems point to the array that I don't have access to.
 
Synchronized Copy

I would suggest using the synchronized Copy (CPS) to make sure the integrity of the data remains. During a CPS the processor cannot interrupt the process until the copy has completed. Otherwise the data could be updated in the middle of the copy and get corrupted.
 
If you are copying down then you should be able to do it with a single copy.

COP MYTAG[1] MYTAG[0] 49

Mytag[1] is copied to Mytag[0]
Mytag[2] is copied to Mytag[1]
.
.
Mytag[49] is copied to Mytag[48]

Oldest data is at Mytag[0] and newest data goes to Mytag[49]


When you copy up as in
COP MYTAG[0] MYTAG[1] 49
then you end up overwriting the array with a copy of MYTAG[0].

If you are concerned about performance use the single copy method and put your newest data at the end of the array instead of at the beginning.

I have actually had cases where copying an array to itself in this manner has resulted in some values being misplaced. I would still recommend copying to a temp array first whether you are going top down or bottom up. In my case the array was about 100 elements and it was often that about 30% of them would not get shifted.
 
If this was being done on a controllogix then the loss of data could have been due to updating of information in the middle of the copy. The CPS instruction is great for preventing that from happening.
 
Since it does not allow the processor to interrupt the copy does that action monopolize the PLC? How does the plc handle actions (IO, MSG instructions) that would happen or be recieved in that time frame?
 
That is correct it will halt other operations from happening such as messaging (which is how the I/O is process with the controllogix processor) and periodic tasks will be delayed. This is a very small amount of time which I have not seen any negative impact on performance.
 

Similar Topics

Good Evening , We have a number of Powerflex 525 Drives . I took notice for years elsewhere and our plant , that our Powerflex 525 drive...
Replies
0
Views
633
Good Afternoon, Just wondering , are many of you using SAP in your plants ? If so , is it difficult to learn ? Are there many training...
Replies
10
Views
1,416
It better to have too many instead of not enough right?
Replies
26
Views
2,860
Hi all- I have an application where: - I have a fixed system with a pre-determined, static, network (say, 192.168.2.0/24). - That system...
Replies
13
Views
4,231
I have an application that needs 20 inputs and 20 outputs with only 10 XNOR and 10 NAND blocks. I could do it with relays, but this could end up...
Replies
16
Views
5,154
Back
Top Bottom