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

Chapter 3 - Fundamental PLC Programming

The reader is invited to algebraically expand the above expression to verify that all ten of the combinations are covered. This can be written in one rung, with branches as shown in Figure 3-12.

* IN1 IN2 IN3 OUT1 1)))1 /)))0)))1 /))))0)))1 /)))0)))))))))))))))))))))))))))))))))))))))))))(OUT)1

* * * IN4 *

** /)))1 /)))1

*

*

* IN5 *

** .)))1 /)))1

*

* IN3

IN4 *

*/)))1 /)))0))))1 /)))1

*

*

* IN5 *

** .)))1 /)))1

*

* IN4

IN5 *

*.)))1 /))))))))1 /)))1

*

IN2

IN3

IN4

*

/)))1

/)))0)))1

/))))0)))1

/)))1

*

 

*

 

*

IN5

*

** .)))1 /)))1

*

* IN4

IN5 *

*.)))1 /))))))))1 /)))1

* IN3 IN4 IN5 * /)))1 /))))))))1 /)))))))1 /)))-

*

*

Figure 3-12 - 5-Input Majority Circuit

3-7. Oscillator

With the above examples, little or no discussion has been made of scan operations or timing. We have merely assumed that when all the conditions were met for a coil to energize, it would do so. However, we must always be aware of the procedure the controller uses to solve the ladder logic diagram. As an example of how an understanding of scanning can benefit us as programmers, let us develop an oscillator. An oscillator in the ladder diagram world is a coil that turns on and off alternately on each scan. An oscillator can be useful to control things like math functions and other types of functions which are controlled by a transitional contact. A transitional contact is a contact that switches from closed to open or from open to closed. Functions such as math functions in some controllers only perform their assigned process on the one scan when the control logic switches from open to closed. As long as the control logic remains closed or open, the function will not be performed. To enable the function to occur on an ongoing basis, a transitional contact may be placed in the control logic. This will cause the function to be performed on (in the case of using an oscillator) every other scan. This is because the transitional contact from the oscillator will switch from open to closed on every other scan.

3-12

Chapter 3 - Fundamental PLC Programming

We are now going to get away from the previous process of looking at Boolean equations and electrical circuit diagrams, because we are going to be discussing the internal operation of the controller while processing ladder logic and, while a good understanding of Boolean logic is essential to understand the process of solving a particular rung, Boolean equations and electrical diagrams will not supply all the tools and understanding you will need to program these devices. By far, a good programmer relies more on a thorough knowledge of how the controller proceeds with the solution of the ladder and his own imagination than he does on strict Boolean logic.

Consider the ladder diagram of Figure 3-13. This program introduces the internal relay. Internal relays are created by the programmer, can be given any name (in this case,

CR1), and are not accessible by terminals on the outside of the PLC. The number of internal relays is limited by the design of the particular PLC being used. The programmer may create only one coil for each internal relay, but may create as many N/O and N/C contacts of each relay as needed. It is important to remember that these relays don’t actually exist in a physical sense. Each one is simply a digital bit stored in a flip flop inside the PLC.

*CR1 CR1

1)))1//)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(RLY)1

*

*

*

Figure 3-13 - Oscillator

The ladder of Figure 3-13 appears to be very simple, only a normally closed (notice normally closed) contact and a coil. The contact and coil have the same number, so if the coil is energized the contact will be open and if the coil is de-energized the contact will be closed. This is the fact that makes this configuration function to provide a transitional contact.

The first thing the controller does when set into operation is to perform an I/O update. In the case of this ladder diagram, the I/O update does nothing for us because neither the contact nor the coil are accessible from the outside world (neither is an input nor output). After the I/O update, the controller moves to the contact logic portion of the first rung. In this case, this is normally closed contact CR1. The contact logic portion is solved to determine if the coil associated with the rung is to be de-energized or energized. In this case, since the controller has just begun operation, all coils are in the de-energized state. This causes normally closed contact CR1 to be closed (CR1 is de-energized). Since contact CR1 is closed, coil CR1 will be energized. Since this is the only rung of logic in the ladder, the controller will then move on to perform another I/O update. After the update, it will then move on to the first rung (in our example, the only rung) of logic and solve the contact logic. Again, this is one normally closed CR1 contact. However, now CR1 is energized from the last scan, so, contact CR1 will be open. This will cause the controller

3-13

Chapter 3 - Fundamental PLC Programming

