Support-focused enterprise controls: PLC Basics

PLC programs do not behave like scripted language programs used by most computer applications. A basic understanding of control application fundamentals is crucial for designing an effective support-focused system. This section of the article provides strategists with the rudimentary knowledge needed to recognize programming instructions, terms, logic circuits, and more. Link to parts 1, 2, and 3, below.


Figure 1 shows some instruction symbols and their associated bit, word, file, and special instruction names. Courtesy: Daniel B. CardinalBefore effectively producing a support-focused design that can efficiently interact with control applications, the designer must first have a basic understanding of control application fundamentals. However, before introducing control application fundamentals, this section of the article focuses on the basics of PLC programming. The material presented provides strategists with the rudimentary knowledge needed to recognize:

  1. Common programming instructions
  2. Control application terms
  3. Potential of machine controller programs
  4. Hard-coded and hardwired logic circuits
  5. Programming techniques that affect circuit styles
  6. Circuit substitution techniques.

PLC programs do not behave like scripted language programs used by most computer applications. PLC operating systems emphasize the continuous and high-speed scanning of all lines of code. The term "scanning" in this context means the successive and consecutive evaluation of each line of code. Designers call each line of code a ladder rung or logic circuit while referring to a group of rungs or circuits as an application. Designers rarely develop logic circuits that cause the controller's program to loop or continuously scan a subset of circuits. Looping on a subset of circuits delays the scan evaluation of other circuits. Evaluation delays create safety hazards when an unevaluated circuit is late or does not examine sensor input transitions in a timely manner. The slow or missed detection of these kinds of events can cause a controller circuit to keep an output signal enabled. Failure to shut off an output signal that enables movement can cause the mechanism or object to reach its physical stop position and crash.

It is often easier for computer programmers to think of ladder logic programs as lists of Boolean equations. Individual groups of equations make up separate controller applications. The machine controller constantly scans and evaluates each equation in every application. If the examinable equation conditions are true, the programmed output instruction acts to enable or disable an internal signal, output signal, or function variable. Each application shares a fraction of each program scan. The resulting net effect is equivalent to parallel processing all resident machine controller applications. The following definitions describe the circuits used to control the movement of a mechanism or object:

Logic circuit: a line of code that is part of a machine controller application

External circuit: any electric, pneumatic, optic, or hydraulic circuit that reacts to a machine controller's output signal to move an object or mechanism.

External circuits are physical circuits, while logic circuits are internal to a machine controller. The "external circuit" term refers to the arrangement of real-world devices that react to a controller's enabled output signal. Externally, output signals are connection points on a controller's output module. External circuits use wires from output connection points to enable relays, valves, and switches to activate a hydraulic, pneumatic, optic, and/or electric circuit. Logic circuits are lines of code with examinable elements and programmable resultants. Elements are discrete signals or application variables. Each logic circuit enables one or more resultants. A resultant is typically an enabled or disabled signal or a changeable register-stored value. It is common to have logic circuits that unconditionally enable resultants. Resultants for some logic circuits are output signals, which when enabled will activate external circuits. Designers often place examinable elements in series on a logic circuit to denote AND conditions. Instead of parenthesis, programmers use branches with one or more parallel elements to denote OR conditions. The following definitions describe some commonly used logic circuit programming terms:

Bit: a machine controller's smallest Boolean variable having only two values, either one (1) or zero (0)

Word: a machine controller's multi-bit (16, 32, 64, etc.) register used to store the contents of an application variable

Instruction: a single, programmable operation used to examine, compare, enable, disable, move, set, reset, or manipulate a bit or word value

Bit instruction: an operation used to examine, enable, or disable a bit value

Word instruction: an operation used to compare, move, set, reset, or manipulate a word value

File instruction: an operation used to compare, move, set, reset, or manipulate a multi-word data array

Special instruction: a unique programmable operation designed to support a specific application purpose.

Figure 1 shows some instruction symbols and their associated bit, word, file, and special instruction names. These common instructions are compatible with most application variables. Bit instructions represent examinable or changeable discrete signals. These signals denote the state of an internal, input, and output variable. An internal signal is a variable enabled by one circuit and examinable by others. An input signal typically represents the enabled or disabled state of a sensor, pushbutton, selector switch, or device. An output signal generally represents the activated or deactivated state of a light, external relay, or solenoid valve. One-shot, Time-On Timer, and Retentive Timer instructions are examples of special programming instructions. A One-Shot instruction enables designers to develop trigger circuits. A Time-On Timer instruction enables control applications to accumulate time when rung conditions are true. Unlike the Time-On Timer, a Retentive Timer holds the accumulated time value when the instruction is disabled. Word instructions are compatible with instructions that compare or manipulate multi-bit instructions. File instructions support the manipulation of contiguous groups of words. Most machine controllers also provide instructions that allow applications to examine and manipulate variables associated with eight-bit bytes, four-bit nibbles, and multi-bit application variables. 

