Programmable logic controllers
A PLC executes logic on stored input values and updates outputs according to a defined schedule. Solve logic questions as a sequence of scans, not as an instantaneous electrical circuit.
5.1 Architecture, scan and I/O
A PLC contains a power supply, CPU, program/data memory, input modules, output modules and communication interfaces. Digital I/O represents on/off states; analogue I/O represents measured or commanded magnitudes. Relay, transistor and triac outputs have different load/switching characteristics. An output module may drive a contactor or valve interface rather than the full machine load.
The basic cyclic model is: sample inputs into an input image, execute the program in order, transfer the output image to physical outputs, and perform housekeeping. Some controllers label the cycle boundary before output transfer, or use asynchronous/immediate I/O; use the specified schedule. Internal bits written earlier in a scan can affect later rungs even though physical outputs have not yet updated.
A pulse shorter than the sample interval can be missed entirely. A high-speed counter, input latch or interrupt can capture events beyond ordinary cyclic sampling. These are distinct from simply shortening the ladder program.
5.2 Ladder contacts and Boolean logic
A normally-open logical contact passes when its addressed bit is 1; a normally-closed logical contact passes when that bit is 0. This is a test of stored data, not a declaration that the field switch is physically NO or NC. Series contacts implement AND; parallel paths implement OR.
| A | B | Series AND | Parallel OR | XOR |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
Ladder diagram (LD) represents contact/coil logic; function block diagram (FBD) connects functional blocks; structured text (ST) expresses operations textually. Sequential function charts (SFC) organise steps and transition conditions. Recognition of these forms is enough for reading a basic automation program; exact instruction syntax is controller-specific.
5.3 Seal-in, reset priority and interlocks
A momentary Start input needs memory to maintain Run after release. A Stop condition must break both the starting path and the holding path. A physically normally-closed stop circuit commonly produces an “OK” input bit equal to 1 while healthy.
A logical seal-in rung with the OK contact ahead of both paths.
Forward/reverse outputs should be mutually interlocked. To make simultaneous direction requests select neither direction, use and , where are direction requests. Trace memory and rung order if seal-in logic is added. Electrical/mechanical interlocks can complement PLC logic; a standard ladder rung alone is not a certified emergency-stop function.
5.4 Edges, timers and counters
A held sensor should count as one arrival, not one arrival per scan. Use an edge detector. Each timer/counter instance has its own stored state; skipping its execution can change behaviour according to the PLC implementation.
| Block | Behaviour when executed cyclically |
|---|---|
| TON: on-delay | Input becomes true: accumulate elapsed time; output becomes true after preset time; input false resets elapsed time and output |
| TOF: off-delay | Input true turns output on; input falling starts the delay; output turns off after the preset if input stays false; a new true input cancels the off-delay |
| TP: pulse | Rising edge starts a fixed-duration output pulse in the basic non-retriggerable model |
| Retentive on-delay | Accumulated elapsed time survives enable becoming false; a reset clears it; power-cycle retention is separate |
| CTU | Increment on a rising input edge; reset clears count |
| CTD | Load preset when commanded; decrement on rising count-input edges; done condition commonly count at/below zero |
5.5 State-based actuator sequencing
Use one active state to represent each step. Evaluate transition conditions from a saved current state, then update the state once per scan. This avoids accidental multiple transitions when several independent rungs immediately overwrite the same state variable.
| State | Requested action | Advance when | Next state |
|---|---|---|---|
| 0: idle | Both cylinders retracted | Start and and | 1 |
| 1 | , hold B retracted | 2 | |
| 2 | Hold A extended; | 3 | |
| 3 | Hold A extended; | 4 | |
| 4 | , hold B retracted | 0 |
Here are the end-position input bits defined in Section 4.7. For monostable valves chosen so coil on extends, A's coil is on in states 1, 2, 3; B's is on only in state 2. Bistable valves instead need the appropriate directional pulse when entering a state; “off” alone does not command retraction.
If Start stays high, the basic sequence restarts when idle conditions become true again. For one cycle per press, use a rising-edge start request or a separate re-arm state. Add a timer only when the process specifies a dwell or timeout; do not replace an end-position condition with an assumed travel time.
Last-minute recall
- PLC contacts test bits; physical contact wiring determines how those bits become 0 or 1.
- Trace inputs, rung order, internal memory and output transfer separately.
- AND is series, OR is parallel, and an NC logical contact complements its bit.
- Put Stop/OK outside both Start and holding branches.
- When set and reset are simultaneous, the specified priority decides the state.
- A counter counts edges; a steady high signal is not a stream of new parts.
- TON delays switch-on; TOF delays switch-off; a retentive timer needs reset semantics.
- Short pulses can fall entirely between two input samples.
- Use current/next state separation to permit only the intended transition in one scan.