Logix 5000 COPY Function

Join Date
Dec 2021
Location
Pa
Posts
2
I'm writing a new Compact Logix program to replace a PLC-5 program. The PLC-5 program uses the COP function to copy 7 floating point files to 7 other locations. I don't see how to do that with the COP function in Logix 5000 since there aren't necessarily files, but tags. Any suggestions out there? This occurs multiple times in the program.

Thanks
 
the COP instruction works the same in foth PLC5 and Logix
In you Logix program create a new tag of real data type when you create it make it a array
so that tag would be an array of real data type
then copy the Source Tag [ Index ] Destination [ index] number of elements to copy
with the COP instruction the number to copy is always the destination number
 
To expand on Gary's solution just a little...

Arrays in Logix work similarly to data files in the PLC-5. You can create a single dimension array just like creating a tag. In the Dim 0 field enter the size of the array. So if you created an array named Storage with a size of 10 you would have Storage[0], Storage[1], through to Storage[9]. Your COP instruction can access those consecutive elements inside an array.

OG
 
Logix 5000 COPY with an Array

I have tried that but it did not work. I guess I need to explain the application more. I am storing 7 days worth of data. Every midnight, I initiate the copy command via a reset pulse through a single shot instruction. The goal is to move the data in word 0 to word 1, data in word 1 to word 2, etc and at the end, move the current days data into word 0. (Word 0 is "yesterdays data".

This works fine in the PLC 5 moving F registers. When I try to do it in Logix with an array, it places the same value in all of the words.
 
Heh, apparently that is expected behavior cf. Example 5 here:

https://literature.rockwellautomati...re/documents/rm/1756-rm003_-en-p.pdf#page=486

So COP must copy from front to back. Hilarious.

One solution might be to do the shift from back to front i.e. move the value from Array[5] to Array[6], then the value from Array[4] to Array[5], etc., and finally the value from Array[0] to Array[1]. I think you can do that with a single FAL instruction here.

  • Control: Some_Tag
  • Length: 6
  • Position: 0
  • Mode: All
  • Dest: Array[6-Some_Tag.POS]
  • Expression Array[5-Some_Tag.POS]
The FAL instruction executes only on a rising edge of its input rung, so you may also need to unlatch Some_Tag.EN, Some_Tag.DN, and put a 0 in Some_Tag.POS, before each execution if this instruction is ever executed on two consecutive scans, to make it closer to an equivalent of the COP.
 
Last edited:
P.S. You could also create a shadow array of six elements, and then use two COPies:

COP Array_of_7[0] Shadow_Array_of_6[0] 6
COP Shadow_Array_of_6[0] Shadow_Array_of_7[1] 6

 
N.B. the FAL suggestion is closer to a MOVe than a COPy; if the COP was being used in RSLogix 500 because it could process multiple elements in one instruction, then that is probably acceptable.
 
One solution might be to do the shift from back to front i.e. move the value from Array[5] to Array[6], then the value from Array[4] to Array[5], etc., and finally the value from Array[0] to Array[1]. I think you can do that with a single FAL instruction here.
You can just do it with the COP.
Code:
COP Source: Array[6] Dest: Array[5] Length:7

I have done this before when I needed a quick and dirty FIFO and it works.

I'm intrigued to learn that the PLC5 (apparently) copies backward. I wonder where the "line in the sand" is? Does the Micrologix copy forward or backward? What about an SLC?

So back to the OP's question, you can either:

1. Copy your data backward, and have Array[6] be the most recent data and Array[0] the oldest; or
2. Use a FIFO queue with FFL/FFU

The first solution is the quick and easy way, the second is the "doing it properly" way. At least, that's my opinion. I'm sure there are lots more ways to do it and drbitboy has probably already come up with at least seven of them.
 
No, it is criminal.
Meh. Customers are welcome to go with another brand.
It takes little effort ...
True, but "little" is an irrelevant adjective. The issue is that it takes extra effort to do it right, which is why it was not done right. Also, it saves effort (and firmware), because now
FLL A B N


can be implemented as
COP A[0] B[0] COP B[0] B[1] (N-1)


So maybe it wasn't even unintentional and/or lazy and/or incompetent. How else would Rockwell maintain their "You can do it better, but you can't do it costlier" cachet?
 
I'm intrigued to learn that the PLC5 (apparently) copies backward. I wonder where the "line in the sand" is? Does the Micrologix copy forward or backward? What about an SLC?

MicroLogix: forward; see screenshot below (MicroLogix 1100 Series B).
xxx.png
 
MicroLogix: forward

PLC-5 is forward also. Here's why:

When the PLC executes the COP instruction, it copies the value of .POS in the control word the S:24 word -- the one used for indexed addressing.

Then, when executing the COP instruction, it then uses indexed addressing as a one-element-at-a-time copy. That's why the files are prefixed with the '#'. If the instruction were, say, COP F8:0 #F9:0 7, you would be creating a File Fill command, populating everything in F9 with the single value in F8:0.

Thus, for COP #F8:0 #F8:1, the value of F8:0 goes into F8:1, the value of F8:1 (which just came from F8:0) goes into F8:2, etc. Which then also winds up acting just like a FLL (Fill) instead of a FFL (FIFO).

The PLC doesn't allocate memory (unlike a PC) to copy all of F8:0-:6 into a buffer, and then copy from that buffer into the destination, as Peter is suggesting it "should". Those early PLCs had no memory to spare. And if the COP did as Peter suggests, then the instruction COP(ArrayA[0], ArrayB[0]) would copy the values in reverse order ?!? That would be "wrong" too.

As we all know, the PLC can't understand the intent of the programmer; it will only do exactly what it's told to do, for better or worse.

That's why those of us who use the COP instruction as a quickie FIFO would usually load from the top (F8:7) and copy backwards (COP #F8:1 #F8:0 7).

But it is more esthetically pleasing to have the first (zeroth) register being the most recent data, so we'd do what you did, and copy it an intermediate register then copy it back to the source.
 
PLC-5 is forward also. Here's why: ...

And yet ...
The PLC-5 program uses the COP function to copy 7 floating point files [values?] to 7 other locations.

... The goal is to move the data in word 0 to word 1, data in word 1 to word 2, etc and at the end, move the current days data into word 0. (Word 0 is "yesterdays data".

This works fine in the PLC 5 moving F registers. ...

How does that work fine if the PLC 5 COP instruction starts at the beginning of the Source and Dest arrays, and then moves (increments) "forward" as it copies?

Moving data from one area (array) of memory to an overlapping area (array) of memory can be implemented without buffering the data:

  • If the start of the destination array is "before" start of the the source array, then the naive approach, which begins at the start of both arrays and increments forward through the arrays, will work.
  • If the destination array is "after" the source array, then the COP must start at the end of both arrays and increment backwards through the arrays.
Anyway, to get back to OP, who probably just wants summat to work in Logix, they can either create an intermediate buffer and do two COPs, or they can change their existing poor-man's FIFO to an actual FIFO with the ordering of the daily numbers reversed, or they can do a simple loop stepping backwards either implicitly via the FAL instruction or explicitly:

LBL X XIC Midnight_Oneshot BST EQU ISRC 0 MOV 6 ISRC NXB MOV ISRC IDST SUB ISRC 1 ISRC MOV ARRAY[ISRC] ARRAY[IDST] GRT ISRC 0 JMP X BND

I think FAL is the best choice; the question of why a single COP works on their PLC 5 is academic.

[Update: took a few tries to get that loop right, and I am still not convinced it is right yet]
 
Last edited:

Similar Topics

Hello, What is the Problem: I have an old version of projects with all the tags' descriptions and a new one without them. I know how to...
Replies
6
Views
3,158
Hi I have offline project and I want to copy a tag (the name and the vaule) to a online project is it posiable ?
Replies
2
Views
1,457
Anyone have a direct link or a copy of this old software? I have valid licenses for it on this PC but when I try and download it from rockwell it...
Replies
8
Views
2,514
This is a real simple interface problem. Typically when I'm developing in ladder I will Ctrl+C an instruction and Ctrl+V, the new instruction will...
Replies
2
Views
1,678
I've run into this a couple times and while I see a lot of references to Fatal crashes on the RA knowledgebase, I don't see one for this...
Replies
10
Views
4,765
Back
Top Bottom