-7 S H O RT P ROGRAMMING E XAMPLES

1 1 -7 S H O RT P ROGRAMMING E XAMPLES

This section presents several examples of logic series that are often encoun- tered when programming a controller. For convenience, the examples are implemented using the most basic ladder diagram instructions. Therefore, they may require more instructions than they would if they were pro- grammed using a higher level instruction set.

E XAMPLE

1: I NTERNAL S TORAGE B ITS

Most programming devices are limited in the number of series contacts or parallel branches that a rung can have. This limitation can be overcome through the use of internal storage bits. Figure 11-72a illustrates a PLC program that was translated directly from a hardwired relay diagram that requires seven parallel OR branches. If the programmable controller had

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC System Programming C HAPTER 3 Programming

and Implementation 11

only allowed five OR branches, an internal could have been used to break the circuit into two circuits, as shown in Figure 11-72b. The program’s operation is the same in both configurations. This technique would also be valid if the contacts were arranged in series.

Figure 11-72. (a)

A relay circuit using seven rungs that is (b) converted to five rungs using an internal.

E XAMPLE

2: S TA RT /S TOP C IRCUIT

The start/stop circuit shown in Figure 11-73 can be used to start or stop a motor or process or to simply enable or disable some function. To start a motor, the ladder output only needs to reference the motor output address. If the intent of the circuit is to detect that some process is enabled, the output can be referenced with an internal address.

In Figure 11-73, the stop push button and emergency stop inputs are pro- grammed as normally open. They are programmed this way because these types of inputs are usually wired normally closed. As long as the stop push button and the emergency stop push button are not pushed, the programmed contacts will allow logic continuity. Since the start push button (normally

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC System Programming C HAPTER 3 Programming

and Implementation 11

open) is a momentary device (i.e., it allows continuity only when pressed), a contact from the motor output is used to seal the circuit. Often, the seal-in contact is an input from the motor starter contacts.

Emergency

Motor M1

Start PB

Stop PB*

Stop PB*

Output

M1

*Wired NC Figure 11-73. Start/stop circuit.

E XAMPLE

3: E XCLUSIVE -O R C IRCUIT

The exclusive-OR circuit in Figure 11-74 is used to prevent an output from energizing if two conditions, which can activate the output independently, occur simultaneously. Thus, if either input A or B is activated, the output will

be energized. However; if both are activated, the output will not be energized.

Input

Input

A B Output or Internal

Input

Input

Figure 11-74. Exclusive-OR circuit.

E XAMPLE

4: O NE -S HOT S IGNAL

The one-shot (transitional output) signal in Figure 11-75 is a program- generated pulse output that, when triggered, is ON for the duration of one program scan and then turns OFF. A momentary signal (e.g., a push button) or an output that comes ON and stays ON for some time (e.g., a motor) can enable a one-shot signal. Whichever input signal is used, the leading-edge (OFF-to-ON) transition of the input signal triggers the one-shot signal,

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC System Programming C HAPTER 3 Programming

and Implementation 11

which stays ON for one scan and then goes OFF. The signal remains OFF until the trigger is activated, causing it to come ON again. Clear or reset signals are typically one-shot signals; the one-shot signal is perfect for this application, since it stays ON for only one scan.

Figure 11-75. One-shot output circuit.

E XAMPLE

5: T RAILING -E DGE O NE -S HOT S IGNAL

A trailing-edge one-shot signal (see Figure 11-76) generates a pulse with a one-scan duration. This signal reacts like the one-shot signal in Example 4; however, the trigger for this pulse is the trailing edge of the trigger pulse. Figure 11-76 shows the timing diagram for each element’s activation.

C Figure 11-76. (a) A trailing-edge one-shot output circuit and (b) its corresponding

timing diagram.

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC System Programming C HAPTER 3 Programming

and Implementation 11

E XAMPLE

N I T I A L I Z AT I O N 6: I U SING AN MCR

The logic circuit shown in Figure 11-77 can be used to set up parameters during an initialization period. These parameters include timer and counter preset values, high- and low-limit set point values, and any other preset or starting values. Typically, the initialization period occurs only once during the program, either when the system is first powered up or when power is restored after a power loss.

Initialize

Internal Reset

Internal Reset

END

MCR

Main Program

Figure 11-77. Initialization circuit using an MCR.

E XAMPLE

7: S YSTEM S T A RT -U P H ORN

A start-up horn logic circuit (see Figure 11-78) is used to signal that moving equipment (e.g., conveyor motors) is about to start. The setup output signal in this example is similar to a start/stop circuit; but instead of starting the system, it enables the timer, allowing the horn to sound for 10 seconds. The horn sounds when the start input is closed and stops when the timer times out or the reset input opens. The system can start, if the setup signal remains ON, when the horn delay timer times out.

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC System Programming C HAPTER 3 Programming

