Programming concepts
7.5 Programming language
7.5.3.3
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.
PEEK(area:=_in_,
PEEK_WORD(area:=_in_,
PEEK_DWORD(area:=_in_,
PEEK_BOOL(area:=_in_,
206
dbNumber:=_in_,
byteOffset:=_in_);
dbNumber:=_in_,
byteOffset:=_in_);
dbNumber:=_in_,
byteOffset:=_in_);
dbNumber:=_in_,
byteOffset:=_in_,
bitOffset:=_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);
Example referencing IB3 input:
%MB100 := PEEK(area:=16#81,
dbNumber:=0, byteOffset:=#i); // when
#i = 3
Reads the word referenced by byteOffset of
the referenced data block, I/O or memory
area.
Example:
%MW200 := PEEK_WORD(area:=16#84,
dbNumber:=1, byteOffset:=#i);
Reads the double word referenced by
byteOffset of the referenced data block, I/O or
memory area.
Example:
%MD300 := PEEK_DWORD(area:=16#84,
dbNumber:=1, byteOffset:=#i);
Reads a Boolean referenced by the bitOffset
and byteOffset of the referenced data block,
I/O or memory area
Example:
%MB100.0 := PEEK_BOOL(area:=16#84,
dbNumber:=1, byteOffset:=#ii,
bitOffset:=#j);
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
Need help?
Do you have a question about the SIMATIC S7-1200 and is the answer not in the manual?