When you use a button-function you are simply controlling the state of a bit in memory, or, at least, trying to control that bit.
The bit does not even need to exist in your Ladder Code. You could have a page on your display controlling nothing but "virtual" bits. That is, bits that exist in memory, and your panel code, but not in your process code.
MOMENTARY
When the button is pressed, this bit is "driven" ON. When you release the button, if there is nothing else keeping the bit ON (such as a latch circuit) then the bit goes OFF.
If there is a latch circuit, in the code, holding this bit ON, then, after latching the bit, there is nothing that this button can do to change the state of the bit.
SET
When the button is pressed, this button-function produces a "SET" on the subject bit. The bit is SET to "1". This is your basic "ON Button".
RESET
When the button is pressed, this button-function produces a "RESET" on the subject bit. The bit is RESET to "0". This is your basic "OFF Button".
TOGGLE
When the button is pressed, the "internals" of the button-function look to see the current state of the bit. If the bit is ON, then the button-function turns the bit OFF. If it is OFF, then the button-function turns the bit ON.
This is your basic "FLIP or Yanov Button".
Remembering my Navy days ( Ya know, I never once wrote FTN on a wall, anywhere! Navy guys know what I'm talking about. )
So, remembering my Navy days, we had this Lt Cmdr named Yanov. He was pretty much on the ball. We figured that he had to be the one responsible for inventing the "Yan/ov Switch". He was Russian (duh)... they invented everything! Didn't they? At least, according to them and Lt Cmdr Chekov (Star-Trek). Anyway, at least, we had fun saying so.
WHAT'S GOING ON IN MEMORY?
Now, because these button-functions are working directly on bits on the PLC Memory, those bits can just as easily be affected by Ladder Code.
For example, let's say you have four buttons programmed as "SET" and each is used to start a process function and each process function (except the first) is dependent upon the previous process function.
PB-1 => SET Bit-1 => Process Module-1
If Module-1 is ON then PB-2 => SET Bit-2 => Process Module-2
If Module-2 is ON then PB-3 => SET Bit-3 => Process Module-3
If Module-3 is ON then PB-4 => SET Bit-4 => Process Module-4
In this case, for start-up, 4 is dependent upon 3, and 3 is dependent upon 2, and 2 is dependent upon 1. Module-4 is the entry part of the process. Module-1 is the exit part. So, you must enable all down-line stuff, in order, before youcan begin feeding product.
Once the four modules are running, you can then "watch-dog" for faults in the various modules and handle module shut-downs as required.
If a fault occurs in Module-2, you need to shut down Modules-2, and -1.
You can do so by simply executing the following code:
Fault
Mod-2 Bit-2
-----| |------------+-----( RESET )
|
| Bit-1
+-----( RESET )
.
If, in addition to controlling those bits, your panel is watching those particular bits for "color status" then the colors for PB-2 and PB-1 will go to the "OFF COLOR".
The point is, the panel only "tickles" a bit into one state or another - FOR A SINGLE PANEL SCAN, unless MOMENTARY, then it is repeated Single-Scans as long as the button is held.
If there is no cause to revert to the previous state, then the bit holds the state to which it was "tickled" to.
When the "MOMENTARY" bit is released, it will revert unless there is a latch, or some such, to hold the state that the bit was "tickled" to (ON).
The "SET" bit will remain as "1" unless there is something in Ladder driving it to "0".
The "RESET" bit will remain as "0" unless there is something in Ladder driving it to "1".
If you are familiar with my "BE THE COMPUTER" stories, then you might be able to see that this is "BE THE PANEL COMPUTER". This is the same but it differs in only a "relative" way.
With respect to the Panel and Process Control, when the Panel tries to control Outputs, he is really messing with the INTERNAL MEMORY LOCATIONS that belong to the MAIN CPU. Whenever he is required to do so the panel passes a REQUEST for handling to the Main CPU.
Now, understand this...
The Main CPU may or may not honor any request from the panel. It depends on what the Main CPU sees to be legitimate.
The bit WILL be set to the state that the panel requested BUT as soon as Ladder Processing begins, Ladder has control!
LADDER CAN AND WILL OVER-RIDE PANEL REQUESTS!
jeez... 'nuff!