Help with RSLogix 5000 COP instruction.

HDeno

Member
Join Date
Jun 2008
Location
Montreal
Posts
3
Hi,

Is it possible to use the COP instruction to copy only one element of a structure or UDT to an array with the same type as the element. Per example:

Structure:

Structure[100], with each on being comprised of:

Structure[xx].element1 (type REAL)
Structure[xx].element2 (type REAL)

My destination array would be Destination_Array[100] (type REAL)

I want to basically copy all the .element2 of my Structure into the destination array. Can I use the following COP instruction?

COP
Source: Structure[0].element2
Dest : Destination_Array[0]
Length: 100

I would also be able to do the opposite which is write from the Destination array back to each .element2 in the structure array.

Thanks
 
I would have to test it to be sure, but I would guess that the answer is no. The COP command is setup to copy contiguous memory blocks from one location to another.
Because the UDT's elements are not contiguous in memory, the COP would not do what you are trying to do.

I believe that you are going to have to use a series of MOV instructions with some sort of logic to loop through all of your UDTs to extract the desired element of each UDT object.
 
Check out the FAL instruction. The examples in the help file should get your imagination going. If the scan time can take it you can even set it to execute the entire process in one scan.
 
This is how I'd do it.

In the main routine:
FOR UDTtoArray I 0 99 1

In a routine called UDTtoArray:
COP Structure.element2 Destination_Array 1


Might not be the most efficient, but it's clear.

(Beats me why the forum insists on changing the I in the COP instruction to i, but I tried to change it back twice.)
 
Last edited:
Thanks everyone for the tips..

Mellis: I tried your suggestion and it works perfectly for my needs... Like you said there might be a more efficient way to do it, but this works great... Thanks a lot..
 

Similar Topics

I am completely stuck on building a ladder program that requires a start button to be pressed 3 times to turn on motor 1. Then motor 2 starts...
Replies
20
Views
574
Hello Everyone, I have tried to access the help function from my RSLogix 5000 but everytime I select a function block on the PLC rung and press...
Replies
3
Views
1,274
I’m working with indirect addressing and trying to make an HMI where each Rectangle Object has a tag of “A[0-127]” with a correlating Push Button...
Replies
15
Views
4,207
I have been tasked to upgrade some SquareD PLCs at our plant. I have done several of these upgrades without any issues. However, I have now met my...
Replies
4
Views
2,444
Hi There, When i did FRD instruction in SLC 500 its working, when i try to simulate in RSLogix 5000 same way as i did in SLC 500 which is not...
Replies
14
Views
2,727
Back
Top Bottom