Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
There are several basic methods of addressing that can be used to identify
an operand in an S7 programmable controller. These basic types are as
follows:
A) Immediate Addressing Immediate addressing refers to the use of a
number value as an operand. A Statement List example would be to load a
constant into the accumulator.
There is no operand address in this operation, the operand is contained in the
Statement.
L 14
// Load accumulator with the integer value 14B) Direct addressing - Direct
addressing refers to the use of an actual memory or object address to specify
the location of the operand. A statement list example would be loading the value
contained in Marker word 46 into the accumulator. The operand address is explicitly
called out in the operational.
L MW46
// Load the accumulator with the contents of MW46C) Indirect addressing
Indirect addressing refers to the use of a pointer to indicate where
the operand address can be found. A statement list example would be loading
theaccumulator with the contents of a memory word, whose address is contained in
apointer. The operand address is not computed until runtime. Braces are used to
signifyan indirect address to the operanda.
L MW [POINTER_LOCATION]
// Load accumulator from a MW whoseaddress is stored as a POINTER in
POINTER_LOCATION
Two Types of Indirect Addressing
Indirect addressing in S7 PLCs can then be further subdivided into two types: A)
Memory-Indirect addressing
Is used for computing the actual address of the data. The pointer to the
actual data
Address is stored in one of the two Address Registers of the PLC, and
that gets
combined with an offset value to compute the variable address. Register
indirect
addressing is the form best supported by STL since you can directly display
thecontents of the address register to see where the pointer is aimed.
Register indirect addressing also executes faster than Memory Indirect
addressing. Register indirect
Addressing can also be used for programming situations where you dont
explicitly Know the Memory Area of the actual data until runtime. Register
Indirect Addressing is covered more completely in a
Companion application note Pointers and Indirect
Addressing in S7 PLCs, Volume 2
After execution of this statement, the accumulator will contain the following 32
bit value: 00000000 00000000 00000011 11011000
L P# 123.0
T MD4
This twoStep operation loads an area internal pointer
Into the accumulator, and then transfers the pointer value into MD4, which can
now be used for an indirect addressing operation. MD4 now contains00000000
00000000 00000011 11011000
L P# 123.0T MD4.L MB [MD4]
This three-step operation loads a pointer of value 123.0into the accumulator and
stores the pointer into the double word location MD4. The third instruction will
Then use the pointer found in MD4 to point to location
M123.0 and will load the contents of MB123 into the into the accumulator
Area Crossing Pointer Operation
Description
L P#M123.0
This operation instructs the CPU to load the
accumulator with an area crossing pointer forM123.0 After execution of
this statement
the accumulator will contain the following 32 bit value:10000011 00000000 00000011
11011000
L P#M123.0T MD4
This two-step operation loads a pointer to M123.0 into the accumulator, and then
transfers the pointer value into MD4, which can now be used for an indirect
addressing operation. MD4 now contains10000011 00000000 00000011 11011000
L P#M123.0T MD4.L B [MD4]
This three-step operation loads a pointer to M123.0 into the accumulator and stores
the pointer into the double word location MD4. The third instruction will then use
the pointer found in MD4 to point to location M123.0
and will load the contents of MB123 into the into the accumulator
Working With Memory Indirect Addressing - Instructions
Memory Indirect Addressing can be used in the following Statement List instructions:
SIMATIC NET customers have free use of the application tips. These tips are only a
general approach to using SIMATIC NET with various applications. Your specific
application may be different. It is your responsibility to use SIMATIC NET properly in
your applications.
Operation STL Mnemonics Sample
Binary Logic Operations A, AN, O, ON, X, XN A M [MD12]O T [QW12]*Binary
Memory Functions=, S, R, FP, FN = Q [MD66]R C [MW88]* Accumulator
Functions L, T T QW [DID44]L T [MW12]*Block Functions(Integer memory
indirect specification of the objects))OPN (opening a DB)S, R, CU, CD
(counter actions)SP, SE, SD, SS, SF (start timers)CALL, UC, CC (calling
code
blocks)OPN DB [mw12]*CU C [DBW56]*SE T [MW12]*UC FC [MW12]**
Integer Memory Pointers for Block Objects
Working with Memory Indirect Addressing - Indexing
Area pointers may be used to perform indexed reading and writing from a
table or array of data items. This can easily be accomplished by creating an
area pointer that contains the starting
Address of the table of data, and then adding a pointer increment to the
table pointer that is equal to the desired index into the table of data. The example
below shows a routine for
Accessing an element in the table of bytes starting at location MB20
// This assumes an integer symbol named index exists that
//contains the index (from 0 to 179) into the table
L index // load a variable index into the table
SLD 3 /
/ Shift left 3 bits to create an index pointer
L P#20.0 // load the pointer to the start of table
+D // Add index pointer to start of table pointer
T MD100 // Store the indexed pointer in MD100L MB [MD100] // read
the table element into the accumulator Location Table element
MB20 Element 0MB21 Element 1MB22 Element 2MB24 Element 3
data handling operations regarding arrays. You may copy this archived object into
a folder on your hard drive and then retrieve the archive using STEP7 program
manager. Once the Archive is retrieved, it will add a new library, called
Array Functions to your STEP7 package. The functions in this library are