See this link:
http://www.contactandcoil.com/patterns-of-ladder-logic-programming/
Read them in this order: Input Map pattern; Seal-in pattern; Start/Stop Circuit pattern; State Coil/Fault Coil pattern.
The point of reading the Input Map pattern is to understand the basic pattern is "If the input logic evaluates to True, then assign a 1 to the output element; if the input logic evaluates to False
The points of the Seal-in pattern are to understand that
- two elements in parallel implement (encapsulate) a logical OR;
- the result of two instructions ORed in the Seal-in pattern reduce to the "input logic" of the Input Map pattern.
- digital PLCs evaluate logic in time, and understanding the that the scan cycle (usually) operates on a snapshot of the process in time. So read value of the seal-in tag in the XIC/Normally Open contact (usually) represents what the value of that tag was at the time of the end of the previous scan cycle, and the assigned value of the seal-in tag in the OTE/Output coil represents what the value will be at the time of the end of the current scan cycle.
The point of the Start/Stop Circuit and State Coil/Fault Coil Circuit patterns is to understand that
- two elements in series implement (encapsulate) a logical AND;
- the result of three instructions ORed and ANDed in the Start/Stop Circuit or State Coil/Fault Coil Circuit pattern reduce to the "input logic" of the Input Map pattern.
Getting back the original query, and ignoring the GL/RL interaction, two Start/Stop Circuit Patterns are needed:
- One Start/Stop Circuit pattern for GL:
- PB 1 is the tag of the Start element
- PB 3 is the tag of the Stop element
- GL is the tag of the Run and Seal-in elements
- One Start/Stop Circuit patter for RL:
- PB2 is the tag of the Start element
- PB 3 is the tag of the Stop element
- RL is the tag of the Run and Seal-in elements
I leave it to the OP to figure out which types of contacts, XIC/Normally Open or XIO/Normally Closed, go with each tag.
With that done, pressing PB 1 will put a value of 1 GL, and GL will remain 1 if PB 1 is released, at least until PB 3 is pressed. Likewise for PB 2, PB 3, and RL.
So the only thing to add is how to implement the value RL not becoming 1 when PB 2 is pressed unless the value of GL is already 1.
- If RL is 0, then RL will remain 0 if EITHER PB 2 is 0 OR GL is 0
- Expressed another, but equivalent, way (cf. De Morgan),
- RL becomes 1 if BOTH PB 3 is 1 AND GL is 1 (assuming PB 3 is not pressed).
So the trick is, given the understanding provided by the circuit patterns shown at the beginning of this post, how to implement that last statement (i.e. the one in blue and red). Hint: only the Start portion of the RL rung needs to be changed.