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 tagPump1 usePump2 use
StartStart1Start2
StopStop1Stop2
RunRun1Run2
Latchedits ownits own

Each use keeps its own state

ScanStart1Start2Run1Run2
1. Press Start11010
2. Release Start10010
3. Press Start20111
4. Press Stop10001

Pump1 latched and Pump2 did not, because each use has its own Latched bit. Stop1 stops only Pump1.

Make a class

  1. Stop the PLC. In Project Explorer, open Logic Classes and click New class.
  2. Type a Class symbol, such as SealIn, and click Create class.
  3. Click Open Tags and add the class's tags with + Tag: Start, Stop, Run and Latched.
  4. Click Open Logic and write the rungs on those tags.

Call it

  1. Drag Call logic class (CALL LOGIC) from the Program Control group onto a rung.
  2. In its settings, choose the Logic class, type a Use name such as Pump1, and click Save use.
  3. Bind the class tags to this machine's tags: Start to Start1, Stop to Stop1, Run to Run1.
  4. Add a second call with the use name Pump2 and bind it to Pump2's tags.

How a call moves values

The class tag isAt the call
Read by the class onlyThe bound tag is copied in before the class runs.
Written by the class onlyThe result is copied out to the bound tag after it runs.
Read and writtenCopied in, then copied back out.
Left unboundKept 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

Related