|
A better implementation of this method is possible using subroutines in program files. The ladder logic for each state will be put in separate subroutines.
Consider the state diagram in Figure 16.23. This state diagram shows three states with four transitions. There is a potential conflict between transitions A and C.
Figure 16.23 A State Diagram
The main program for the state diagram is shown in Figure 16.24. This program is stored in program file 2 so that it is run by default. The first rung in the program resets the states so that the first scan state is on, while the other states are turned off. Each state in the diagram is given a value in bit memory, so STA=B3/0, STB=B3/1 and STC=B3/2. The following logic will call the subroutine for each state. The logic that uses the current state is placed in the main program. It is also possible to put this logic in the state subroutines.
plc advanced functions -16.23
Figure 16.24 The Main Program for the State Diagram (Program File 2)
The ladder logic for each of the state subroutines is shown in Figure 16.25. These blocks of logic examine the transitions and change states as required. Note that state STB includes logic to give state C higher priority, by blocking A when C is active.
plc advanced functions -16.24
Program 3 for STA
B
B3/0 -STA B3/1 -STB
Program 4 for STB
B3/1 -STB B3/2 -STC B3/1 -STB B3/0 -STA
Figure 16.25 Subroutines for the States
The arrangement of the subroutines in Figure 16.24 and Figure 16.25 could experi ence problems with racing conditions. BACK | NEXT Easy Access To All Pages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|