Файл: Programmable logic controllers. Methods and Applications (Hackworth J., Prentice Hall).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 15.06.2025
Просмотров: 2117
Скачиваний: 0
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
Chapter 3 - Fundamental PLC Programming
occurs). Another name for such a rung is a latch and the coil is said to be latched on by the contact associated with the coil.
3-9. Always-ON and Always-OFF Contacts
As programs are developed, there are times when a contact is required that is always ON. In newer PLC's there is generally a coil set aside that meets this requirement.
There are, however, some instances where the programmer will have to generate this type of contact in the ladder. One instance where such a contact is required is for a level-triggered (not transition-triggered) arithmetic operation that is to be performed on every scan. Most PLC's require that at least one contact be present in every rung. To satisfy this requirement and have an always true logic, a contact must be placed in the rung that is always true (always closed). There are two ways to produce such a contact. One is to create a coil that is always de-energized and use a normally closed contact associated with the coil. The other is to create a coil, that is always energized and use a normally open contact associated with the coil. Figure 3-16 illustrates a ladder rung that develops a coil that is always de-energized.
* CR1 CR1 CR1 1)))1 /)))))))1//)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(RLY)1
*
*
Figure 3-16 - Always De-energized Coil
Placing this rung at the top of the program will allow the programmer to use a normally closed contact throughout the ladder anytime a contact is required that is always on.
Notice that coil CR1 will always be de-energized because the logic of normally open CR1 contact AND normally closed CR1 contact can never be true. Anytime a contact is required that is always closed a normally closed CR1 contact may be used since coil CR1 will never energize.
Figure 3-17 illustrates a rung which creates a coil CR1 that is always energized. Notice that the logic solution for this rung is always true since either normally closed CR1 contact OR normally open CR1 contact will always be true. This will cause coil CR1 to energize at the conclusion of the solution of this rung. This rung must be placed at the very beginning of the ladder to provide for an energized coil on the first scan. Anytime a contact is required that is always closed, a normally open CR1 contact may be used since coil CR1 will always be energized.
3-16
Chapter 3 - Fundamental PLC Programming |
||
* CR1 |
CR1 |
|
1)))1 /)))))0)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(RLY)1
*CR1 *
/)))1//)))))-
*
Figure 3-17 - Always Energized Coil
There are advantages and disadvantages to using the always de-energized or always energized coil and the use depends on the requirement of the software. If an always de-energized coil is used, it will never be energized, no matter where in the program the rung is located. An always energized coil will be de-energized until the first time the rung is solved, no matter where in the program the rung is located. If there is a program requirement that the coil needs to be de-energized until after the first scan, an always energized coil may be used with the rung placed at the end of the program. This way, the coil would be de-energized until the end of the program where the rung is solved for the first time. After that time the coil will energize and remain energized until the PLC is turned off.
3-10. Ladder Diagrams Having More Than One Rung
Thus far, we have dealt with either ladder diagrams having only one rung, or multiple rung diagrams that may be rearranged in any desired order without affecting the execution of the program. These have served to solve our problems but leave us limited in the things that can be accomplished. Before moving ahead, let us review the steps taken by the controller to solve a ladder diagram. After the I/O update, the controller looks at the contact portion of the first rung. This logic problem is solved based on the states of the elements as stored in memory. This includes all inputs according to the input image table (the state of all inputs at the time of the last I/O update) and the last known state of all coils (both output and internal). After the contact logic has been solved the coil indicated on the right side of the rung is either energized (if the solution is true) or de-energized (if the solution is false). Once this is accomplished, the controller moves on to the next rung of logic and repeats the procedure. The coil of a rung, once set or reset, will remain in that state until the rung containing the coil is again solved on the next scan. If a contact associated with the coil is used in later rungs, the condition of the contact (energized or de-energized) will be based on the state of the coil at the time of the contact usage. For instance, suppose coil CR1 is energized in rung 3 of a ladder diagram. Later in the ladder, say at rung 25, a normally open contact CR1 is used in the control of a coil. The state of contact CR1 will be energized because coil CR1 was energized in the earlier rung. The normally open energized contact will be closed for the purpose of solving the logic of ladder rung 25. After a rung of logic has been solved and the coil set up accordingly, the controller never looks at that rung again until the next scan.
As an aid to further explain these steps, refer to the ladder diagram of Figure 3-18.
3-17
Chapter 3 - Fundamental PLC Programming |
|||
* |
IN1 |
CR1 |
|
1)))1 /)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(RLY)1 |
|||
* |
|||
* |
|||
* |
CR1 |
OUT1 |
|
* |
|||
2)))1 /)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))(OUT)1
*
*
Figure 3-18 - 2-Rung Ladder Diagram
Let us work our way through the operation of this ladder diagram. Notice that the ladder has only one input, IN1, and one output, OUT1. Coil CR1 is referred to as an internal coil. It is not accessible from outside the controller as OUT1 is. The state of CR1 cannot be readily monitored without being able to see "inside" the machine. In the first rung, IN1 is controlling CR1. In the second rung, a normally open contact of CR1 is used to control the state of OUT1. The solution of the ladder diagram is performed as follows:
After I/O update, the controller looks at the contact configuration of rung 1. In this ladder diagram, this is contact IN1. If contact IN1 is closed (energized since it is normally open), the solution of the contact logic will be true. If contact IN1 is open (de-energized), the solution will be false. Once the contact logic is solved, the controller moves to the coil of rung 1 (CR1). If the contact logic solution was true, coil CR1 will be energized; if the contact logic solution was false, coil CR1 will be de-energized. Notice the "contact logic was true or false" in the previous sentence. This is important because after the controller solves the contact logic of a rung, it will not even consider it again until the next time the rung is solved (in the next scan). So, if IN1 had been turned on at the last I/O update, CR1 would be energized after the solution of the first rung. Conversely, if IN1 was off at the time of the last I/O update, CR1 would be de-energized after the solution of the first rung.
The coil will remain in this state until the next time the controller solves a rung with this coil as the right side, generally on the next scan. After the solution of the first rung is complete, the controller moves to the contact solution of the second rung.
The contact logic of rung 2 consists of one normally open contact, CR1. The condition of this contact at this time depends upon the state of coil CR1 at this time. If coil CR1 is presently energized, contact CR1 will be closed. If coil CR1 is presently deenergized, contact CR1 will be open. After arriving at a true or false solution for the contact logic, the controller will energize or de-energize OUT1 depending on the result. This completes the solution of the entire ladder diagram. The controller then moves on to I/O update. At this update, the output terminal OUT1 will be turned on or off depending upon the state OUT1 was set to in rung 2, and IN1 will be updated to the present state of IN1 at
I/O update time. The controller will then move back to the contact logic of rung 1 and start the ladder solution process all over again. The solution of the ladder diagram is a sequential operation. For the purpose of analyzing the operation of the ladder the states of inputs, internal coils and output coils can be followed by making a table of states. Such
3-18
Chapter 3 - Fundamental PLC Programming
a table is shown below. The table takes into account all possible combinations of inputs.
The table is filled in as each rung is solved. Each line of the table represents the solution of one rung of logic.
IN1 |
CR1 |
OUT1 |
|
1 |
0 |
0 |
0 |
I/O update |
|||
2 |
1 |
1 |
0 |
3 |
1 |
1 |
1 |
I/O update |
|||
4 |
0 |
0 |
1 |
5 |
0 |
0 |
0 |
Line 1 indicates the condition of inputs and coils at the time the controller is started. IN1 and all coils begin in the off condition. Line 2 shows the condition of the elements after the solution of rung 1 assuming that IN1 was on at the last I/O update. Line 3 shows the condition of the elements after the solution of rung 2. IN1 remains on for rungs 2 and 3 because if it was on at I/O update, it will be used as on for the entire ladder. The state of all inputs can only change at I/O update. Lines 4 and 5 show the element states after solving rungs 1 and 2 respectively assuming that IN1 was turned off. Once the timing and sequencing of ladder diagram processing by the controller is better understood, this table approach can be used with each line indicating the results of processing one scan instead of one rung. This can be a much more useful approach especially since the table could become unmanageable in a ladder that had a large number of rungs.
3-19
Chapter 3 - Fundamental PLC Programming
Chapter 3 Review Questions and Problems
1.Is a normally closed contact closed or open when the relay coil is energized?
2.What is the limitation on the number of contacts associated with a particular relay coil in a PLC program?
3.How is the state of a relay coil represented inside the PLC?
4.If a particular coil is to be an output of the PLC, when is the state of the coil transferred to the outside world?
5.Draw the ladder logic rung for a normally open IN1 AND'ed with a normally closed IN2 driving a coil CR1.
6.Repeat 5 above but OR IN1 and IN2.
7.What physical changes would be required to system wiring if the PLC system of problem 5 had to be modified to operate as problem 6?
8.Draw the ladder logic rung for a circuit in which IN1, IN2 and IN3 all have to be ON OR IN1, IN2 and IN3 all have to be OFF in order for OUT1 to energize.
9.It is desired to implement a switch system similar to a three-way switch system in house wiring, that is, a light may be turned on or off from either of two switches at doors on opposite ends of the room. If the light is turned on at one switch, it may be turned off at the other switch and vice versa. Draw the ladder logic rung which will provide this. Define the two switches and IN10 and IN11 and the output which will control the light as OUT18.
10.Draw the ladder logic rung for an oscillator which will operate only when IN3 and IN5 are both ON or both OFF.
3-20