Sitelet https://plcsimulationsoftware.com/plc-codes
PLC Simulator
PLC code reference

PLC Codes: Common Instructions, Code Examples & Faults

PLC codes are the instructions and programs that tell a programmable logic controller what to do, such as XIC (examine if closed), OTE (output energize), TON (on-delay timer) and CTU (count up). The same phrase also covers controller and drive fault codes. This reference explains both, with PLC code examples you can run in the browser.

Reference PLC students, maintenance technicians and programmers
Real PLC codes and examples footage

See this exact skill in the working simulator.

Watch the real browser product respond to the task on this page, then try the same practical workflow yourself. No slides, concept mockups, install, or credit card.

Try this in the browser
PLC Codes — See Instructions Become Working Machine Logic

Three meanings, one evidence path

Connect instruction codes, working patterns and fault evidence

Use the visual sequence to identify the code type first. Then open the matching reference, run the control pattern and preserve the exact diagnostic evidence before consulting the hardware manual.

PLC training bench connecting ladder instructions, a guarded machine, live I/O evidence, measurements and a technical manual
Use the evidence-first troubleshooting method
01Separate program syntax from machine behavior and hardware diagnostics; a useful answer preserves all three layers of evidence.
PLC timer and counter instruction path connected to observable machine events
Open the PLC instruction reference
02Read the instruction contract, including timing base, edge behavior and reset conditions, before reusing a mnemonic.
Ladder logic seal-in motor example with start, stop, holding contact and motor output behavior
Study tested ladder logic examples
03A complete pattern combines instructions with permissives, reset behavior and observable tests instead of presenting an isolated code fragment.
Industrial PLC instruction-family bench connecting contacts, coils, timing, counting, data movement and comparison to physical inputs and outputs
Compare instruction families and syntax
04Instruction families become memorable when each mnemonic is tied to its scan behavior, operands and observable machine result.
PLC scan-cycle evidence board linking field inputs, ladder evaluation, timer and edge state to motor, valve and stack-light outputs
Learn the PLC scan cycle
05Read inputs, solve logic, update outputs and repeat: rung order and retained state explain why correct-looking code can still behave unexpectedly.
Guarded conveyor and motor control pattern shown under normal start, interlock stop and fault-recovery test states
Run tested ladder logic patterns
06A reusable code pattern is not complete until normal operation, boundary conditions, interlocks and recovery all produce the intended physical outcome.
PLC diagnostic workflow separating controller, remote input output, industrial network, drive and motor evidence before consulting the manual
Practice evidence-first fault finding
07Preserve the layer, code, timestamp and active condition first; then use the exact controller, module, network or drive manual for the recovery procedure.

Follow the workflow

Learn one step, use the product, inspect the evidence.

01

Instruction codes

Rockwell-style mnemonic codes include XIC, XIO, OTE, OTL, OTU, ONS, CTU and MOV. IEC systems express similar behavior with contacts, coils and standard function blocks such as TON, TOF and CTU.

Do this in the product

Build a contact-and-coil rung in the guided exercise, then use the PLC instruction reference for per-instruction truth tables, syntax notes and examples.

Open the exercise
02

Program examples

Useful examples combine instructions into patterns: seal-in motor control, start permissives, alarm latches, pump alternation, traffic-light sequences, counters and analog scaling. The pattern and its edge cases matter more than copying addresses.

Do this in the product

Use the ladder logic examples and PLC projects hubs to open a matching scenario in the simulator.

Open the exercise
03

Fault and diagnostic codes

CPU, I/O, drive and communication fault numbers are vendor-, family- and firmware-specific. Record the exact code, state and timestamp; preserve evidence; then use the manufacturer manual. Never clear a fault repeatedly without finding the cause.

Do this in the product

Practice the evidence workflow in electrical troubleshooting and commissioning scenarios without claiming a generic table replaces the manual.

Open the exercise
04

Portable Structured Text

IEC Structured Text uses statements such as IF, CASE, FOR and function blocks. Vendor environments add libraries and data types, so test portability rather than assuming source code will compile unchanged.

Do this in the product

Compare the same lesson across IEC, Allen-Bradley and Siemens dialect views in the product.

Open the exercise
05

Scan-state and recovery codes

