Matrices in Structured Text:

mimimichele

Member
Join Date
May 2017
Location
Italy
Posts
1
Hello all,

i'm new to PLC programming and Structured Text. I'm working in Automation Studio (B&R) using the structured text.

I am able to create a matrix:

Matrix : ARRAY [0 .. MaxRows, 0 .. MaxCol] OF arraytype;

The problem arise when i would like to access the matrix, extracting, for instance a coulumn, instead a single value.

singleValue = Matrix[0,0]; <-- Working
array1 := Matrix [0, 0 .. MaxCol]; <-- Not Working

I hope i explained my problem clearly. Does anyone have some suggestions?

Many thanks in advance,

Michele
 
I don't think you can assign an array like that. I never used B&R Studio, but surely there will be a copy or move function where you specify the starting point of the data block (position 0 in your case) and the starting point of the destination and the length to be copied.

I would look into a Move instruction first, if Siemens is a standard for Germanic PLC brands.
 
I have the specification. I don't see where it is allowed to index into the array by whole columns. However, the new specification allows declaring
A: ARRAY[*, *] OF REAL;
You may try
ROW := A[r,*];

but I doubt it will work. I know that Many languages support getting whole rows, columns or structures this way. I just don't see where ST does.
 
Depending on how the matrix is stored (actually, a multidimensional array), you might be able to just use memcpy(ADR(array1), ADR(Matrix[0,0]). This will either do exactly what you want and copy the 'column' or it will copy the first row instead. If it is copying the row, you'll just have to use a FOR loop.
 

Similar Topics

What is the best way to make an online program change with structured ladder without stopping the operation of the PLC using GX Works 2?
Replies
1
Views
98
Good morning. I'm doing a rehab and I need to recycle some part of the old code that won't change and that I need. This is a calculation that...
Replies
22
Views
1,170
I'm writing some structured text that's handling a data structure that comes from a PC. The PC structure is in the "new" LREAL 64-bit floating...
Replies
3
Views
440
Trying to put these equations in structured text program in a Micro 830. when I run the verify I get this error. ;:expected before this new...
Replies
4
Views
395
Hey all, Studio v20.05 Background. We are piggy backing another system to record attributes for product travelling down the line and several...
Replies
21
Views
3,422
Back
Top Bottom