Most of today's ladder logic circuits adopt a discrete bit instruction symbol that mimics the one used to represent electrical relay diagrams. More importantly, the relay coil, latch relay coil, unlatch relay coil, and other bit-level circuit instructions behave like their equivalent electromagnetic relay components. When a physical relay coil with normally opened contacts electrically energizes, an electromagnet pulls the contacts closed. When the coil de-energizes, a spring forces the contacts to return to their normally opened positions. A logical relay coil instruction energizes a discrete signal and keeps it energized provided the evaluated preconditions do not change state. When a precondition transitions to a false state, the machine controller disables the signal associated with the output instruction. Relay coil and latch/unlatch coil instructions, when used, produce the following types of circuits:

  • Setup circuit: a logic circuit that examines one or more serial or parallel conditions to enable the coil assigned discrete signal
  • Seal circuit: a setup circuit that examines the rung's relay coil assigned discrete signal as a parallel condition around one or more other conditions that are expected to change state when the circuit is enabled
  • Latch circuit: a logic circuit that examines various serial and/or parallel conditions before setting a signal
  • Unlatch circuit: a logic circuit design that examines various serial and/or parallel conditions before resetting a signal
  • Timer circuit: a logic circuit that examines various serial and/or parallel conditions before enabling a timer instruction.

Setup and seal circuits differ in two important ways. Unlike a seal circuit, a setup circuit will never include the rung's coil signal as an examinable precondition. A seal circuit always includes at least one condition needed to break the seal. Designers sometimes refer to a setup circuit as a summation circuit because it sums together all the serial and parallel conditions needed to enable the coil-assigned signal. Designers use a setup circuit when they expect any of the conditions to change state, and they want to keep the signal enabled until one does. For seal circuits, designers simply OR the conditions they expect to change state with a normally opened contact enabled by the coil-assigned signal. Designers also add at least one other AND condition that must change its signal state or variable value when it is time to disable the sealed signal.

Latch and unlatch circuits set and reset the same discrete signal. Some applications use a latch/unlatch instruction to change the state of a signal and a word or file instruction to change it back to the original state. Designers typically program latch and unlatch coils to work together to behave like electromechanical latch relays. When the programmed conditions for a latch coil instruction are true, the machine controller energizes the associated latch instruction signal. The latched signal remains on even when the circuit's preconditions transition to a false state. The enabled signal de-energizes or shuts off when the circuit conditions that enable the unlatch coil instruction are true.

Various timer circuit terms sometimes cause confusion among control system designers. A circuit that uses a Time-On instruction accumulates an elapsed time value when the rung conditions are true. When the circuit is false, the accumulated value automatically resets. Some designers use math-based add or retentive timer instructions to accumulate and hold elapsed time information. These circuit designs need special word instructions that reset or clear retained time information. Regardless, designers usually apply timer circuits to produce one of the following two signal conditioning circuits:

  • Dwell circuit: a timer circuit that times the steady-state condition of a signal before enabling another circuit to examine the signal
  • De-bounce circuit: a timer circuit that times a steady-state condition of a signal before it enables another circuit to react to the signal's new state.

Designers usually apply dwell and de-bounce circuits to time the state of a sensor's input signal. What makes each type of timer circuit different is what each declares when an accumulated elapsed time value is greater than a preset value. A dwell circuit declares the sensor input signal stabilized and ready for use, whereas a de-bounce circuit declares the sensor input signal qualified to change state for the next sensed object or mechanism.

Figure 2 shows how designers usually apply dwell and de-bounce circuits to time the state of a sensor’s input signal. Courtesy: Daniel B. Cardinal

Each machine controller manufacturer is likely to provide a programming environment that is equipped with differing sets of instructions. However, most environments use bit instructions, while others force programmers to create special add-on instructions (AOI) to manipulate word data or enable complex algorithms. Most controller manufacturers provide an environment with a standard set of instructions that allow programmers to enhance the ability of simple relay applications. Programmers use relay instructions to control the movements of objects and mechanisms. Programmers also use bit instructions to enable other internal and external processes. For the most part, programmers use word and file instructions to develop ancillary applications that manipulate data. Shift-register, reader applications, get-next, and communication drivers are examples of an ancillary application.

