Hi all,

I’m currently working hard on fixing some issues in the S7 array processing.

Admittedly it seems as if the Array tags never really worked in S7 … I’m hoping 
to change that.

So, the problem I currently have, is that you can define a variable as 
BYTE[3..10] which will create a 8 element array. It’s stored as 0..8 in the PLC 
memory, but addressed as 3..10 from the program.

So if you want to read an array, you’d need to pass the dimensions: start..end

%DB1.DBB0:BYTE[0..4]

But if you have a non-0 based array variable … things start getting tricky.

So I would like to go for this general assumptions:

  *
Arrays are generally treated as 0-based per default
  *
A single element is addressed by a single index: "%DB1.DBB0:BYTE[3]"
  *
If a variable is not 0-based, the base can be added to the tag like this:
  *
"%DB1.DBB0:BYTE[4..5;3]" returns a two element BYTE array implying that we’re 
reading the second and third element in memory - „(4-3)..(5-3)“ —> „1..2"
  *
"%DB1.DBB0:BYTE[4;3]“ returns a single BYTE which will read the second element 
in memory: 4-3 = 1

What do you think? For protocols, where the full type information is present 
(like ADS, UMAS, S7+) we don’t need this, but I think for S7 it would be 
important to support this.

Chris

Reply via email to