Array Shift Not Working With UDT

Richjr

Lifetime Supporting Member
Join Date
May 2013
Location
West Covina, California
Posts
8
I have searched quite a bit, but I'm struggling to figure this one out. Any assistance would be greatly appreciated. The COP and MOV instructions work perfectly in the standard array of DINTs at the top of the rung, but when I attempt to shift the DINTs in my UDT array, it does not. See attached picture.

Array Shift.jpg
 
Last edited:
The item in one UDT is not directly adjacent (in memory) to the unit in the next UDT. A COPy of more than one unit wants the items to be adjacent. Even though you have an array of UDTs the item (eg month) in one UDT is not adjacent to month in the next UDT. This would work if you were copying whole UDTs though (for example if your UDT was JUST made up of year, month, day and hour).

If it is try

COP WMS_Log[1] WMS_Log[0] 50

followed by

COP WMS_Time WMS_Log[49] 1


Else try using the FAL for the UDT copying.

By the way, shouldn't the length in the COPY be 49 instead of 50? Or do you actually have an array element [50]?
 
Last edited:
I see, that make sense. When you say whole UDTs, what do you mean? I will look into utilizing the FAL as you suggested. Thanks so much for your help!
 
Last edited:
To repeat, if your UDT is made up of JUST year, month, day and hour then each member of you UDT array can be moved as a unit.

If it is then use the syntax of the two commands I gave.

By defining a UDT you are creating a new data type (as the name suggests) just as valid as DINT and SINT and able to be copied as a chunk.
 
What you said worked! The UDT is made up of year, month, day, hour, min, sec, microsec. Is there a reason you mentioned "JUST" year, month, day, and hour?

Also, I put 50 since the array starts at [0] and ends at [49]

I see what you mean regarding copying my new UDT as a chunk. I think what I did wrong the first time was using a "mov" following the "cop" instead of "cop" "cop."
 
Last edited:
Is there a reason you mentioned "JUST" year, month, day, and hour?

You are right, on second thought it is not important that the UDT have JUST these elements. The COPy commands would work as you wished but copying all the other stuff in each UDT also.
 

Similar Topics

Hey all, was wondering if it was possible to shift values in an array of strings? I have a database that I am loading up with "Users" in the...
Replies
2
Views
301
I'm still a little remedial with my Step 7 classic knowledge. I'm working on in Simatic Manager 5.5, SP4, and I need a little insight of how to...
Replies
10
Views
2,707
Hello all, I find myself writing some new logic and I am storing records of analog values so that it will be possible to look back on them and...
Replies
7
Views
3,166
Trying to put together an array to do the following Dial has 8 positions Each position can have a status of 0,1 or 2. 0-not present 1-OK 2-Not...
Replies
8
Views
2,795
Hi, I'm having an issue in crimson 3.0 when I create a programme using a case statement referencing a fault word that each bit needs to change the...
Replies
4
Views
187
Back
Top Bottom