Copying from a UDT array into a larger array?

Paul351W

Member
Join Date
Mar 2008
Location
Northern Illinois
Posts
154
I have an application where I am allowing the user to edit 4 different XY value tables using 2 columns of numeric indicators on the Panelview. I am storing the X and Y values in 4 different UDT's, and want to copy the X and Y values into a larger array of DINTs that the Panelview is reading.

I would like to do this every scan if possible, to minimize delay when the operator changes a value.

My UDT is basicly: X (DINT[15])
Y (DINT[15])
And I want to copy into a larger array, for example, X would copy into elements 100-114, and Y would copy into elements 115-130. I allow the operator to change either the X or Y values at one time, so there are two possible value states per table, and 4 tables, so I would have to have 240 move statements to cover all the possible scenarios.
 
I forgot to mention, this project is in Controllogix.

I was just thinking, could I somehow write a subroutine to process the data moves (like a FAL instruction), and not jump back to the main routine until all the data is moved? I've done JSRs before, but I've never done any looping in ladder logic code.
 
It is possible to do what you want to do by using the FOR instruction.

One word of caution though with a FOR instruction. You are literally stopping all other processes until the FOR loop has been completed. This means that machine control could be affected by how you use this instruction. It all depends on the array sizes and amount of data you are working with.

If you just let the processor run without loops and update each item on each scan it will get updated rather quickly and not affect the reaction of the processor.

Just a word of caution since the PLC does not work with threads like a PC does.
 
I have an application where I am allowing the user to edit 4 different XY value tables using 2 columns of numeric indicators on the Panelview. I am storing the X and Y values in 4 different UDT's, and want to copy the X and Y values into a larger array of DINTs that the Panelview is reading.

I would like to do this every scan if possible, to minimize delay when the operator changes a value.

My UDT is basicly: X (DINT[15])
Y (DINT[15])
And I want to copy into a larger array, for example, X would copy into elements 100-114, and Y would copy into elements 115-130. I allow the operator to change either the X or Y values at one time, so there are two possible value states per table, and 4 tables, so I would have to have 240 move statements to cover all the possible scenarios.


Let me make sure I have this correct..

Your udt consists of two DINT[15] named X & Y.
You have 4 tags using this udt (the tables).
You want to copy this data into a larger array DINT[240+].
Each of the tables has a specific spot in the larger array.

I'm not following why you want to move them, you only mentioned that the panelview reads them. If you are writing to the tables directly, why not display them using the same tags? The whole lag issue goes away. But if you need to copy the data, this is how I'd do it.

COP Table1 BigArray[100] 30
COP Table2 BigArray[130] 30
COP Table3 BigArray[160] 30
COP Table4 BigArray[190] 30

If you need to copy just the X or Y portions independantly...

COP Table1.X[0] BigArray[100] 15
COP Table1.Y[0] BigArray[115] 15

I'm also not getting the requirement for 240 moves. I count 120 DINTs of data. What am I missing?
 
You are correct, except that the arrays in the UDT are REAL, because they will be feeding an FGEN instruction in function block. I originally had DINT arrays, but the FGEN requires REAL for some reason. I will have to change the data type of my destination array as well I think, since it is currently DINT.

The Panelview screen setup has 2 groups of 15 numeric indicators, to display the X and Y values separately. I have a list selector with 15 positions that selects which value will be changed via the keypad interface.

I have another set of 4 buttons to select the table, and 2 more buttons to select if the X or Y values are going to be edited by the keypad.

As far as the 240, I think I accidentally multiplied 8 by 30 instead of 15. Each display address would have the potential to move 8 different data locations into it, based on the 4 tables, and X or Y.

I had played around a little with the COP instruction, but I must have been entering something incorrectly because I was not working for me until I tried the format you posted.
 
Last edited:

Similar Topics

Hello all! Is it possible to COP a SINT array to a UDT structured the same as a SINT array, except all BOOL bits? I have a module that has an...
Replies
5
Views
3,178
I created a UDT with recipe parameters and have created several Recipe tags using that UDT as a data type, as well as an "Active_Recipe" tag. if...
Replies
1
Views
1,756
Hi All, In RSLogix 5000 (or Studio 5000), is there a way to easily copy all the tag values from an UDT instance to another UDT instance (same UDT...
Replies
2
Views
2,347
I'm trying to reverse engineer a client's program. They are sending Logic Command and Speed Reference over DeviceNet to a PowerFlex 40P VFD. The...
Replies
2
Views
3,264
I'm not super familiar with the Micrologix line of processors, but I am pretty familiar with RSLogix 500. I'm trying to simply copy a string to...
Replies
4
Views
311
Back
Top Bottom