RichardE1
Electrical
- Oct 25, 2010
- 8
Status Point Energize (STE) – An Easier Way to Keep Track of Process Status
Let’s first look at the reasons the STE instruction was written.
The first person to provide me with any kind of PLC programming guidance was an electrician. The bit of advice that has proved most useful over the years was to keep the use of OTL (latch) and OTU (un-latch) instructions to a minimum. All of my training up to that point was with languages such as C, Pascal and Fortran. The latch and un-latch instructions seemed to be easier for me to follow at the time. To the electrician’s contempt, I used these instructions a lot.
From the electrician’s point of view using an OTE (coil) and latching it in with a branch and a normally open contact referencing the coil represented what he was familiar with. The analogy is that of latching and un-latching a hardware relay.
From a PLC programming standpoint the main issue with using the latch and un-latch instructions is that it tends to lead to “spaghetti code”. There seems to be a tendency to put several latch and un-latch instructions controlling the same bit in the ladder logic. The use of multiple latch and un-latch instructions on the same bit leads to code that is difficult to understand. The authors using this technique often don’t fully understand the resulting logic. Many times it seems that this type of code is a “Band-Aid” approach based on “lucking” into some logic that works most of the time based on observing the machine run. This is not to say that a solid program can’t be written with latch and un-latch instructions. It’s possible that most of us don’t have the discipline to write solid code with these instructions.
Let’s look at the OTE instruction. The OTE instruction turns the referenced bit on when the rung in conditions are true and off otherwise. It’s a simple command. If the OTE instruction is used as shown below to latch a status bit, there is one problem. If the processor is switched from Run to Program and back again, the status bit will be lost. In some cases this is fine. The process inputs will just latch it up again if it’s called for. In other cases it just won’t work. For instance, say you have a switch that denotes a carrier of some kind is at one point – call it SW1 – and another switch that denotes that the carrier is at another point – call is SW2. Say you define a status bit that denotes that the carrier is between SW1 and SW2. Call the bit zone 1 status – Z1.
****see attached file for ladder examples****
Z1 will be lost if the processor is switched from Run to Program and back again. The switches are not situated to correctly latch Z1 after the mode switch.
PLC programming languages are very un-structured. They could be roughly compared to Assembly Language Programming. The successful programmer learns quickly to impose structure or rules. Most will agree that OTE instructions should never reference a given bit in more than one place in the program. A bit referenced by an OTE instruction should not, as a rule, be referenced by an OTL or OTU instruction.
For our purposes, let’s say that we will only reference a given status bit with one OTE instruction in a given program. One positive outcome of this is that basically all of the logic that drives the status bit is clearly provided on one rung. Let’s consider Z1 again. If there is a problem with Z1, you can review the logic immediately without searching through the program. Some status bits will have more involved logic than Z1. If there are status bits used in the logic controlling another status bit, some searching could be necessary to diagnose a problem. If the rules are applied, you at least will only have to look in one place to find the logic for each of the other status bits.
Now let’s consider the STE instruction. The STE instruction can be thought of as an OTE instruction that will survive a processor mode switch. It should be applied using the same rules mentioned above for the OTE instruction. Only reference a given status in one STE instruction in a program.
Very often it is useful to trigger an event based on the leading edge of a signal or the trailing edge of a signal. The STE instruction actually has three signals embedded in it. STE is a user defined instruction. It has data and logic. Let’s say you declare a tag called STATUS and set its data type to STE. Let’s say you reference STATUS in an STE instruction using the rules mentioned. Then STATUS.PT is on when the rung in conditions are true and is off otherwise. This is just like the OTE instruction behaves. The difference is that if STATUS.PT is true when a processor mode change is made, it will also be true after switching back to Run Mode. STATUS.PT survives a processor mode switch. Another signal embedded in the STE instruction is denoted by STATUS.LE given our example. STATUS.LE is on for the first scan that the STATUS.PT is true. The last signal embedded in the STE instruction is denoted by STATUS.TE given our example. It is on the first scan STATUS.PT is off. PT stands for point. LE stands for leading edge. TE stands for trailing edge.
Consider the following example:
****see attached file for ladder examples****
The STE instruction implementation for RSLogix 5000 is included with this document in most cases. This instruction was written recently and the document at hand is all that’s available so far. I’ve done quite a bit of testing to make sure the instruction performs as indicated. The instruction was also used extensively to control machinery. Please contact Richard Edington at Richard.edington@gmail.com with questions, comments or for more information.
Let’s first look at the reasons the STE instruction was written.
The first person to provide me with any kind of PLC programming guidance was an electrician. The bit of advice that has proved most useful over the years was to keep the use of OTL (latch) and OTU (un-latch) instructions to a minimum. All of my training up to that point was with languages such as C, Pascal and Fortran. The latch and un-latch instructions seemed to be easier for me to follow at the time. To the electrician’s contempt, I used these instructions a lot.
From the electrician’s point of view using an OTE (coil) and latching it in with a branch and a normally open contact referencing the coil represented what he was familiar with. The analogy is that of latching and un-latching a hardware relay.
From a PLC programming standpoint the main issue with using the latch and un-latch instructions is that it tends to lead to “spaghetti code”. There seems to be a tendency to put several latch and un-latch instructions controlling the same bit in the ladder logic. The use of multiple latch and un-latch instructions on the same bit leads to code that is difficult to understand. The authors using this technique often don’t fully understand the resulting logic. Many times it seems that this type of code is a “Band-Aid” approach based on “lucking” into some logic that works most of the time based on observing the machine run. This is not to say that a solid program can’t be written with latch and un-latch instructions. It’s possible that most of us don’t have the discipline to write solid code with these instructions.
Let’s look at the OTE instruction. The OTE instruction turns the referenced bit on when the rung in conditions are true and off otherwise. It’s a simple command. If the OTE instruction is used as shown below to latch a status bit, there is one problem. If the processor is switched from Run to Program and back again, the status bit will be lost. In some cases this is fine. The process inputs will just latch it up again if it’s called for. In other cases it just won’t work. For instance, say you have a switch that denotes a carrier of some kind is at one point – call it SW1 – and another switch that denotes that the carrier is at another point – call is SW2. Say you define a status bit that denotes that the carrier is between SW1 and SW2. Call the bit zone 1 status – Z1.
****see attached file for ladder examples****
Z1 will be lost if the processor is switched from Run to Program and back again. The switches are not situated to correctly latch Z1 after the mode switch.
PLC programming languages are very un-structured. They could be roughly compared to Assembly Language Programming. The successful programmer learns quickly to impose structure or rules. Most will agree that OTE instructions should never reference a given bit in more than one place in the program. A bit referenced by an OTE instruction should not, as a rule, be referenced by an OTL or OTU instruction.
For our purposes, let’s say that we will only reference a given status bit with one OTE instruction in a given program. One positive outcome of this is that basically all of the logic that drives the status bit is clearly provided on one rung. Let’s consider Z1 again. If there is a problem with Z1, you can review the logic immediately without searching through the program. Some status bits will have more involved logic than Z1. If there are status bits used in the logic controlling another status bit, some searching could be necessary to diagnose a problem. If the rules are applied, you at least will only have to look in one place to find the logic for each of the other status bits.
Now let’s consider the STE instruction. The STE instruction can be thought of as an OTE instruction that will survive a processor mode switch. It should be applied using the same rules mentioned above for the OTE instruction. Only reference a given status in one STE instruction in a program.
Very often it is useful to trigger an event based on the leading edge of a signal or the trailing edge of a signal. The STE instruction actually has three signals embedded in it. STE is a user defined instruction. It has data and logic. Let’s say you declare a tag called STATUS and set its data type to STE. Let’s say you reference STATUS in an STE instruction using the rules mentioned. Then STATUS.PT is on when the rung in conditions are true and is off otherwise. This is just like the OTE instruction behaves. The difference is that if STATUS.PT is true when a processor mode change is made, it will also be true after switching back to Run Mode. STATUS.PT survives a processor mode switch. Another signal embedded in the STE instruction is denoted by STATUS.LE given our example. STATUS.LE is on for the first scan that the STATUS.PT is true. The last signal embedded in the STE instruction is denoted by STATUS.TE given our example. It is on the first scan STATUS.PT is off. PT stands for point. LE stands for leading edge. TE stands for trailing edge.
Consider the following example:
****see attached file for ladder examples****
The STE instruction implementation for RSLogix 5000 is included with this document in most cases. This instruction was written recently and the document at hand is all that’s available so far. I’ve done quite a bit of testing to make sure the instruction performs as indicated. The instruction was also used extensively to control machinery. Please contact Richard Edington at Richard.edington@gmail.com with questions, comments or for more information.