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.

By Daniel B. Cardinal May 19, 2015

Before 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.

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.

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.

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. 

Circuit style versus structure

Often the look and feel or the style of logic circuits comes out of a perceived need for designers to emphasize circuit design efficiencies. Most design efficiencies create fewer unique circuits. Discrete parts manufacturers must decide whether it is desirable to have fewer efficient circuits or a larger number of structured circuits. On the surface, many designers would say efficiencies are always advantageous. Regardless, manufacturers must decide if unique circuits are worth the cost of not having globally structured circuits for all control applications. How do manufacturers achieve standard structured circuits? This topic is described in the next section of this article, but the process starts by examining design efficiency issues that end up affecting design styles. For some applications, design efficiencies are important, whereas for most applications, efficiencies are not relevant.

Circuit efficiencies affect machine controllers by improving their program scan times and reducing program memory requirements. Even with today’s modern machine controllers, designers continue to emphasize circuit efficiencies. The oddity is that today’s controllers execute extremely fast when compared to yesterday’s controllers. Similarly, new controllers have more memory allocated to support larger applications. So why do designers continue to emphasize circuit efficiencies? Some designers say that for obvious reasons less memory used per application means more resident applications. As a result, efficiency advocates continue to emphasize the need for using many unique nonstandard circuits.

Application execution efficiencies improve the abilities of control applications to respond to input signal changes. Efficient responses enable control applications to stop moving objects or mechanisms repeatedly in precise positions. Inefficient designs that cannot accurately stop moving objects force designs to use mechanical stops and/or electrical cutoff circuits. A mechanical stop is merely an obstruction placed in the path of a moving object. A cutoff circuit is a feature of an external circuit that activates to quickly disable an energized electrical, hydraulic, or pneumatic device that is causing movement. This circuit attribute eliminates the inconsistent stopping effect associated with variable controller scan times. For these types of applications, built-in speed efficiencies have no value to circuits and only act to impede their ability to achieve standard circuit structures coming from many suppliers.

Memory efficiencies allow designers to add more logic to the same PLC. This kind of efficiency acts to reduce the number of PLCs and interconnections. This reduces the overall hardware costs associated with a manufacturing process. Regardless, what are the hidden manufacturing costs associated with having many different nonstructured circuits? The dollar amount is hard to identify because it is usually a cost tied to lost production downtime events. Each downtime event can cost manufacturers a tremendous amount of money. Even small delays that only slightly extend an event can be costly. It is important to acknowledge that delays associated with support personnel interacting with many nonstructured, nonstandard, but efficient applications always extend the length of downtime events.

The use of standard circuits and specifications takes much of the variability of circuit designs away from control system designers. In other words, it prevents them from taking shortcuts that end up increasing the number of design styles. To minimize the negative effects many design styles have on support personnel, manufacturers need a way to control programming methods. Specifically, they need to control the major variables that affect circuit styles. The style of individual applications has everything to do with how designers arrange, invert, and/or combine circuits. The ordered arrangement usually evolves from the need to group circuits by device or device function. The use of inverted circuits comes from a need to reduce the number of parallel circuit branches. Similarly, the practice of combining circuits stems from a desire to merge many smaller circuits into fewer larger circuits. The following terms describe the practices designers use when they create logic circuits:

Negative logic: a circuit design that uses all the inverted parallel condition signals of another circuit

Direct substitution: a circuit design that replaces a bit-enabled signal in one circuit with all the conditions that enabled the bit on another circuit

Inverse substitution: a circuit design that replaces a bit-enabled signal with the negative logic, equivalent signals of the same bit on another circuit

Seal-circuit substitution: a circuit design that replaces a bit-enabled signal with the seal circuit conditions that enable the same bit on another circuit.

Negative logic allows designers to eliminate many parallel circuit branches. The general idea is to invert the otherwise OR conditions and place them in series on one main circuit. When all conditions are off, the inverted conditions automatically enable the circuit’s output signal. When any inverted condition goes on, the normally enabled output signal deactivates. Designers then program a second circuit to examine the disabled signal before enabling another output signal. Figure 5 shows the different logic styles associated with equivalent parallel conditioned logic and negative logic setup circuits.

 

The intuitive nature of logic is extremely important when support personnel are attempting to understand, diagnose, fix, and re-enable a production process. To most people, negative logic circuits with inverted conditions are not as intuitive as parallel logic circuits. So when should manufacturers allow designers to use negative logic? Some manufacturers recognize how negative logic enables support personnel to examine circuit conditions and get to root cause problems quicker. Many manufacturers tie the use of negative and positive logic to how designers apply logic. If an application is enabling a production process, most manufacturers do not allow the use of negative logic. If an application is only diagnosing problems or sending information to a system application, manufacturers often allow its use.