and Implementation 11

PR: 10 TB: 1 sec.

TMR1

Setup

Horn Output

* Wired NC Figure 11-78. Start-up horn circuit.

E XAMPLE

8: O S C I L L AT O R C IRCUIT

An oscillator logic circuit (see Figure 11-79) is a simple timing circuit that generates a periodic output pulse of any duration. The TMR1 output generates this pulse.

TMR2

TMR1

PR: 5 TB: 0.1 sec.

TMR1

TMR2

PR: 5 TB: 0.1 sec.

Figure 11-79. Oscillator circuit.

E XAMPLE

9: A N N U N C I AT O R F LASHER C IRCUIT

A flasher circuit (see Figure 11-80) toggles an output ON and OFF continually. In this circuit, an oscillator circuit output (TMR1) is pro- grammed in series with an alarm condition. As long as the alarm condition is TRUE, the annunciator output will flash. The output in this case is a pilot light; however, this same logic could be used in conjunction with a horn, which would pulse during the alarm condition. Any number of alarm conditions can be programmed using the same flasher circuit.

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC System Programming C HAPTER 3 Programming

and Implementation 11

Alarm n n

Cond. n n

TMR1

Output

Figure 11-80. Annunciator flasher circuit.

E XAMPLE

10: S ELF -R ESETTING T IMER

The self-resetting timer shown in Figure 11-81 provides a one-scan pulse each time the timer is energized. The specified preset value of the timer determines the repetition of this pulse.

TMR1

TMR1

PR: 30 TB: 1 sec.

Figure 11-81. Self-resetting timer circuit.

E XAMPLE

11: S CAN C OUNTER

The circuit shown in Figure 11-82 computes scan time. This short program counts the number of times two consecutive scans occur during a time interval, which is defined by the timer (e.g., 10 seconds). Once the time interval elapses, the program multiplies the number of two-scan counts by two. It then divides the time interval (10 seconds) by the number of total scans, thus computing the scan time, which is stored in a result register. The result register is scaled so that the scan time is expressed in milliseconds.

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC System Programming C HAPTER 3 Programming

and Implementation 11

One Scan

Two

A D CTR

B Scans

Up PR: K10000 AR: 4000

PR: K1000 AR: 4100 TB: 0.01

D MULT

R 4000 x R K2 = R 4001

D DIV

R 4100 ÷ R 4001 = R 4002 Scale +3

Figure 11-82. Scan counter circuit.

E XAMPLE

12: S EQUENTIAL M OTOR S TA R T I N G

This example (see Figure 11-83) illustrates how several motors or other devices can be started sequentially, as opposed to all at once. For simplicity, we used an ON-delay timer to delay the start of each motor. However, this approach is impractical for starting a large number of motors. If a large number of motors will be started, other techniques that do not require as many timers as motors (e.g., shift registers, self-resetting timers, oscillator circuits, etc.) should be used.

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC System Programming C HAPTER 3 Programming

and Implementation 11

Output M1

PR: 30 TB: 0.1 sec.

TMR1

Output M2

PR: 30 TB: 0.1 sec.

TMR2

Output M3

* Wired NC

Figure 11-83. Sequential motor-starting circuit.

E XAMPLE

13: D E L AY E D D E - ENERGIZE D EVICE

This example (see Figure 11-84) illustrates the use of an OFF-delay timer to de-energize a motor or another device after a delay period. Note that the output of the OFF-delay timer before the Stop Motor 1 push button is pressed is TRUE, thus keeping the TMR1 contact in line 1 closed. When the Stop Motor 1 push button (wired as normally closed) is depressed while the motor is running, it energizes the internal output, enabling the OFF-delay timer. When the timer times out, the contacts open and the motor de-energizes.

Industrial Text & Video Company 1-800-752-8398

www.industrialtext.com

S ECTION PLC System Programming C HAPTER 3 Programming

and Implementation 11

Stop Motor 1*

* Wired NC

TB: 1 sec. Figure 11-84. Delayed de-energize circuit.

E XAMPLE 1 4 : 2 4 -H OUR C LOCK

A 24-hour clock has many applications, but it is typically used to display the time of day or to determine the time a report is generated. Figure 11-85 shows the logic used to implement this type of clock. This logic consists of three counters: one counts 60 seconds, another counts 60 minutes, and the third counts 24 hours. The time is displayed by outputting the accumulated register value of each counter to seven-segment BCD displays.

E XAMPLE

15: E L I M I N AT I O N OF B IDIRECTIONAL