Studio5000 data clear

ibora

Lifetime Supporting Member
Join Date
Dec 2008
Location
Izmir
Posts
66
Hi guys,
I have a data table as REAL type VALUES_TABLE[32,100].
I want to clear this table. For that i created a REAL type CLEAR_DATA tag with value 0.

Is this line clears the table?

COP(CLEAR_DATA, VALUES_TABLE[0,0], 32);

Or what is the correct way?

Thanks
 
That won't work the way you intend it to. COP is for copying an array into another array (slightly oversimplified explanation). Look at the FLL instruction instead. That will take a single source tag or literal value and copy it into an array of destination tags. I'm not sure how I would handle it with a multi-dimensional array but would experiment with it some. Probably do a loop 32 times with a FLL of LEN 100 as a first step. You may have to do 2 loops. Inner loop 100 times and outer loop 32 times (or the other way around...), and use a simple MOV with the source being 0 and the destination being VALUES_TABLE[x,y] with x looping from 0-31 and y from 0 to 99.
 
Last edited:
FLL should do the trick, but according to this, COP may be another option. So this:
Code:
VALUES_TABLE[0,0] = 0;
then either this:
Code:
COP(VALUES_TABLE[0,0], VALUES_TABLE[0,1], 31999);
or this:
Code:
COP(VALUES_TABLE[0,0], VALUES_TABLE[1,0], 31999);
should also work.
 
Um, I think he has a 2-dimensional array, not an array of length 32000. Does the FLL work that way? Where it'll continue withe next "column" of the array? Interesting...I'll have to try that.
 
Um, I think he has a 2-dimensional array, not an array of length 32000. Does the FLL work that way? Where it'll continue withe next "column" of the array? Interesting...I'll have to try that.


I would expect that COP, CPS, and probably FLL, don't care about the multi-, or non-dimensional organization of the data, rather the source address, the destination address, the size of one destination element, and the length, which length is the number of destination elements to overwrite. The data types can be different (e.g. copy two 2xLength UINTs from a Modbus Slave into a Length REALs).

Of course, I doubt Rockwell Automation gives two hoots about what I expect.
 
Write it as one structured text loop nested within another loop.

The code is easy to understand, it would run largely unchanged on any PLC, the array dimensions are easy to change, and the code is independent of the data type of the array element. No need to figure out how confusing AB instructions work.

Something like this (nearly ST Pseudo-code):


REAL C[10][20]; or maybe REAL C[0..9][0..19]; (depends on the PLC)
INT A, B;


FOR A:= 0 TO 9 BY 1 DO
FOR B:= 0 TO 19 BY 1 DO
C[A] := 0.0;
END_FOR;
END_FOR;

The '0.0' explicitly specifies a REAL constant as opposed to '0' which may be integer.

Use the right language for the job.
 
I created the program with Corsair's solution:

FOR INDEX_3:= 0 (*...Data table clear*)
TO PARAMETER_CHANNEL_QTY -1
DO
FOR INDEX_4:= 0
TO PARAMETER_SAMPLES_QTY -1
DO
VALUES_TABLE_GLB[INDEX_3, INDEX_4] := 0.0;
END_FOR;
END_FOR;

Thanks all
 

Similar Topics

Hi Hope you all are doing well. Iam working on a project with some AOI. I also hate no online edits... lol. My problem occurs when I use a UDT...
Replies
2
Views
167
Hi all, I have a question on how to hande data that i read from a sensor (type IFM) trough IO-Link (1734-4IOL) I get 2 SINT's (SINT[0] and...
Replies
2
Views
691
Hi all, Working on a project in Studio 5000 setting up a UDT to read an Input Instance from an EIP device. I have everything set up and it's...
Replies
2
Views
889
See image below. Look at line 95. I tested all data type, but none of them works. https://ibb.co/H2Csr15 See this. TEMPDATA2 is used only...
Replies
3
Views
2,708
We recently had a 1794-L34 (v16) FlexLogix system with 1794-ACN15 ControlNet adaptors converted to a 5069 (v30) CompactLogix controller with...
Replies
1
Views
1,133
Back
Top Bottom