Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Programmable logic controllers. Methods and Applications (Hackworth J., Prentice Hall).pdf
Скачиваний:
870
Добавлен:
12.08.2013
Размер:
6.34 Mб
Скачать

Chapter 4 - Advanced Programming Techniques

Unlike counters, sequencers have contacts that actuate at any specified count of the sequence. For example, if we have an up-counting sequencer SEQ1 with a preset value of 10, and we would like to have a rung switch on when the sequencer reaches a count of 8, we would simply put a N/O contact of SEQ1=8 (or SEQ1:8) in the rung. For this contact, when the sequencer is at a count of 8, the contact will be on. The contact will be off for all other values of sequencer SEQ1. In our programs, we are allowed as many contacts of a sequencer as desired of either polarity (N/O or N/C), and of any sequence value. If for example, we would like our sequencer, SEQ1, to switch on an output OUT1 whenever the sequencer is in count 3 or 8 of it’s sequence, we would simply connect N/O contacts

SEQ1:3 and SEQ1:8 in parallel to operate OUT1. This is shown in Figure 4-13. In rung one, N/O contact IN1 advances the sequencer SEQ1 each time the contacts close. In rung two, N/O contact IN2 resets SEQ1 when the contact closes. In rung three, output OUT1 is energized when the sequencer SEQ1 is in either state 3 or state 8.

* IN1 Seq1 1)))1 /)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))[AVseq]1

*

*

*

* IN2 Seq1 2)))1 /)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))[RSseq]1

*

*

*

* Seq1:3 OUT1 3)))1 /)))0)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(OUT)1 * Seq1:8 *

/)))1 /)))-

*

Figure 4-13 - Sequencer and Output Rung

4-12. Timers

A timer is a special counter ladder function which allows the PLC to perform timing operations based on a precise internal clock, generally 0.1 or 0.01 seconds per clock pulse. Timers usually fall into two different categories depending on the PLC manufacturer. These are retentive and non-retentive timers. A non-retentive timer is one which has one control line, that is, the timer is either timing or it is reset. When this type of timer is stopped, it is automatically reset. This will become more clear as discussion of timers continues. The retentive timer has two control lines, count and reset. This type of timer may be started, stopped then restarted without resetting. This means that it may be used as a totalizing timer by simply controlling the count line. Independent resetting occurs by activating the reset control line. At the beginning of this section, it was stated that a timer is a special

4-19

Chapter 4 - Advanced Programming Techniques

counter. The timing function is performed by allowing the counter to increment or decrement at a rate controlled by the internal system clock. Timers typically increment or decrement at 0.1 second or 0.01 second rates depending upon the PLC manufacturer.

An example of a non-retentive timer is shown in Figure 4-14. Notice that this timer has only one control line containing normally open contact IN1. Also notice that, like the counter, there are two values, ACTUAL and PRESET. These values are, as with the counter, the present and final values for the timer. While the control line containing, in this case, IN1 is false (IN1 is open) the ACTUAL value of the timer is held reset to zero. When the control line becomes true (IN1 closes), the timer ACTUAL value is incremented each 0.1 or 0.01 second. When the ACTUAL value is equal to the PRESET value, the coil associated with the timer (in this case TIM1) is energized and ACTUAL value incrementing ceases. The PRESET value must be set so that the timer counter ACTUAL value will increment from zero to the PRESET value in the desired time. For instance, suppose a timer of 5.0 seconds is required using a 0.1 second rate timer. The PRESET value would have to be 50 for this function since it would take 5.0 seconds for the counter to count from zero to 50 utilizing a 0.1 second clock (50 X 0.1 second = 5.0 seconds). If a 0.01 second clock were available, the PRESET value would have to be 500.

Figure 4-14 - Non-retentive Timer

An example of a retentive timer is shown in Figure 4-15. This type of timer looks more like the counter discussed earlier. The two control lines operate in much the same manner as the counter in that the lower line is the reset line. The top line, however, in the case of the timer is the time line. As long as the reset line is true and the time line is true, the timer will increment at the clock rate toward the PRESET value. As with the nonretentive timer, when the ACTUAL value is equal to the PRESET value, the coil associated with the timer will be energized and timer incrementing will cease. As with the timer, the

PRESET value must be chosen so that the ACTUAL value will increment to the PRESET value in the time desired dependent upon the clock rate.

4-20

Chapter 4 - Advanced Programming Techniques

Figure 4-15 - Retentive Timer

In some cases the PLC manufacturer will, as with the counter, design the timer to decrement the ACTUAL value from the PRESET value toward zero with the coil associated with the timer being energized when the ACTUAL value is equal to zero.

As can be seen from the above explanation for timers and counters, these functions are very similar in operation. Typically, the maximum number of timers and counters a PLC supports is a represented as the total combined number. That is, a system may specify a maximum total of 64 timer/counters. This means that the total of timers and counters can only be 64: therefore, if the program contains 20 timers, it can only contain 44 counters (20 timers + 44 counters = 64 timer/counters). The numbering of the timers and counters is handled differently by different manufacturers. In some cases they are numbered sequentially (TIM1 - TIM.. and CTR1 - CTR..) while in other cases they may not be allowed to share the same number (if TIM1 is present there cannot be a CTR1). Numbering and operation are dependent upon manufacturer and in some instances on the model of the PLC.

Example Problem:

Design a PLC program that will operate a light connected to output OUT1 when input IN1 is ON. When IN1 is ON, the output OUT1 is to flash continuously ON for 0.5 second and off for 1.0 second.

Solution:

Since there are two times specified in this problem (0.5 second and 1.0 second), we will need two timers.

4-21

Chapter 4 - Advanced Programming Techniques

Chapter 4 Review Questions and Problems

1.Draw the ladder rung for an R-S type flip flop that will energize when both IN1

AND IN2 are on and will de-energize when both IN3 AND IN4 are ON. The condition where all inputs are on will not be a defined state for this problem, i.e., it will not be allowed to occur so you do not have to plan for it.

2.Draw the ladder diagram for a T flip flop CR1 which will toggle only when IN1 and IN2 are both OFF.

3.Develop the ladder for a system of two T flip flops which will function as a two bit binary counter. The least significant bit should be CR1 and the most significant bit should be CR2. The clock input should be IN17.

4.Develop the ladder diagram for a 3 bit shift register using J-K flip flops that will shift each time IN1 is switched from OFF to ON. The input for the shift register is to be IN2. The three coils for the shift register may be any coil numbers you choose.

5.Design the ladder diagram for a BCD counter using T flip flops. The LSB of the counter is to be CR1 and the MSB is to be CR4. The clock input is IN2.

6.Design the ladder diagram for a device that will count parts as they pass by an inspection stand. The sensing device for the PLC is a switch that will close each time a part passes. This switch is connected to IN1 of the PLC.

A reset switch, IN2, is also connected to the PLC to allow the operator to manually reset the counter. After 15 parts have passed the inspection stand, the PLC is to reset the counter to again begin counting parts and turn on a light which must stay on until reset by a second reset switch connected to IN3. The output from the PLC that lights the light is OUT111.

7.Design the ladder diagram for a program which needs a timer which will cause a coil CR24 to energize for one scan every 5.5 seconds.

4-22