Designers use a direct substitution technique as a way to minimize the number of control circuits needed to enable a signal. Direct substitution allows designers to replace a normally opened contact condition found on one circuit with all the circuit conditions used to enable that signal. Figure 6 shows a direct substitution example. Even though the combined circuit remains intuitive, it does not mean manufacturers should always allow designers to use this technique. There are many cases where this type of substitution only causes designs to replicate conditions multiple times to many different circuits. This situation just sets up opportunities to confuse support personnel when they need to make changes and fail to update all instances. Failing to update all instances causes machines to behave incorrectly, resulting in more lost production.

Designers use the inverse substitution technique as another way to minimize the number of control circuits needed to enable a signal. Inverse substitution allows designers to replace a normally closed contact condition found on one circuit with all the inverted circuit conditions used to enable that signal.

Figure 7 shows an inverse substitution example. Like direct substitution, the unregulated use of this method creates the potential to confuse support personnel. This is a result of inverse substitution creating less intuitive circuits. For example, if the substituted signal’s circuit only has serial or parallel conditions, this technique creates somewhat intuitive circuits. However, if the circuit contains both serial and parallel conditions, this technique creates unintuitive circuits. As a result, manufacturers need to provide designers with rules to govern when it is acceptable to use the inverse substitution technique.

Designers who use direct and inverse substitution techniques are also prone to use the seal-circuit substitution technique. This technique is similar to direct substitution, but the substituted conditions include a sealed condition. As a result, the sealing signal and other conditions need to change to ensure the final circuit will execute correctly.

Figure 8 shows an example of a substituted seal-circuit. The illustrated substitution circuits work because the seal breaking "CLEAR" condition exists in both circuits. Another critical feature is the fact that the conditions that enable the automatic (AUTO) and manual (MAN) mode signals are known by the circuit’s designer to come on when the machine is not in any mode. In other words, both modes must be off before any one mode comes on. Support personnel do not always readily know this design information. As a result, they must rely on the original circuit designer to have understood these types of rules. This situation makes it difficult for support personnel to modify the substituted seal circuit because they have contingent signal connections to other circuits. Before manufacturers can control seal-circuit substitution techniques, they must already have control over the base set of command control circuits. The next section describes the fundamentals of command control circuits. 

Ancillary trigger circuits

Designers program ancillary trigger circuits to enable what they commonly call a "one-shot." A one-shot is a signal that stays on for one complete program scan. This makes the enabled trigger signal examinable by all controller resident applications. There are many ways to design an ancillary trigger circuit to enable a one-shot signal. The previously described entering, in-position, and exiting triggers are examples of how movement detection circuits enable one-shot signals. Machine controller manufacturers have equipped controllers with special one-shot instructions that make it easy for control system designers to produce triggers. Control system designers have also come up with many ingenious circuits to enable one-shot signals. How designers develop ancillary trigger circuits affects the reliability and chaotic nature of machine control applications.

Early machine controllers were simply equipped with a base set of programming relay circuit instructions. This situation forced control system designers to develop their own trigger circuits. Some controller manufacturers reacted to complaints from their user community when customers wanted an easier way to create trigger signals. Some controller manufacturers reacted by adding a one-shot instruction to their suite of bit level instructions. Did this reaction help to enable structured machine controller programs or did it enhance the chaotic nature of programs? To answer this question, strategists must examine how various trigger circuits work and how designers apply one-shot instructions. The following definitions describe different trigger circuits that produce one-shot signals:

Instruction-based trigger circuit: a trigger circuit design that uses a one-shot instruction to ensure a signal stays on for one program scan

Coil-blocked trigger circuit: a trigger circuit design that uses a discrete coil instruction to ensure a signal stays on for one program scan

Latch-protected trigger circuit: a trigger circuit design that uses a latch and unlatch blocking signal to ensure a signal stays on for one program scan

Movement-armed trigger circuit: a trigger circuit design that uses a movement-enabled arm signal to ensure a signal stays on for one program scan

Signal-less one-shot circuit: a trigger circuit that does not produce an examinable signal that would otherwise stay on for one program scan.

Figure 9 shows an instruction-based and a coil-blocked trigger circuit. Both examples assume a clamp will move from an opened to closed position. This means the Clamp Opened Sensor input signal will be off when the Clamp Closed Sensor activates. The closed clamp position enables the instruction-based circuit to activate the Clamp Closed Trigger for one program scan. The coil-blocked trigger circuit uses the disabled state of the Clamp Closed blocking signal to activate the Clamp Closed Trigger the moment the clamp closes. After activating the trigger, the coil circuit enables the internal Clamp Closed blocking signal. When the controller re-executes the same rung on the next program scan, the enabled blocking signal deactivates the Clamp Closed Trigger. This means the Clamp Closed Trigger signal stays on for one scan of the program.

Figure 9 shows two circuits that allow the trigger signals to fire multiple times when any examinable circuit condition toggles between states. This is what happens when machine controllers experience power failures or the Clamp Closed Sensor deactivates and reactivates. The obvious question is, does the repeat enabling of the trigger cause any application problems? To answer this question, designers must understand how circuit designers make sure extra triggers do not negatively affect applications. If there is a potential for creating a problem, designers enhance simple trigger circuits to avoid re-enabling trigger signals. Most enhancements involve replacing the coil-blocking signal with a latched signal. In most cases, when the latch instruction sets a signal on, an unlatch instruction is needed to shut it off.

Figure 10 shows how designers use latch and unlatch circuits to protect against the accidental repeat enabling of the trigger. This protection can improve the reliability of the trigger. When the circuit activates the Clamp Closed Trigger, it immediately latches the Arm Clamp Closed blocking signal. This technique ensures the trigger cannot re-enable until after the clamp returns to its opened position.

Although latch-protected trigger circuit designs work for most programs, they still have the ability to re-enable the trigger for the same part. This happens when someone deliberately moves a mechanism to unlatch the block signal. Depending on the actual application, re-enabling the trigger may not be desirable. If re-firing the trigger does not cause any undesirable affects, these circuits do not create application anomalies. However, if repeat triggering creates anomalies, designers often leave applications to the chance someone will manually move the mechanism.

Figure 11 shows an extremely reliable alternative to a latch-protected trigger circuit. Without the optional parallel branch, the base circuit does not allow the re-enabling of the trigger. The circuit’s preconditions force the design to rely on a movement detection trigger to re-enable the arming signal. If it is desirable to repeat fire the trigger, the programmer merely includes the OR branch to provide an alternate way to re-arm the trigger. The base circuit design ensures the ancillary trigger will only fire once per part.

There are likely some minor technical benefits to using instruction-based circuits over coil-blocked circuits. Any benefit would have nothing to do with decreasing the chaotic nature of control applications. The latch-protected circuit provides some additional false trigger protection without using a one-shot instruction. The movement-armed circuit ensures the highest degree of reliability. It is obvious that the instruction-based method just provides programmers with a redundant way to generate a coil-blocked trigger. Therefore, it is easy to conclude that the reaction by machine controller manufacturers to add a one-shot instruction to their suite of bit level instructions increases the chance designers will arbitrarily use them to produce less reliable triggers. Hence, their use in control applications only increases the chaotic nature of control applications.

Signal-less one-shot circuits do not produce trigger signals that are examinable by other circuits. These circuits typically latch or unlatch a discrete signal. Some circuits simply change or move data when the preconditions are correct. The lack of an examinable signal makes it difficult for other designers, support personnel, or controls integrators to discover the trigger conditions used. In most cases, signal-less one-shot circuits increase the probability that someone will create additional trigger circuits to accommodate their own applications. Their failure to reproduce the same circuit behavior guarantees the increased chaotic nature of the application.

Daniel B. Cardinal graduated from Michigan Technological University as an electrical engineer. He has over 30 years of experience designing control systems and working as a controls integrator. In the early 1980s he was a controls supervisor for one of Europe’s largest machine tool suppliers. Later, he was a co-owner of Control Systems Associates Inc., a company that specialized in integrated system designs. Mr. Cardinal recently published "The Cardinal Cornerstone for MES Success," a book that describes control designs and system fundamentals needed to support manufacturing execution systems; edited by Joy Chang, digital project manager, Control Engineering, jchang@cfemedia.com.

Key Concepts:

  • Before effectively producing a support-focused design that can efficiently interact with control applications, the engineer must first have a basic understanding of control application fundamentals.
  • 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.
  • Each machine controller manufacturer is likely to provide a programming environment that is equipped with differing sets of instructions.

Consider this 

Did controller manufacturers react to their customers properly by providing programmers with one-shot instructions?

ONLINE extra

See parts 1, 2, and 3 of this series by Daniel Cardinal linked below.