Siemens S7-1500 PLC Direct Addressing vs Indirect Addressing: Complete Comparison and Examples
1. Core Differences Comparison Table
| Feature | Direct Addressing | Indirect Addressing |
|---|---|---|
| Definition | Fixed specific address hardcoded in the program | Dynamic calculation of address in the program |
| Syntax | L MW10 |
L ID[AR1,P#0.0] |
| Address Source | Hardcoded (e.g., MW10) | Pointer variables/registers (AR1/AR2) |
| Flexibility | Low (requires program modification) | High (can change at runtime) |
| Applicable Scenarios | Simple fixed logic | Arrays, loops, dynamic tables |
| Execution Speed | Fastest | Slower (requires calculation) |
| Code Volume | Least | More (requires pointer calculations) |
| Debugging Difficulty | Simple | Complex (requires monitoring pointers) |
| Memory Usage | Minimum | Requires additional pointer variables |
| S7-1500 Support | Full support | Enhanced support (ANY pointer) |
2. Practical Application Scenario Comparison
| Scenario | Direct Addressing ❌ | Indirect Addressing ✅ |
|---|---|---|
| 8 Temperature Sensors | L MW0 T MW8L MW1 T MW9… |
1 line of code for loop processing |
| Recipe Table | 8 IF statements | 1 pointer to switch recipes |
| HMI Dynamics | Modify program | Change address at runtime |
| Data Movement | 8 MOV instructions | BLKMOV for batch processing |
3. 1:1 Corresponding Example Comparison
Scenario: Processing 8 Temperature Sensors (I0.0-I0.7 → MW0-MW7)
3.1 Direct Addressing Version (OB1, simple but cumbersome)
| Network | STL Code | Description | Disadvantages |
|---|---|---|---|
| 1 | A I0.0 L IW4 T MW0 |
Channel 1 | Repeat 8 times |
| 2 | A I0.1 L IW4 T MW1 |
Channel 2 | Modification is troublesome |
| 3 | A I0.2 L IW4 T MW2 |
Channel 3 | … |
| … | … | … | 8 networks! |
| 8 | A I0.7 L IW4 T MW7 |
Channel 8 |
3.2 Indirect Addressing Version (OB1, 1 network solves it)
| Network | STL Code | Description |
|---|---|---|
| 1 | OPN DB1L MW20 // Index 0-7*L 0.1 // Bit offset L P#I0.0 T AR1 + AR1 P#0.0 A I[AR1,P#0.0] L IW4 T ID[AR1,P#8.0] |
Process all channels once |
4. Complete Project Example
DB1 Data Block
| Address | Name | Type | Description |
|---|---|---|---|
| DBD0 | Temp_Direct[1..8] | ARRAY[1..8] OF INT | Direct method |
| DBD16 | Temp_Indirect[1..8] | ARRAY[1..8] OF INT | Indirect method |
| DBD32 | Index | INT | Indirect index |
Test Program (OB1)
// ========== Direct Addressing (NETWORK 1-8) ==========\n// A I0.0 L IW4 T MW0 // Channel 1\n// A I0.1 L IW4 T MW1 // Channel 2\n// ... Repeat 8 times\n\n// ========== Indirect Addressing (NETWORK 9) ==========\nNETWORK 9\nOPN DB1\nL MW100 // Loop counter 0-7\nAN 7\nJCN END\nL MW100\nT MW32 // Store index\n*L 0.1\nL P#I0.0\nT AR1\n+AR1 P#0.0 // AR1 points to I0.x\nA I[AR1,P#0.0] // Indirect read input\nL IW4 // Read analog quantity\nL MW32 // Get index\n*L 2 // INT byte count\nL P#DB1.DBD16 // Array base address\nT AR1\n+AR1 P#0.0 // Calculate target address\nT ID[AR1,P#0.0] // Indirect write\nEND:\n
Here comes the valuable content;
Siemens S7-1500/1200/200 Physical Simulation Software (Available for Download)
Dozens of Siemens 1500 learning materials and manuals (available for download)
Electrical simulation software for Android (available for download)
Siemens 200 Smart and physical simulation, bundled with 3 software (available for download)
Siemens S7-1500/1200 simulation software (software and learning materials available for download)
Siemens S7-200 Smart and S7-200 Smart simulation software (available for download)
Siemens S7-200 SMART simulation software (available for download)
Circuit simulation software used by 100,000 people (available for download)
PLC simulation software used by 200,000 people (includes tutorial available for download)