Program a PLC with contacts, coils, timers and counters and test it in your browser
Choose a tool and click a cell in the diagram to place it. Contacts go in the six columns and outputs in the right-hand column. The rows below create parallel branches. While the PLC is in RUN, press the inputs and you will see in green where the current flows.
¬ = normally closed contact (NC), ↑ = rising edge, · = AND (series), + = OR (parallel).
A PLC (Programmable Logic Controller) is an industrial computer that reads sensors and push buttons through its inputs, runs a program and drives contactors, valves or pilot lights through its outputs. It replaces relay panels, which is why its most widespread language, ladder logic or ladder diagram, mimics an electrical control schematic rotated 90°.
The program repeats endlessly in a scan cycle lasting a few milliseconds:
Ladder is one of the five languages of the IEC 61131-3 standard, together with function block diagram (FBD), structured text (ST), instruction list (IL, STL in Siemens) and sequential function chart (SFC or Grafcet).
| Symbol | Name | Operation |
|---|---|---|
| ─| |─ | Normally open contact (NO) | Lets current through when its bit is 1. |
| ─|/|─ | Normally closed contact (NC) | Lets current through when its bit is 0. |
| ─|P|─ | Positive edge | Conducts only during the scan in which the bit goes from 0 to 1. |
| ─( )─ | Coil | Copies the rung result into its bit: 1 if current reaches it, 0 if not. |
| ─(S)─ | Set | Sets the bit to 1 and keeps it there even if the rung stops conducting. |
| ─(R)─ | Reset | Sets the bit to 0. On a counter or timer, it resets it. |
| [TON] | On-delay timer | Its output turns on once the input has been on for the preset time. |
| [TOF] | Off-delay timer | Its output turns on immediately and turns off a set time after the input drops. |
| [CTU] | Up counter | Adds 1 on each rising edge. Its output turns on when it reaches the preset. |
Contacts in series form an AND function and contacts in parallel an OR function. That is why every rung is equivalent to a Boolean algebra equation, which the simulator shows below the diagram.
The contact in the program is not the physical push button: it only asks whether the input is 1 or 0. For safety, the stop button is wired normally closed (NC), so its input is 1 at rest. The program then uses a normally open contact: if the wire breaks, the input drops to 0 and the machine stops by itself. In the simulator the inputs are normally open push buttons, which is why the stop in the examples uses an NC contact.
| Manufacturer | Input | Output | Internal bit | Software |
|---|---|---|---|---|
| Siemens (S7-1200/1500) | I0.0 (E0.0 in German) | Q0.0 (A0.0) | M0.0 | TIA Portal |
| IEC 61131-3 (CODESYS) | %IX0.0 | %QX0.0 | %MX0.0 | CODESYS |
| Allen-Bradley (Rockwell) | I:0/0 or Local:1:I.Data.0 | O:0/0 | B3:0/0 | Studio 5000, RSLogix |
| Omron | 0.00 | 100.00 | W0.00 | CX-Programmer, Sysmac Studio |
| Mitsubishi | X0 | Y0 | M0 | GX Works |
| Delta | X0 | Y0 | M0 | ISPSoft, WPLSoft |
The simulator uses Siemens notation: I = input, Q = output, M = memory bit, T = timer and C = counter.
The Q0.0 contact in parallel with Start acts as a seal-in: when you release the button, the output itself keeps the rung conducting until Stop opens it. Equation: \(Q0.0 = (I0.0 + Q0.0) \cdot \overline{I0.1}\). Set and Reset achieve the same, but if both are pressed at once the last rung wins (here, the Reset).
KM1 (line) seals in as in the start-stop and starts T0. While T0 is timing, KM2 (star) is on. After 5 s KM2 drops out and KM3 (delta) comes in. The crossed NC contacts of KM2 and KM3 form the electrical interlock that prevents both from being on at once, which would be a short circuit. In the real panel an interlock with auxiliary contacts is also added.
The rising edge generates a one-scan pulse in M0.0. The second rung is an exclusive OR (XOR) between the pulse and the output: each pulse inverts Q0.0. Without the edge, the output would toggle on every scan while the button is held down.
Related: Boolean algebra, Karnaugh map, number systems and three-phase motor connection.