to de-energize coil CR1. With the ladder diagram solution complete, the controller will then perform another I/O update. Once again it will return to solve the first rung of logic. The solution of the contact logic will indicate that the contact CR1, on this scan, will be closed because coil CR1 was de-energized when the rung was solved on the last scan. Since the contact is closed, coil CR1 will again be energized. This alternating ...on-off-on-off-on...

sequence will continue as long as the controller is operating. The coil will be on for one entire scan and off for the next entire scan etc. No matter how many rungs of logic we have in our program, for each scan, coil CR1 would be alternating on for one scan, off for one scan, on for one scan and so on. For a function that only occurs on an off-to-on contact transition, the transition will occur on every other scan. This is one method of forcing a transitional contact.

In controllers that require such a contact, there is generally a special coil that can be programmed which appears to the controller to switch from OFF to ON on every scan. The rung containing this coil is placed just before the rung requiring the contact. The controller forces the coil containing the transitional contact to an off state at the end of the ladder diagram solution so when the rung to be solved is reached, the coil is in the off state and must be turned on. This provides an off to on transition on every scan which may be used by the function requiring such a contact.

The study of this oscillator rung, if it is thoroughly understood, will provide you with an insight into the operation of the controller that will better help you to develop programs that use the controller to its fullest extent. The fact that the controller solves each rung one- at-a-time, left side logic first and right side coils last, is the reason that a ladder like Figure 3-13 will function as it does. The same circuit, hardwired using an actual relay would merely buzz after the application of power and perform no useful purpose unless you wanted to make a buzzer. It could not be used to energize any other coil since there is no timing to that type of operation. The reason it would only buzz is that in a hardwired system all rungs are both solved and coils set or reset at the same time. It is this timing and sequential operation of the programmable controller that makes it capable of performing otherwise extremely complicated operations.

Let us now add an additional contact to the rung shown in Figure 3-13, to create the rung in Figure 3-14. The additional contact in this rung is a normally open IN1 contact. If IN1 is off at I/O update, normally open IN1 will be open for that scan. If IN1 is on at I/O update, normally open contact IN1 will be closed for that scan. This provides us with a method of controlling coil CR1's operation. If we want CR1 to provide a transitional contact, we need to turn IN1 on. If we want CR1 to be inactive for any reason, IN1 needs to be turned off.

3-14

 

 

Chapter 3 - Fundamental PLC Programming

* IN1

CR1

CR1

 

1)))1 /)))))))1//)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(RLY)1

*

*

Figure 3-14 - Gated Oscillator

3-8. Holding (also called Sealed, or Latched) Contacts

There are instances when a coil must remain energized after contact logic has been found to be true even if on successive scans the logic solution becomes false. A typical application of this would be an ON/OFF control using two separate switches, one to turn the equipment on and one to turn the equipment off. In this case, the coil being controlled by the switches must energize when the ON switch is pressed and remain energized until the OFF switch is pressed. This function is accomplished by developing a rung which contains a holding contact or sealing contact that will maintain the coil in the energized state until released. Such a configuration is shown in Figure 3-15.

* IN1 IN2 CR1 1)))1 /)))))0)))1//)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(RLY)1

*CR1 *

/)))1 /)))))-

*

Figure 3-15 - Holding (or Sealed) Contact

Notice that the contact logic of Figure 3-15 contains three contacts, two normally open and one normally closed. Normally open contact IN1 is defined as the ON switch for our circuit and normally closed contact IN2 is defined as the OFF switch. Notice that when IN1 is turned ON (the normally open contact closes) and IN2 is turned OFF (the normally closed contact is closed), coil CR1 will energize. After CR1 energizes, if IN1 is turned OFF

(the normally open contact is open), coil CR1 will remain energized on subsequent scans because normally open contact CR1 will be closed (since coil CR1 would have been energized on the previous scan). Coil CR1 will remain energized until normally closed contact IN2 is opened by turning IN2 ON because when the normally closed contact IN2 opens the contact logic solution will be false. If IN2 is then turned OFF (the normally closed contact closes), coil CR1 will remain de-energized because the solution of the contact logic will be false since normally open contacts IN1 and CR1 will both be open. Normally open contact CR1 is referred to as a holding contact. Therefore, the operation of this rung of logic would be as follows: when the ON (IN1) switch is momentarily pressed, coil CR1 will energize and remain energized until the OFF switch (IN2) is momentarily pressed.

A holding contact allows the programmer to provide for a coil which will hold itself

ON after being energized for at least one scan. Some instances in which such a configuration is required are ON/OFF control, occasions when a fault may occur for only one scan and must be detected at a later time ( the coil could be latched on when the fault

3-15