It is interesting to note that not all electrical relay circuits match an equivalent equation-based logic circuit, and logic circuits do not always translate into valid hardwired circuits. Figure 2 shows two setup circuit examples that do not have corresponding logical and electrical circuits. The top setup circuit is only electrically valid, whereas the bottom setup circuit is only logically valid. The top circuit has four electrically conductive paths. The shown node connection position makes it impossible to represent this circuit logically using a parenthetical Boolean equation. As a result, programmers cannot create an identical ladder logic circuit. If it were programmable, the controller's runtime environment would likely only allow for three logical paths starting from left to right. True paths that back feed through contacts from right to left may be electrically conductive, but they are not logically valid. The bottom example has two relay coils shown connected in series. Although this type of series circuit is electrically impossible, some controller run-time environments allow the execution of this circuit configuration as a way to show more application signals on a circuit run-time screen or printout.

Figure 3 shows an example of seemingly equivalent circuits. Courtesy: Daniel B. Cardinal

It is important to recognize the differences associated with using a relay coil instruction to replace a logical paired set of latch and unlatch coil instructions. Figure 3 shows an example of seemingly equivalent circuits. The seal circuit enables the coil instruction signal when a sensor detects a physical locating mechanism to be in the returned and not the advanced position. On the next scan of the program, the output signal contact is true, thus keeping itself enabled or sealed until the mechanism moves to the advanced position. Once the locator is in the advanced position, the normally closed instruction's signal changes state to break the seal. The latch circuit example enables the latch coil signal, and the machine controller keeps it latched on until the locator moves back to the returned position. The two example circuits seem to operate in an identical fashion. Under normal powered operation, they do. What makes the two circuits unique is how they each reset or keep the discrete output or internal signal on when a power or program interruption occurs. For the latch-unlatch circuit example, the signal remains in the last state when machine power goes off or when a programmer changes the run-time environment from run mode to program mode. For the seal circuit, the enabled signal always resets when power goes off or when a run-time mode change occurs.

It is important to recognize when programmers need to apply seal circuits over latch-unlatch circuits. This is usually the case when massive mechanisms are moving at high speeds over a relatively long distance. When a power or safety interruption occurs while the mechanism is moving, it stops abruptly. This is what happens when someone presses an emergency stop button and the machine power shuts off. Programmers recognize that under these circumstances it is safer to restart the movement of large mechanisms at a slow speed. This practice ensures control applications will safely resume and complete their movements at the slower speed. This is extremely important when an abruptly stopped mechanism coasts by a powered-off deactivated sensor and the control application does not detect the sensor input signal used to decelerate or stop movement.

Figure 4 shows two setup circuit examples that do not have corresponding logical and electrical circuits. Courtesy: Daniel B. Cardinal

Many control system designers understand the value of having a large number of armed triggers for each station's control application. These signals can enable the activation of an equal number of application triggers. To create these signals, designers use multi-bit word registers to arm large numbers of triggers. Figure 4 shows circuit examples for arming a large number of ancillary application triggers. The top circuit arms 16 unique trigger bits when the "object in-position trigger" fires. This occurs when the instruction moves an integer value of 32767 into an arming word register. Because the value 32767 in binary equates to 16 bits being on, the same number of bits are set on when the move instruction executes. Similarly, the bottom circuit fills a file with 160 bits in a 10 consecutive 16-bit word file. 

<< First < Previous 1 2 Next > Last >>

ALBERT , Non-US/Not Applicable, Belgium, 07/10/15 11:12 AM:

Khaleel , UT, Iraq, 07/10/15 03:12 PM:

Thank you for information
The Engineers' Choice Awards highlight some of the best new control, instrumentation and automation products as chosen by...
The System Integrator Giants program lists the top 100 system integrators among companies listed in CFE Media's Global System Integrator Database.
The Engineering Leaders Under 40 program identifies and gives recognition to young engineers who...
This eGuide illustrates solutions, applications and benefits of machine vision systems.
Learn how to increase device reliability in harsh environments and decrease unplanned system downtime.
This eGuide contains a series of articles and videos that considers theoretical and practical; immediate needs and a look into the future.
Make Big Data and Industrial Internet of Things work for you, 2017 Engineers' Choice Finalists, Avoid control design pitfalls, Managing IIoT processes
Engineering Leaders Under 40; System integration improving packaging operation; Process sensing; PID velocity; Cybersecurity and functional safety
Mobile HMI; PID tuning tips; Mechatronics; Intelligent project management; Cybersecurity in Russia; Engineering education; Road to IANA
This article collection contains several articles on the Industrial Internet of Things (IIoT) and how it is transforming manufacturing.

Find and connect with the most suitable service provider for your unique application. Start searching the Global System Integrator Database Now!

SCADA at the junction, Managing risk through maintenance, Moving at the speed of data
Flexible offshore fire protection; Big Data's impact on operations; Bridging the skills gap; Identifying security risks
The digital oilfield: Utilizing Big Data can yield big savings; Virtualization a real solution; Tracking SIS performance
click me