COP Studio5000 order on a UDT

maexio

Lifetime Supporting Member
Join Date
Nov 2005
Location
Lindsay, ON
Posts
27
Hello,
I have been looking for a reference for the order that a UDT is copied in the COP instruction.

More specifically - I have a set of code that used an unprotected COP on an array of UDTS that were changed in a higher priority event task. Due to the size of the array and udts a CPS was not used (to prevent motion issues) and I stupidly didn't think or know of a UID / UIE pair to prevent data integrity issues.

My code now correctly uses a UID / UIE pair before cop of the data, but the symptom of the problem will only be corrected if the UDT data is copied in a specific order, which I can't find anywhere.

More Specifically i have an array of UDT's of the type 'Board' and it has approximately 30 DINT subtags ordered as follows :

ID (Position 0)
Tag 1
Tag 2
Tag 3
Tag 4
...
Tag 20
Tag CriticalCondition
..
Tag 29

If I do a COP Board[5] to TestBoard with a Len 1 -> and an event task interrupts the COP and moves Board[4] -> Board [5] (after moving board [5] -> board[6]...)

Depending upon where the COP is in the interrupt - this could explain my problem. BUT only if the COP copies in the following order :

Tag 29 - Tag 29
Tag 28 - Tag 28
....
Tag 1 (ID) - Tag 1(ID)


That way i could be doing a check that ID NEQ OldID -> MOV ID OldID and have the Tag 21 (CriticalCondition) not be representative of the data i'm trying to 'one shot' with my stored 'OldID' condition.


If however it copies Tag 1 -> Tag 1 then Tag 2 - Tag 2, and so on - My problem still exists and I want to solve it before updating a bunch of locations its used in.



That said -> I know the COP copies data in 32 bit groups, but not the order it copies within a UDT and can't find anywhere on KnowledgeBase or in google searches that clarifies it.

Much thanks in advance, as this issue has me quite distracted trying to find another source of the issue.
 
Thanks baref00t25,

I use circular queues as well for some items, but in this case it doesn't work with most of the other handoff and trigger positions as easily. The vast majority of interactions with the array were data safe, just this one wasn't and it now is. The only problem is either the integrity issue corrects another symptom that is very intermittent or it doesn't. As opposed to waiting weeks or months and having it occur or not, I am hoping to stay in the headspace of this issue and verify that it is solved, but the order a udt is copied in affects that.

Thanks
 
Good question. I know that an array will be be copied starting from the lowest member.

I would assume that since the COP instruction functions over a set of contiguous bits this would be the same regardless of data type, but I admit I don't have any actual evidence or documentation regarding the order it operates on UDTs.
 
It should be easy to test, summat like this:

Continuous task, three rungs:
COP baseudt udt 1

GRT udt.first_dint udt.last_dint CTU ctrgrt 32767 0
LES udt.first_dint udt.last_dint CTU ctrles 32767 0
High-priority Timed-interrupt (1-5ms?) task, three rungs:
ADD baseudt.first_dint 1 tmp_dint

XIC first MOV tmp_dint baseudt.first_dint MOV tmp_dint baseudt.second_dint ... MOV tmp_dint baseudt.next_to_last_dint MOV tmp_dint baseudt.last_dint

XIO first MOV tmp_dint baseudt.last_dint MOV tmp_dint baseutd.next_to_last_dint ... MOV tmp_dint baseudt.second_dint MOV tmp_dint baseudt.first_dintBND

Toggle the first bit, and see which counter increments.
 

Similar Topics

Long time lurker, first time poster.. I've been working with PLCs for a while now and have ran into a head scratcher that I was hoping someone...
Replies
8
Views
2,240
Why not use CPS for everything? When would you actually want to allow the data to change during the copy operation?
Replies
16
Views
36,758
I am trying to copy an array of real numbers into a UDT with a real data type element. I have attached a snip below showing my COP instruction...
Replies
4
Views
204
Hello all. I have a Danfoss VLT feeding an INT into my CpLX program. I need to concatenate the MSB and LSB for position. I used a COP, making sure...
Replies
10
Views
642
I'm having to make an AOI to use with a generic ethernet device because the manufacturer does not provide an AOP. I just want to do a sanity check...
Replies
13
Views
1,262
Back
Top Bottom