3. 3
The ControlLogix processors can store
data in arrays.
Arrays – An array is a tag that holds multiple
values of the same data type.
Your textbook defines an array as: “a data
structure that allocates a contiguous block of
memory to store a specific data type as a table
of values.
ControlLogix Arrays
4. 4
Arrays are specified as having dimensions.
They can be:
1-dimensional
2-dimensional
3-dimensional
ControlLogix Arrays
6. ControlLogix Arrays
Tag Name Data Type
Dimension
0
Dimension
1
Dimension
2
Total # of
Elements
one_d_array DINT[7] 7 0 0 7
two_d_array DINT[4,5] 4 5 0 20
three_d_array DINT[2,3,4] 2 3 4 24
8. Creating and Array
Select the data
type, then
enter the
number of
elements for
each
dimension.
Use Dim0 for a
1-dimensional
array, Dim0
and Dim1 for a
2-dimensional
array and
Dim0, Dim1
and Dim2 for a
3-dimensional
array.
9. Creating an Array
This Select Data
Type dialog box
shows a DINT
data type
configured as a
3-dimensional
array. Note how
the array
elements are
designated in
the Data Types:
box.
11. 11
The ladder shown will collect temperature
readings from tempReading
<Local:10:I.Ch0Data>, every 30-seconds and
store them in an array.
Array Example
12. SLC500 – Indexed and Indirect Addressing
SLC500 Information (Optional)
13. Indirect and Indexed Addresses (SLC500 and
LogixPro)
Includes arrays (ControlLogix)
Chapter 09
14. 14
Valid Addressing Modes
There are four basic modes or types of
addressing in the SLC500 series PLC’s
Direct
Indexed direct
Indirect
Indexed indirect
15. 15
Direct Addressing
Data is stored in the specified address.
This mode is what we have been using for
all of our work in the course.
Examples:
N7:3
T4:9.PRE
R6:3.POS
F8:7
B3:6/2
C5:8.ACC
Memory Address Data Value
N7:0 52
N7:1 128
N7:2 346
N7:3 510
N7:4 14
16. 16
Indirect Addressing
The address in the instruction serves as a
reference point and does not point directly
to the data location. In other words: the
instructions memory address contains the
address of a memory location.
Memory
Address
Data
Values
2210 52
2211 128
2212 345
2213 510
2214 343
Memory
Address
Data
Values
343 54
344 71
345 633
346 85
347 500
Address = 2212 Data = 633
17. 17
Indirect Addressing
An address can be specified as indirect by
replacing the file number, element number
or sub-element number with another word
address.
The indirect address is always enclosed in
square brackets [ ].
N7:[N7:0] is an example of an indirect
address.
The word level address in the square brackets
is queried for a value. The queried value then
becomes the file, element or sub-element
portion of the indirect address.
18. 18
Indirect Address
Examples
N7:[N7:0]
If a value of 43 is stored in N7:0, the indirect
address N7:[N7:0] is indirectly referencing
N7:43
B3:[T4:0.ACC]
If the value of 12 is stored in the accumulator
of T4:0, the indirect address B3:[T4:0.ACC] is
indirectly referencing B3:12
F[N7:3]:[N26:12]
If a value of 18 is stored in N7:3 and a value
of 4 is stored in N26:12, the indirect address
F[N7:3]:[N26:12] is indirectly referencing
F18:4
19. 19
Guidelines for specifying indirect
addresses:
The
file number
word number (element + sub-element)
bit number
can be addressed indirectly
The substitute address must be a word-
level address.
Enter the substitute address in square
brackets [ ].
Indirect Addressing
20. 20
The table shows some additional examples
of indirect addressing:
Indirect Addressing
Valid Address Variable Explanation
N7:[C5:7.ACC] Word number The word number of N7 is
being specified by the value
stored in the accumulator of
C5:7
B3:0/[R6:4.POS] Bit number The bit number of B3:0 is
being specified by the value
stored in the position word of
R6:4
N[N7:0]:[N22:1] File and word
number
The file number is stored in
N7:0 and the word number is
stored in N22:1
I:[N10:0].1/1 Slot number The slot number is stored in
N10:0
21. 21
Indirect Addressing
When using indirect addressing, the data file
(memory location) being referenced must
exist. Data files (memory) is not
dynamically created or expanded. In other
words, the memory is not dynamically
allocated to fit the size of the data.
IMPORTANT
22. 22
Indirect Addressing
Indirect addressing allows for the
creation of less complex ladder logic
preservation of memory
use of an array like structure
Indirect addressing can be used for
applications such as cycling through a
recipe file in a multiple batch operation.
23. 23
Example application of Indirect
Addressing:
Data collection is an application for indirect
addressing such as, keeping a record of
temperature at prescribed times and over a
given period of time.
Using recipes in systems that require different
parameters depending upon the product being
produced.
Discuss the LogixPro Batch Process Recipe
Example
Indirect Example
24. 24
An indexed address is an addressing mode
for referencing a memory location that is
the original memory address plus a value
that is stored in an index register.
The content of the index register is added
to the original address to obtain the final
memory location (offset).
Indexed addressing is useful for accessing
elements of an array of data. The base
address stays the same, but the value of
the index register is incremented or
decremented.
Indexed Addressing
25. 25
The table shows an example of an indexed
address:
Indexed Addressing
Memory
Address
Data
Value
N7:33 52
N7:34 578
N7:35 79
N7:36 427
N7:37 56
N7:38 4
N7:39 131
Base address = N7:22
Index or Offset = 15
Data = 56
N7:22 → (Word 22 + 15) = N7:37
26. 26
An address is specified as being “indexed”
by placing the “#” character in front of the
address.
When the program encounters an address
of this form, the processor takes the
element (word) number of the address
and adds to it the value stored in the
index register.
The index register is in the
SLC500/LogixPro Processor Status file at:
S:24
Indexed Addressing
27. 27
The actual address is the Base address
plus the value stored in the index register.
Example:
#N7:10
Here, the element (word) number of the direct
address (the base address) is 10.
If S:24 has a value of 25 stored in it, the value of 25
is added to the base address element number; in this
case 10.
The address that #N7:10 with S:24 = 25 is
referencing is N7:35.
N7:10 + S:24 or N7:10 + 25 = N7:35
Indexed Addressing
28. 28
When the processor resolves an Indexed
Indirect address it first resolves the
indirect portion of the address and then
adds the offset from the index register
S:24 to create the final address.
What makes the addressing mode
powerful is that S:24 is a dynamic
address. It can be read and written to on-
the-fly.
Indexed Indirect
Addressing
29. 29
An address can be specified as a
combination of indirect and indexed
addressing.
Example:
#N7:[N10:3]
If a value of 20 is stored in N10:3 and a value of 10
is stored in S:24, then the indexed indirect address
#N7:[N10:3] is referencing N7:30
That is, N7:[N10:3] is indirectly referencing N7:20
and #N7:[N10:3] is indexed by 10 producing
N7:20 + 10 = N7:30
Indexed Indirect
Addressing
LogixPro does not support this mode of addressing
30. 30
Guidelines for specifying indexed
addresses:
The offset value stored in S:24 can be positive
or negative.
The offset value should not cause the base
address to cross a file boundary.
If an instruction uses more than one indexed
address, the processor uses the same index
value on each of the indexed addresses.
The value of the index register should be set
immediately before enabling the instruction
that uses an indexed address.
Indexed Indirect
Addressing
31. 31
Guidelines for specifying indexed
addresses:
Indexed addressing does not work with
Timers, Counters or the Control File.
Indexed addressing is invalid for any file type
that uses multiple words.
Some instructions modify the value of the
index register so that they can function
properly. The Sequencer and the Bit Shift
instructions are examples of instructions that
use and modify the value of S:24.
Indexed Indirect
Addressing
32. Monitoring Indexed
Addresses
The value of the
indexed address
will not display
when it is being
monitored.
The code snippet
shown assumes
that:
S:24 = 5
N7:3 = 123
N7:8 = 456
When the MOV instruction is executed
the indexed address #N7:3 is evaluated
to N7:8 and the value of the indexed
address will be stored and displayed in
the direct address of N10:3. Also note in
the ADD instruction that the value stored
in the indexed address is added to the
zero of C5:0.ACC.