Tuesday, July 7, 2009

About the Counter in PLC-5 (Allen-Bradley)

Definition:
In the PLC-5 system, a Counter is a type of data file used to count events — whether incrementing (count up), decrementing (count down), or both.

Default File Number:

C: Counter Data File
Examples:
  • C5:0 → First counter
  • C5:1 → Second counter, and so on

Counter Register Structure
Each counter element (C5:x) contains the following internal structure:

  • .ACC — Accumulated Value (current count)
  • .PRE — Preset Value (target count to trigger DN)
  • .EN — Enable Bit (1 when conditions are true)
  • .DN — Done Bit (1 when ACC = PRE)
  • .CU — Count Up Bit (active when rising edge is detected)
  • .CD — Count Down Bit (active when falling edge is detected)
  • .OV — Overflow Bit (active if count exceeds limits)
  • .UN — Underflow Bit (active if count goes below zero)

Types of Counters in PLC-5

  1. CTU (Count Up)
    Increases ACC when the input rises from 0 to 1.
    When ACC >= PRE, the DN bit becomes 1.
  2. CTD (Count Down)
    Decreases ACC on a rising input edge.
    DN becomes active if ACC <= 0, depending on logic.
  3. RES (Reset)
    Resets ACC to 0 and clears the DN bit.

Application Example
Suppose you want to count the number of cartons passing an optical sensor:

  • The sensor is connected to I:1/0
  • The counter CTU uses C5:0
  • Set C5:0.PRE = 10
  • If 10 cartons pass, then:
    • C5:0.ACC = 10
    • C5:0.DN = 1 (indicating completion)

Historical & Philosophical Note
The PLC-5 is more than just a control system—it’s the industrial liturgy of an era that built the foundations of SCADA and DCS. Its counter register is a reflection of how digital logic imagines time and quantity, like a string of prayer beads for engineers—each pulse, a step toward process enlightenment. 😌