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

I have an expression in a structured text routine of a Logix controller that looks more or less like the following: ResultInteger := Integer1 *...
Replies
13
Views
388
Good evening. I display the step number of a SFC on a display. Sometimes, on a trip, it goes quickly through many steps and I need to prove to...
Replies
1
Views
127
I am trying to set up a piece of equipment with a Horner HE-X4R. I'd like to use structured text and so far I'm just trying to get a basic On/off...
Replies
0
Views
70
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
163
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,359
Back
Top Bottom