Will Use of Floating array parameter increase the execution time and load the module

Hi All,

In our project, we have use 2-3 floating array which gets the value and state of devices which is  updated through a logic in ACT block for each scan.

Will this increase the execution time and increase the load.

Can someone please give their experience and suggestions on this topic.

Thanks

Senthilkrishnan

4 Replies

  • Arrays allow you to manipulate the data contained using For Loops and such, so they can be quite powerful. You have to perform logic in an expression to populate the array. So generally, comparing the CPU cost of an ARRAY over a set of external reference module parameters would likely show some increased CPU, and would totally depend on the logic of the expression. Using individual parameters might cost you in Memory size, assuming the Expression is reading the data directly from the source.

    In the HMI, you can programmatically walk through the Array to use the data, which can make your scripting more efficient, or at least more elegant. But your primary concern is achieving the functionality you need in the most effective way.

    Andre Dicaire

  • In reply to Andre Dicaire:

    Andre... thanks once again for the detailed info....

    Lets say I write a Do while loop to update this array with the Device mode, SP & PV for n devices
    Is this a good approach ....

    Which is better to create individual parameter or an array to write a series of dynamic status values for lets say n devices and is it ok to use a DO while loop or a IF statement expression...

    We have used DO while loop in action block of steps and it works perfectly but it seems it increases execution time and may skip checking one loop if there more devices to check..

    If possible can you let me know how the scan of Do while loop is carried out in a action of a step for 1 scan execution module

    Since we at this point has to consider optimization and had to focus on reducing the execution time for better performance ...

    I was also informed to not use DO while loops or more than 3 nested IF loops since they may miss some data due to scan constraints...

    Just want to know these for finding a better approach while writing logic or to reduce logic and mostly prefer gate logic instead of expression in ACT or CALC or Action (in SFC)..

    If we update these detail through HMI, is it possible to totally eliminate the array or parameters in module and keep all the reference directly ref in HMI.. Is this a better approach since we reduce the load on controller, but will the HMI refresh rate gets affected...


    Thanks for your time ...

    Have a great day...

    Senthilkrishnan...
  • In reply to Senthilkrishnan M:

    I know I'm late to the game here, but like Andre says, it depends. All code needs to be a balance between speed of execution and memory consumed, as well as ease of understanding and troubleshooting for the next engineer. We have some places where we will use arrays to calculate valve setpoints and then write those later to each valve in a sequence, but we have also done large extended if/then constructs to accomplish similar functions. Generally the smaller the code the more efficient it is going to be, but keep in mind when you think about smaller, that would be the number of statements that are executed. With loops, you would have to multiply out to get number of steps executed.

    In general though, an action or calc block is going to be executed in one scan. Putting too much stuff in a single loop is going to increase the loading significantly. There is a limit of somewhere around 3000 total loops in a module before it just throws an execution error. This is to prevent against run away loops where the end condition is not met. This is part of what gets you in trouble with nested loops because of the multiplicative effect.

    Block logic vs. action or calc block is also heavily dependent on style and configuration. Personally I tend to go with if I can do something in 3-4 discrete function blocks, I'll do it that way, if it's more than that, an action or calc block usually ends up cleaner and not a significant loading difference.

    As to your comment about nested if then loops, I have not seen or heard of any limitation there and we regularly will do 16 or 32 in a lot of our code.

    I think at this point, without a more specific use case, any of us from Emerson are going to have a harder time recommending anything that is very general and open ended.
  • In reply to Matt Forbis:

    One note on Matt's comment about nested loops. I have had to work with multiple arrays of enough elements that the "Do While" loop consistently tripped the "runaway" process criteria and failed the module. You can setup module level parameter to keep track of the current array element and use iteration counters inside the CALC block to do the array stuff in chunks.