|
Figure 18.4 IL Equivalents for Ladder Logic
Figure 18.5 shows the IL programs that are generated when there are multiple out puts. This often requires that the stack be used to preserve values that would be lost nor
plc il -18.6
mally using the MPS, MPP and MRD functions. The MPS instruction will store the current value of the top of the stack. Consider the first example with two outputs, the value of A is loaded on the stack with LD A. The instruction ST X examines the top of the stack, but does not remove the value, so it is still available for ST Y. In the third example the value of the top of the stack would not be correct when the second output rung was examined. So, when the output branch occurs the value at the top of the stack is copied using MPS,and pushed on the top of the stack. The copy is then ANDed with B andusedto set X.After this the value at the top is pulled off with the MPP instruction, leaving the value at the top what is was before the first output rung. The last example shows multiple output rungs. Before the first rung the value is copied on the stack using MPS. Before the last rung the value at the top of the stack is discarded with the MPP instruction. But, the two center instructions use MRD to copy the right value to the top of the stack -it could be replaced with MPP then MPS.
plc il -18.7
Ladder
Instruction List (IL)
AX LD A ST X Y
ST Y
X
LD A LD A ST X ST X Y
LD B AND B ANB ST Y ST Y
X
LD A LD A MPS MPS Y
LD B AND B ANB ST X ST X MPP MPP AND C LD C ST Y ANB ST Y
W
LD A LD A MPS MPS X
LD B AND B ANB ST W Y
ST W MRD MRD AND C Z
LD C ST X ANB MRD ST X ST Y MRD MPP STY AND E MPP ST Z
LD E ANB ST Z
Figure 18.5 IL Programs for Multiple Outputs
Complex instructions can be represented in IL, as shown in Figure 18.6. 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
|