Understanding Instruction List for PLC Programming

An Instruction List (IL) is a low-level programming language used in industrial automation, specifically for Programmable Logic Controllers (PLCs) and other industrial control systems. It is one of the five standard languages defined by the IEC 61131-3 standard (the global standard for PLC programming) and is modeled after assembly language—using simple mnemonics (e.g., LD for “Load”, AND for logical AND) to represent operations executed sequentially. IL is particularly useful for small-scale control tasks, troubleshooting, or optimizing performance-critical code.

Core Characteristics of Instruction List

1. Low-Level, Assembly-Like Syntax

IL uses a line-by-line structure where each line consists of:

  • mnemonic (operation code, e.g., LDOROUT).
  • An operand (memory address, constant, or variable, e.g., I0.0Q0.1MW10).
  • Optional comment (for documentation, prefixed by // or ;).

Example line:

il

LD I0.0       // Load input I0.0 (sensor signal) into the accumulator

2. Accumulator-Based Execution

IL relies on a virtual accumulator (a temporary storage register) to hold intermediate results:

  • Most operations read from the accumulator, process data, and write back to the accumulator.
  • The accumulator stores boolean (1/0) values for logic operations or numerical values (integers, floats) for arithmetic operations.

3. Sequential Execution

Instructions are executed in the order they are written (top to bottom), unless conditional jumps (e.g., JMPJC) are used to alter the flow. This makes IL straightforward for linear control logic but less intuitive for complex branching than graphical languages like Ladder Diagram (LD).

4. Support for Multiple Data Types

IL handles both boolean (discrete) and non-boolean (analog) data:

  • Boolean: For logic operations (e.g., I0.0 = input sensor, Q0.1 = output relay).
  • Integer/Float: For arithmetic operations (e.g., MW10 = 16-bit memory word, MD20 = 32-bit floating-point register).
  • Timers/Counters: For time-based or count-based control (e.g., T1 = on-delay timer, C5 = up-counter).

Key Instructions in IL

IEC 61131-3 defines standard IL mnemonics, grouped by function:

1. Boolean Logic Instructions

MnemonicDescriptionExample
LDLoad operand into accumulator (start of logic rung)LD I0.0 (Load input I0.0)
LDNLoad negated operand (NOT)LDN I0.1 (Load NOT I0.1)
ANDLogical AND with accumulatorAND I0.2 (Accumulator = Accumulator AND I0.2)
ANDNLogical AND with negated operandANDN I0.3 (Accumulator = Accumulator AND NOT I0.3)
ORLogical OR with accumulatorOR I0.4 (Accumulator = Accumulator OR I0.4)
ORNLogical OR with negated operandORN I0.5 (Accumulator = Accumulator OR NOT I0.5)
XORLogical XOR with accumulatorXOR I0.6 (Accumulator = Accumulator XOR I0.6)
NOTInvert accumulator value (1→0, 0→1)NOT
OUTWrite accumulator value to output operandOUT Q0.0 (Set output Q0.0 to accumulator value)

2. Arithmetic Instructions

MnemonicDescriptionExample
LDILoad integer constant into accumulatorLDI 100 (Load 100 as integer)
ADDAdd operand to accumulatorADD MW10 (Accumulator = Accumulator + MW10)
SUBSubtract operand from accumulatorSUB MD20 (Accumulator = Accumulator – MD20)
MULMultiply accumulator by operandMUL 2.5 (Accumulator = Accumulator × 2.5)
DIVDivide accumulator by operandDIV MW30 (Accumulator = Accumulator ÷ MW30)
STIStore accumulator (integer) to operandSTI MW40 (Save accumulator value to MW40)

3. Timer/Counter Instructions

MnemonicDescriptionExample
TONOn-delay timer (start timer, output goes high after preset time)TON T1, PT=100 (Timer T1, preset 100ms)
TOFOff-delay timer (output stays high for preset time after input goes low)TOF T2, PT=500 (Timer T2, preset 500ms)
CTUUp-counter (increment count on input trigger)CTU C1, PV=10 (Counter C1, preset 10 counts)
CTDDown-counter (decrement count on input trigger)CTD C2, PV=5 (Counter C2, preset 5 counts)

4. Jump Instructions (Flow Control)

MnemonicDescriptionExample
JMPUnconditional jump to labelJMP LABEL1 (Jump to LABEL1)
JCJump if accumulator is 1 (conditional)JC LABEL2 (Jump to LABEL2 if accumulator = 1)
JNCJump if accumulator is 0 (conditional)JNC LABEL3 (Jump to LABEL3 if accumulator = 0)
LABELDefine a jump targetLABEL1: (Label for jump target)

Example IL Program

Below is a simple IL program for a motor control system:

  • InputsI0.0 (Start button), I0.1 (Stop button), I0.2 (Overload sensor).
  • OutputQ0.0 (Motor relay).
  • Logic: Start motor when I0.0 is pressed; stop when I0.1 or I0.2 is triggered (latching control).

il

// Motor Control IL Program
LD I0.0       // Load Start button (I0.0)
OR Q0.0       // Latch: OR with motor output (Q0.0) to keep motor running
ANDN I0.1     // Stop if Stop button (I0.1) is pressed (NOT I0.1)
ANDN I0.2     // Stop if Overload sensor (I0.2) is triggered (NOT I0.2)
OUT Q0.0      // Write result to motor output (Q0.0)

// Optional: Timer to auto-stop motor after 10 seconds
LD Q0.0       // Load motor output status
TON T1, PT=100 // Start on-delay timer T1 (100ms × 100 = 10s)
LD T1         // Load timer T1 output
OUT Q0.1      // Trigger auto-stop indicator (Q0.1)
JNC END       // If timer not expired, jump to END
LD 0          // Load 0 to stop motor
OUT Q0.0      // Turn off motor output
END:          // Label for jump target

Use Cases for Instruction List

1. Small-Scale Control Logic

IL is ideal for simple tasks (e.g., motor start/stop, sensor monitoring) where minimal code is needed and speed is critical.

2. Troubleshooting & Debugging

IL’s line-by-line structure makes it easy to trace execution step-by-step, which is useful for diagnosing issues in complex PLC programs.

3. Performance Optimization

Since IL is low-level, it can be optimized for faster execution (e.g., reducing memory accesses) compared to higher-level languages like Structured Text (ST).

4. Legacy System Support

Many older PLCs (e.g., Siemens S5, Allen-Bradley MicroLogix) use IL or assembly-like languages, so IL is still relevant for maintaining legacy systems.

5. Hybrid Programming

IL is often combined with other IEC 61131-3 languages (e.g., Ladder Diagram for main logic, IL for arithmetic subroutines) to balance readability and performance.

IL vs. Other IEC 61131-3 Languages

FeatureInstruction List (IL)Ladder Diagram (LD)Structured Text (ST)
SyntaxAssembly-like, line-by-lineGraphical (rungs, contacts/coils)Text-based (Pascal-like)
ReadabilityLow (for complex logic)High (for electrical engineers)High (for software engineers)
PerformanceHigh (minimal overhead)Medium (graphical abstraction)Medium (compiled to IL)
Best ForSmall logic, troubleshooting, optimizationIndustrial control (motor, conveyor)Complex algorithms (PID, math)
Learning CurveSteep (requires low-level understanding)Gentle (familiar to electricians)Moderate (programming experience)

Advantages & Limitations of IL

Advantages

  • Speed: Minimal execution overhead, ideal for time-critical operations.
  • Precision: Direct control over memory and registers (useful for hardware-specific tasks).
  • Compactness: Requires fewer lines of code than graphical languages for simple logic.

Limitations

Limited Abstraction: No built-in functions for complex tasks (e.g., string handling) compared to Structured Text.

Low Readability: Difficult to follow for complex branching or large programs (graphical languages like LD are better).

Error-Prone: Manual memory management and line-by-line execution increase risk of bugs (e.g., missing OUT instructions).



了解 Ruigu Electronic 的更多信息

订阅后即可通过电子邮件收到最新文章。

Posted in

Leave a comment