PLC-5/250: indexed addresses
Indexed addressing lets you offset an address by the number of elements that you select. You store the offset value in an offset word in the processor's status file. The processor starts operation at the base address plus the offset. You can manipulate the offset word in your ladder logic. For example: #1N23:0.
The indexed address symbol is the # character. Place the # character immediately before the file-type identifier in a logical address. Enter the offset value in word 2 of the module status file (
n
S:2). All indexed instructions use the same word n
S:2 to store an offset.When you specify indexed addresses:
- Make sure the index value (positive or negative) does not cause the indexed address to exceed the file type boundary.The processor does not check this unless you use an indexed indirect address or you exceed the data table area of memory. If the indexed address exceeds the data table area of memory, the processor initiates a run-time error and sets a major fault. The processor does not check to see whether the indexed address crosses file types, such as 1N7 to 1F8. If you are concerned about exceeding file type boundaries, use indexed indirect addressing.
- When an instruction uses more than two indexed addresses, the processor uses the same index value for each indexed address.
- Set the offset word to the index value you want immediately before enabling an instruction that uses an indexed address. File instructions use the same offset word in the status file to perform operations. If the processor runs a file instruction before an instruction that uses an indexed address, the value in nS:2 may not be what you expect. The following instructions manipulate the offset value in nS:2:BSL/BSRBit Shift Left/RightCOPFile CopyDDTDiagnostic DetectFLLFile FillFFL/FFUFIFO Load/UnloadFSCFile Search and CompareLFL/LFULIFO Load/UnloadSQI/SQL/SQOSequencer Input/Load/OutputFALFile Arithmetic and LogicFBCFile Bit CompareIMPORTANT:File instructions manipulate the offset value stored at nS:2. Make sure you monitor or load the offset value you want prior to using an indexed address. Otherwise, unpredictable machine operations could occur, with possible damage to equipment and injury to personnel.
Indexed Addressing Example
The following
MVM
example uses an indexed address in the source and destination addresses. If the offset value is 10 (stored in 1S:2), the processor manipulates the data stored at the base address plus the offset.MVM | |
MASKED MOVE | |
Source | #1N7:10 |
Mask | 00110011 |
Destination | #1N11:5 |
In this example, the processor uses these addresses:
Value: | Base Address: | Offset Address: |
---|---|---|
Source | 1N7:10 | 1N7:20 |
Destination | 1N11:5 | 1N11:15 |
Provide Feedback