Allen-Bradley Ladder Logic Basics — Programming in Studio 5000
Key Takeaway
Fundamentals of ladder logic programming in Studio 5000 for Allen-Bradley PLCs — contacts, coils, timers, counters, comparison, and math instructions with worked examples.
Quick Answer
Ladder logic is the most common programming language for Allen-Bradley PLCs. It uses a graphical format resembling electrical relay diagrams, with horizontal rungs containing contact instructions (inputs) on the left and coil instructions (outputs) on the right. Studio 5000 provides a comprehensive ladder logic instruction set for discrete control, timing, counting, comparison, and mathematical operations.
What Is Ladder Logic and Why It Is Used
Ladder logic was designed to be readable by electricians familiar with relay wiring diagrams. Each rung represents a logical condition: if the contacts on the left side of the rung evaluate to true (continuity), the output instructions on the right side execute. This visual approach makes ladder logic the preferred language for discrete I/O control, motor circuits, interlocks, and safety logic.
Rungs, Contacts, and Coils
A ladder logic program is a series of rungs between two power rails. Each rung contains:
- Contacts — Input conditions that test tag values
- Coils — Output actions that set tag values
- Branches — Parallel paths for OR logic
XIC and XIO Contact Instructions
- XIC (Examine If Closed) — Passes continuity when the referenced BOOL tag is true (1). This is the normally open contact, equivalent to pressing a pushbutton.
- XIO (Examine If Open) — Passes continuity when the referenced BOOL tag is false (0). This is the normally closed contact, used for stop buttons and safety interlocks.
Output Instructions
- OTE (Output Energize) — Sets the output tag true when the rung is true, false when the rung is false. The most common output instruction.
- OTL (Output Latch) — Sets the output tag true when the rung is true. The tag remains true even after the rung goes false (latching behavior).
- OTU (Output Unlatch) — Resets a latched output to false. Always pair OTL and OTU instructions for the same tag.
Timer Instructions
- TON (Timer On-Delay) — Starts timing when the rung goes true. The .DN bit sets after the preset time elapses. Resets when the rung goes false.
- TOF (Timer Off-Delay) — The .DN bit is true while the rung is true and remains true for the preset time after the rung goes false.
- RTO (Retentive Timer) — Like TON but retains the accumulated time when the rung goes false. Must be explicitly reset with a RES instruction.
Counter Instructions
- CTU (Count Up) — Increments the accumulated value on each false-to-true transition of the rung. The .DN bit sets when ACC reaches PRE.
- CTD (Count Down) — Decrements the accumulated value on each false-to-true transition.
- RES (Reset) — Resets a timer or counter accumulated value to zero and clears all status bits.
Comparison Instructions
Used for analog value comparisons:
- EQU — Equal | NEQ — Not Equal
- GRT — Greater Than | LES — Less Than
- GEQ — Greater Than or Equal | LEQ — Less Than or Equal
Math Instructions
- ADD, SUB, MUL, DIV — Basic arithmetic
- MOV (Move) — Copies a value from Source to Destination
- COP (Copy) — Copies a block of data elements
- SQR, ABS, NEG — Square root, absolute value, negate
Example: Motor Start/Stop with Seal-In Circuit
Rung 0: [XIC Start_PB] --+-- [OTE Motor_Run]
|
[XIC Motor_Run] --+
[XIO Stop_PB] --------
Rung 1: [XIC Motor_Run] ------ [OTE Motor_Contactor]
Pressing Start_PB energizes Motor_Run. The XIC Motor_Run branch seals in the circuit. Pressing Stop_PB (normally closed) breaks continuity and de-energizes Motor_Run.
Example: Timed Pump Cycle Using TON
Rung 0: [XIC Cycle_Enable] ---- [TON Pump_Timer PRE:300000]
Rung 1: [XIC Pump_Timer.DN] --- [OTE Pump_Start]
When Cycle_Enable is true, the TON timer counts for 300 seconds (300000ms). When the timer completes, Pump_Start energizes.
Frequently Asked Questions
XIC (Examine if Closed) is a normally open contact instruction. It passes logic continuity when the referenced tag bit is true (1). It is the most common contact instruction in ladder logic programs.
Use OTL (Output Latch) to set a bit when a condition is true and OTU (Output Unlatch) on a separate rung to reset it. The bit retains its state even after the set condition goes false.