Programming concepts
7.5 Programming language
S7-1200 Programmable controller
206 System Manual, V4.2, 09/2016, A5E02486680-AK
Indexed addressing with PEEK and POKE instructions
SCL provides PEEK and POKE instructions that allow you to read from or write to data
blocks, I/O, or memory. You provide parameters for specific byte offsets or bit offsets for the
operation.
Note
To use the PEEK and POKE instructions with data blocks, you must use standard (not
optimized) data blocks. Also note that the PEEK and POKE instructions merely transfer data.
They have no knowledge of data types at the addresses.
dbNumber:=_in_,
byteOffset:=_in_);
Reads the byte referenced by byteOffset of
the referenced data block, I/O or memory
area.
Example referencing data block:
%MB100 := PEEK(area:=16#84,
dbNumber:=1, byteOffset:=#i);
ple referencing IB3 input:
%MB100 := PEEK(area:=16#81,
dbNumber:=0, byteOffset:=#i); // when
#i = 3
dbNumber:=_in_,
byteOffset:=_in_);
Reads the word referenced by byteOffset of
the referenced data block, I/O or m
emory
%MW200 := PEEK_WORD(area:=16#84,
dbNumber:=1, byteOffset:=#i);
dbNumber:=_in_,
byteOffset:=_in_);
Reads the double word referenced by
byteOffset of the referenced data block, I/O or
memory ar
ea.
%MD300 := PEEK_DWORD(area:=16#84,
dbNumber:=1, byteOffset:=#i);
dbNumber:=_in_,
byteOffset:=_in_,
bitOffset:=_in_);
Reads a Boolean referenced by the bitOffset
and byteOffset of the referen
ced data block,
%MB100.0 := PEEK_BOOL(area:=16#84,
dbNumber:=1, byteOffset:=#ii,
bitOffset:=#j);