The drawbacks when using arrays and structured types

Hi,

I was considering to use arrays and structured types. But the drawbacks of using them seem huge. I’m using the Modbus/TCP modules from the M40 series.

  1. Arrays:
    Assume you have a single ADI consisting of an array of 32 integers. Each integer is an ADC value. When the value is requested, it must be fetched, for example via some slow I2C transaction. So if the user only asked for 4 of the 32 integers, then I’d really like to know. Because then I must fetch only 4 ADC values, not 32. Yet, when I specify a get function (which is called before the value of the ADI is returned), the get function is always called with its parameters set to startIndex=0 and numberOfElements=32 - regardless of how many Modbus register I request. The Anybus drivers always sets startIndex to 0, and numberOfElements to the declared number of elements of the ADI. That is hard-coded in the driver. What are these two parameters of the get function intended to do? Is the information which elements of an array were requested available to the driver and can it be made available to the application?

  2. Structured datatypes:
    Lets say we have 32 ADC channels. Each ADC channel provides an ADC value, but of course there are also some parameters (resolution, sample time, etc.). So I could define a structured datatype consisting of the ADC value and all the parameters. But the individual fields of a structured datatype have no get/set methods. There is only one get/set function for the ADI as a whole, and my guess is that the startIndex and numberOfElements parameters of the get/set functions do not indicate which fields of the struct need updating. So in this example, I would have fetch the ADC value (via I2C) even though only the modbus registers holding the parameters (such as sample rate, resolution, etc.) have been read. These parameters would not have to be fetched by I2C.

  3. Arrays, structured datatypes and the modbus/tcp module:
    If I understand correctly, the number of modbus registers allocated for each ADI must be large enough to hold the largest array or struct that I am using. That means, that if I have hundreds of small ADIs (16bit integers, 32bit integers), and several copies of a large struct or array, then the small ADIs will waste a lot of modbus registers. Is that correct?

The bottom line is, that instead of using structured types or arrays, I’m thinking about having several lists of lots of small ADIs (no arrays, no structures, just single values). From these smaller lists I will then compile one big list of ADIs. The big list will consist of several copies of each small list. It is likely, that I will end up with about 800 to 1000 ADIs.

It seems that structured datatypes do not consist a list of ADIs. So they are no mechanisms to express a repeated structures within the list of ADIs? It also seems there is no way to have an array of ADIs with the support for partial updates.

What is the intended purpose of structured datatypes and ADIs with more than 1 element?

Topic closed due to inactivity.