A status bit is only meaningful in context: the input image that was sampled, the rung order, the current timer or counter state, the output update and the task that owns the code. Preserve that state before forcing, resetting or editing anything.

Do this in the product

Run a normal case, an edge case and a recovery case; compare the live I/O and test evidence before accepting the program.

Open the exercise

Field reference

Read the code, predict the scan, prove the result.

These tables separate instruction syntax, reusable control patterns and hardware diagnostics. Use them to choose the right reference before changing a running program.

First identify what “PLC code” means

Searches for PLC codes mix four different jobs. Start here so a ladder mnemonic is not confused with a CPU fault number or a complete control program.

Code typeExamplesUse it forCorrect next step
Instruction mnemonicXIC, XIO, OTE, TON, CTU, MOVBuilding one operation inside ladder or Structured TextCheck operands and scan behavior in the instruction manual, then run a focused test.
Program patternSeal-in, permissive chain, alarm latch, pump alternationCombining instructions into a reusable control behaviorTest normal, boundary, interlock and recovery cases against the machine brief.
Controller or I/O diagnosticMajor fault type/code, module status, channel diagnosticLocating a CPU, task, connection, module or channel problemPreserve the event record and open the manual for the exact controller and firmware.
Drive or field-device faultOvercurrent, undervoltage, encoder, network or thermal tripDiagnosing a VFD, servo, instrument or smart deviceRecord active conditions and use the exact device-family manual; do not substitute a generic list.

PLC code examples: what the code looks like

Each row shows one control task as Allen-Bradley ladder instructions (read left to right, one rung per line) and as IEC 61131-3 Structured Text. Stop buttons are wired normally closed on real panels, so the healthy input is true and the rung examines it as closed (XIC), not open (XIO).

