Terry Woods said:
BTW, Peter, is the more appropriate term... "Re-Entrant"?
I know damned well that there is a term that is applied to what I was describing.
No, again re-entrant applies to subroutines. A re-entrant subroutine has its own local variables and can be interrupted and then called again from the interrupt routine and still work properly. A S7-300 function can be re-entrant if it doesn't modify global memory. A S7-300 function block is not re-entrant if it modifies variables in its DB or globals memory.
I know the what you are trying to say. This is a PLC Ladder Compiler problem.
This is easy
IX0 OX0
--------||-----------------------()
| IX1 OX1
+-----||---------()
ld ix0
st ox0
and ix1
st ox1
No pushes pope or temporary coils required.
This is not
IX0 IX1 OX0
--------||------------||---------()
| OX1
+----------------()
ld ix0
push
and ix1
st ox0
pop
st ox1
Note that push and pop are not IEC 61131-3 instruction list instructions.
This can also be broken down into two rungs.
IX0 IX1 OX0
--------||------------||---------()
ld ix0
and ix1
st ox0
IX0 OX1
--------||-----------------------()
ld ix0
st ox1
This is the problem Terry is talking about. To avoid non standard push and pop, one must use two rungs. No big deal. Code wise two rungs would be more effiecient.
If the rung is modified by switching the two branches then this
rung is easy but then the outputs are updated in reverse order.
Is it OK for the compiler to switch the order of updating the outputs
just to avoid the push and pop or two rungs.
IX0 OX1
--------||-----------------------()
| IX1 OX0
+-----||---------()
ld ix0
st ox1
and ix1
st ox0
Now lets go a step further.
IX0 IX2 OX0
--------||------------||---------()
| IX1 OX1
+-----||---------()
If the PLC uses non-standard push and pop instructions then
ldi ix0
push
and ix2
st ox0
pop
and ix1
st ox1
Without the non standard push and pop the compiler forces the user to use two rungs:
IX0 IX2 OX0
--------||------------||---------()
ld ix0
and ix2
st ox0
IX0 IX1 OX1
--------||------------||---------()
ld ix0
and ix1
st ox1
I think the term Terry is look for is nesting. The push and pop allows nesting the condtion registers in a similar way parentheses allow nesting in formulas.
Telemechanique uses three instructions MPS , MRD, and MPP. These are equivelent to push , pop push and pop. None of these instructions are in my IEC 61131-3 documentation. Telemechanique instruction list is non standard but these three instructions are required if more complicated rungs with multiple output are desired.
MPS, MRD, MPP, push and pop are stack instructions. These are dangerous instructions that can cause stack over and underflows as in forth. This is probably why stack instructions are not included in the IEC 61131-3 specification. Be carefull when using stack instructions.
I see differing opinions about rungs with multiple outputs. It does not make any difference when using a ladder compiler but multiple outputs in instruction list can be unsafe if stack instructions are used.
I am working on an IEC compatible package. I think I will implement just the standard. This means non-standard stack instruction will not be available. This also means that mulitple output rungs may not be available, unless the ladder compiler can convert the mulitple output rung and break it down to multiple rungs with one output each and hide this from the user. Any thoughts?
Hopefully this gives everyone some insight into why....
Terry, I just got some new S7-200 software but haven't tried it out yet. Can it do flow charts too?