Reputation: 3
I would like to understand what is the difference in the PLC performances if I declare and use an array of one element or a single variable.
I am reusing parts of a TIA Portal project where all the variables were indexed. In the project I am working on, there is no need to have arrays, but keeping the indexes would keep the parts of code I am using identical.
Does the array use more resources? Are there any limits on the hardware? In short, are there any cons in keeping the arrays of 1 element?
Thanks in advance
Upvotes: 0
Views: 133
Reputation: 423
I do not believe arrays have any memory overhead in work memory, but they require extra processing time if they are being indexed with variables.
I don't know if there's any processing overhead if arrays are indexed with constants (in your case, 1). I would guess not, but if you want to be sure, create some one-element arrays and perform 100s or 1000s of math operations on them in a loop. Then use the RUNTIME instruction to compare the processing time with a copy that uses simple variables instead. I have used this method in the past to compare the efficiency of different types of operations.
Upvotes: 1
Reputation: 1
It is quite probable that its use is due to the fact that it is used in some FB or FC in the program that needs a value of that type.
The most recommended way to find the origin is to look at the list of cross-references and check in which other parts of the program it is used.
Surely it will give you an idea of why it is used, or maybe the array was reduced, an array was put in place to be able to expand if necessary, or some other FB or FC module requested it in that format.
Upvotes: 0
Reputation: 74
That depends…
If in code, none.
If in interface of OPC UA, array is much better that single elements.
When used in some HMI, the tag count can be lower when using arrays.
//PerD
Upvotes: 1