Chapter 5

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.

ABSeries ANDParallel ORXOR
00000
01011
10011
11110

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.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 YF=Enable FRˉdY_F=\mathrm{Enable}\,F\bar R_d and YR=Enable RdFˉY_R=\mathrm{Enable}\,R_d\bar F, where F,RdF,R_d 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.

BlockBehaviour when executed cyclically
TON: on-delayInput becomes true: accumulate elapsed time; output becomes true after preset time; input false resets elapsed time and output
TOF: off-delayInput 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: pulseRising edge starts a fixed-duration output pulse in the basic non-retriggerable model
Retentive on-delayAccumulated elapsed time survives enable becoming false; a reset clears it; power-cycle retention is separate
CTUIncrement on a rising input edge; reset clears count
CTDLoad 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.

StateRequested actionAdvance whenNext state
0: idleBoth cylinders retractedStart and a0a_0 and b0b_01
1A+A+, hold B retracteda1a_12
2Hold A extended; B+B+b1b_13
3Hold A extended; B−B-b0b_04
4A−A-, hold B retracteda0a_00

Here a0,a1,b0,b1a_0,a_1,b_0,b_1 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.

Revise offline: the whole CAD/CAM and Automation handbook as one PDF

40 pages · 1.8 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections