Latches

Birket Engineering Cookbook

Given:
Any two bit terms ‘S’et and ‘R’eset. S and R may be any logic that evaluates to a single bit, including combinations of most input instructions. Also, an output bit X (before evaluation) or X’ (after evaluation).

Latches Figure 1

Consider the following ladder logic program fragments:

1. Reset Priority Latches

1.1. Double Output Latch, -(L)- then -(U)-

A matched pair of -(L)- and -(U)- instructions.

Latches Figure 1

Table of result X’, given S,R, and initial X.

X’ S,R
X 0,0 0,1 1,1 1,0
0 0 0 0 1
1 1 0 0 1

Boolean equation of result X’, given S,R, and initial X.

X’ = (S | X) & ~R

1.2. Single Output Latch, Reset Priority

A handmade latch, using the -( )- instruction, and giving priority to the Reset term.

Latches Figure 1

Table of result X’, given S,R, and initial X.

X’ S,R
X 0,0 0,1 1,1 1,0
0 0 0 0 1
1 1 0 0 1

Boolean equation of result X’, given S,R, and initial X.

X’ = (S | X) & ~R

2. Set Priority Latches

2.1. Double Output Latch, -(U)- then -(L)-

The same matched pair of -(L)- and -(U)- instructions, but reversed in sequence.

Latches Figure 1

Table of result X’, given S,R, and initial X.

X’ S,R
X 0,0 0,1 1,1 1,0
0 0 0 1 1
1 1 0 1 1

Boolean equation of result X’, given S,R, and initial X.

X’ = S | (X & ~R)

2.2. Single Output Latch, Set Priority

A handmade latch, using the -( )- instruction, and giving priority to the Set term.

Latches Figure 1

Table of result X’, given S,R, and initial X.

X’ S,R
X 0,0 0,1 1,1 1,0
0 0 0 1 1
1 1 0 1 1

Boolean equation of result X’, given S,R, and initial X.

X’ = S | (X & ~R)

3. Observations

There exists a exact equivalent for any pair of -(L)-, -(U)- rungs that can be written on one rung, modifying the output bit X only once per scan. Example 1.2 is equivalent to example 1.1, and example 2.2 is equivalent to example 2.1. The single rung latch uses no more instructions than the double rung latch, including the rung and branch begin and end instructions. The single rung latch may even use fewer instructions if S and R contain common terms allowing simplification of the rung.

If you reverse the order of the -(L)- and -(U)- rungs, the result is different for the case where both S and R are true. (See examples 1.1 and 2.1 and compare the tables.) When the -(L)- and -(U)- rungs are both active, the last one executed ‘wins’. This behavior is like an electrical latch relay which gives priority to either the set or reset input when both are active, but unlike an electrical latch relay because the priority is determined by the order of evaluation in the program. The single rung latch makes the priority clear by its construction (compare the ladder logic of examples 1.2 and 2.2) and is not subject to swapping.

The order of evaluation has another effect if the -(L)- and -(U)- rungs are not next to each other. Any rungs that come between the -(L)- and -(U)- rungs will not see the same value for X as the rungs that follow the pair. Again, the problem occurs when both S and R are true. The single rung latch is not subject to this problem.

4. Summary

It is a principle of the design of maintainable software that you should minimize or eliminate the scope where a variable can contain an invalid value. Maintaining programmers will expect a variable to contain the value described. If the variable does not always contain the correct value it can be misused. By using the Single Rung Latch construction, you can insure that the latch variable always contains a valid result and eliminate the chance that the variable will be misused. Remember that the maintenance programmer who’s time you save may be yourself.

5. Using the Single Rung Latch with the Fail-Safe Sense Convention

The Single Rung Latch works well with the Fail-Safe Sense Convention. Consider a general case of a device controlled by a START and ESTOP button and OK and READY sensors or bits. All devices are wired Fail-Safe.

Latches Figure 1

Notice that all contacts are Normally-Open (not inverted) and the terms permitting continued operation of the device are a simple series (AND) circuit. It is very clear that it is not possible to energize RUN without ESTOP and SAFE.

6. Using the Single Rung Latch with the OK (NOT Fault) Convention

The Single Rung Latch works well with the OK Convention. Consider a general case of an OK bit set by a RESET button and cleared (faulted) by two over-travel limit switches (LIM1 and LIM2). All devices are wired Fail-Safe.

Latches Figure 1

Notice that all contacts are Normally-Open (not inverted) and the terms evaluating the safety of the device are a simple series (AND) circuit. It is very clear that it is not possible to set the OK bit (clear the fault) unless the two limit switches are made.

7. Using the Single Rung Latch for Estop Bus Control

The Single Rung Latch is ideal for Estop Bus Control. Consider a Estop bus where the PLC controls an Estop power VOTE relay with a RESET and ESTOP button and an ALL_OK term. The PLC also receives the status of the Estop BUS. All devices are wired Fail-Safe.

Latches Figure 1

Notice that all contacts are Normally-Open (not inverted) and the terms evaluating the safety of the device are a simple series (AND) circuit. It is very clear that it is not possible to energize the VOTE relay unless the ESTOP button and ALL_OK bits are made. Notice that this construction merges the Reset Priority and Set Priority constructions by placing the EBUS term on the branch with the VOTE contact. Thus EBUS can kill VOTE in the absence of RESET, but RESET can energize and latch VOTE provided EBUS follows VOTE.