Logic Classes
A Logic Class holds rungs you write once and use for many machines of the same kind. Each Call Logic instruction runs one named use of the class, with the class's tags bound to that machine's tags.
Written once, used twice
A class called SealIn has three tags its rungs connect to: Start and Stop, which it reads, and Run, which it writes. It also keeps its own Latched bit. Two uses, one per pump:
| Class tag | Pump1 use | Pump2 use |
|---|---|---|
| Start | Start1 | Start2 |
| Stop | Stop1 | Stop2 |
| Run | Run1 | Run2 |
| Latched | its own | its own |
Each use keeps its own state
| Scan | Start1 | Start2 | Run1 | Run2 |
|---|---|---|---|---|
| 1. Press Start1 | 1 | 0 | 1 | 0 |
| 2. Release Start1 | 0 | 0 | 1 | 0 |
| 3. Press Start2 | 0 | 1 | 1 | 1 |
| 4. Press Stop1 | 0 | 0 | 0 | 1 |
Pump1 latched and Pump2 did not, because each use has its own Latched bit. Stop1 stops only Pump1.
Make a class
- Stop the PLC. In Project Explorer, open Logic Classes and click New class.
- Type a Class symbol, such as
SealIn, and click Create class. - Click Open Tags and add the class's tags with + Tag:
Start,Stop,RunandLatched. - Click Open Logic and write the rungs on those tags.
Call it
- Drag Call logic class (CALL LOGIC) from the Program Control group onto a rung.
- In its settings, choose the Logic class, type a Use name such as
Pump1, and click Save use. - Bind the class tags to this machine's tags:
StarttoStart1,StoptoStop1,RuntoRun1. - Add a second call with the use name
Pump2and bind it to Pump2's tags.
How a call moves values
| The class tag is | At the call |
|---|---|
| Read by the class only | The bound tag is copied in before the class runs. |
| Written by the class only | The result is copied out to the bound tag after it runs. |
| Read and written | Copied in, then copied back out. |
| Left unbound | Kept inside the use, from scan to scan. |
Good to know
- Two calls with the same use name share one state. Choose Reuse an existing named use only when you want that.
- A project holds up to 64 Logic Classes, and a program up to 256 uses of them.
Learn it in a lesson
- Logic classesIntermediate · 15 min