TaskLadder instructions (Allen-Bradley)Structured Text (IEC 61131-3)What to test
Motor start/stop with seal-inBranch [XIC Start_PB | XIC Motor] → XIC Stop_PB → XIO Overload → OTE MotorMotor := (Start_PB OR Motor) AND Stop_PB AND NOT Overload;Motor stays on after Start is released and drops out on Stop, overload and a broken Stop wire.
Forward/reverse interlockXIC Fwd_PB → XIO Rev → OTE Fwd; XIC Rev_PB → XIO Fwd → OTE RevFwd := Fwd_PB AND NOT Rev; Rev := Rev_PB AND NOT Fwd;Both directions can never be true together, even when both buttons are pressed; pair it with a hardwired interlock.
On-delay timerXIC Run → TON Delay_T (preset 5000 ms); XIC Delay_T.DN → OTE FanDelay(IN := Run, PT := T#5S); Fan := Delay.Q;Fan waits 5 s after Run turns on, turns off immediately with Run and restarts timing from zero.
Count partsXIC Photo_Eye → CTU Parts_C (preset 12); XIC Parts_C.DN → OTE Case_Full; XIC Reset_PB → RES Parts_CCount(CU := Photo_Eye, R := Reset_PB, PV := 12); Case_Full := Count.Q;One count per part even when the beam stays blocked for many scans; Reset returns the count to zero.
Count each button press onceXIC Button → ONS Button_OS → ADD Presses 1 PressesEdge(CLK := Button); IF Edge.Q THEN Presses := Presses + 1; END_IF;Holding the button adds exactly one; releasing and pressing again adds one more.

PLC instruction codes by scan behavior

Names vary by vendor. The transferable part is the state transition: what is read, what is retained, when an edge is recognized and what must reset.

FamilyCommon codesWhat changes during the scanMinimum proof test
ContactsXIC / XIO; NO / NC contactThe rung condition reads a Boolean tag; the symbol does not change the physical wiring.Toggle the source bit and verify both true and false paths.
OutputsOTE / coil; SET-RESET; OTL / OTUA non-retentive coil follows the solved rung; latch instructions retain state until an explicit reset.Prove de-energization on Stop, interlock and restart.
TimersTON, TOF, TP, RTOElapsed state advances with scan time while enabling conditions and reset rules differ.Test just below, at and just above the preset, then interrupt and restart.
CountersCTU, CTD, CTUD, RESCounts normally change on a qualifying edge, not on every scan that the input remains true.Hold the input true, pulse it repeatedly and verify reset and rollover assumptions.
EdgesONS, OSR, R_TRIG, F_TRIGThe output is true for one execution when the remembered previous state changes.Prove one pulse per transition and verify first-scan behavior.
Compare and limitEQU, NEQ, GRT, LES, LIM; EQ, GT, LTThe rung result depends on type, sign, scaling and boundary inclusion.Test both boundaries, one value outside each side and invalid or stale data.
Data and mathMOV, COP, ADD, SUB, MUL, DIV, SCALEValues change immediately for later rungs in the same task; type conversion can truncate or overflow.Check data types, zero division, range limits and downstream rung order.
Sequence and stateCASE, sequencer, step bits, state machineOnly permitted transitions should advance the process; recovery must return to a defined state.Test every transition, aborted step, power-up state and manual recovery path.

Fault-code evidence workflow

A numeric code without provenance is weak evidence. Capture the surrounding state before changing the plant, then consult the authoritative manual.

LayerCapture before resetLikely evidence sourceUnsafe shortcut to avoid
Controller and taskMode, major/minor class, type/code, task and timestampController fault log, diagnostic buffer and programming manualRepeatedly clearing a major fault without locating the triggering instruction.
Remote I/O and channelModule state, channel state, field power and last known valueModule status page, wiring diagram and module manualAssuming a logic fault when field power or a channel is unhealthy.
Industrial networkLink state, connection status, topology, device reachability and sequence of eventsManaged-switch diagnostics, controller connections and device manualReplacing a device before checking power, cabling, addressing and connection state.
Drive and motorDrive trip, DC bus, current, speed command, thermal state and run sourceExact VFD/servo manual plus measured electrical and mechanical evidenceResetting an overcurrent or thermal trip and immediately restarting the load.
Program behaviorInput image, rung state, retained bits, timer/counter values and commanded outputsOnline monitor, trend, event log and repeatable simulator testTreating an energized output command as proof that the actuator moved safely.

Core concepts

Know what the evidence means.

The simulator creates a repeatable result; these concepts make that result transferable to real vendor software and supervised practical work.

Mnemonic

A short instruction identifier such as XIC or OTE. Meaning and operand rules depend on the platform.

Pattern

A tested arrangement of instructions that solves a recurring control problem, including reset and fault behavior.

Diagnostic evidence

Code, timestamp, active state, surrounding I/O and preceding event sequence make a fault number actionable.

Scan contract

The same code can produce a different result when rung order, retentive state, edge detection or task timing changes. Predict the scan before editing the pattern.

Common mistakes to avoid

  • × Treating all vendor mnemonics as interchangeable
  • × Copying a latch without a safe reset path
  • × Using a generic fault-code table for real hardware
  • × Publishing a code example without a runnable test
  • × Clearing a fault before preserving its timestamp and active state
  • × Assuming a green rung proves the machine completed the required behavior

Continue in the workspace

Turn this tutorial into retained training evidence.

Run the foundation exercise publicly, then use a subscription for advanced challenges, saved configurations, full attempt history, sharing, assigned paths and team reporting.

Technical reference questions

Questions before you continue.

A PLC code is either an instruction in a PLC program, such as XIC, OTE or TON, a complete control program, or a diagnostic number reported by a controller, module or drive. Instruction codes and programs tell the PLC what to do; fault codes tell you what went wrong and must be read against the exact manufacturer manual.

Technical reference and worked-example guide

PLC codes and examples: field reference

Direct answer

The reader can classify the code being searched, find its correct owner and verify meaning in the target context.

Written for learners and technicians trying to distinguish instruction mnemonics, sample logic, controller faults and device diagnostics.

Automation engineer checking PLC signal timelines, executable logic and training-rack behavior for PLC instruction, program and fault-code navigation
System map / 02

NODE 01observable

Definition

Vendor, controller or device, software, firmware, code text or number, screen, timestamp, operating state and preceding event.

NODE 02observable

Signal path

Observed code through the correct instruction reference, program context or diagnostic manual to an evidence-based next action.

NODE 03observable

Worked example

One known instruction and one known fault interpreted with source and context retained.

NODE 04observable

Limits

Same number across vendors, decimal versus hexadecimal, stale alarm, translated wording, symptom code and undocumented reset.

NODE 05observable

Common mistake

An identity, context, source, interpretation, program, device or process-response mismatch.

NODE 06observable

Verification

The conclusion verified in current official documentation and against the actual controller or device state.