C0-00DR-D PLC: Count Active Outputs with a Register

Brian Holt6 min read
AutomationDirectPLC HardwareTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

On the C0-00DR-D, count the true conditions for outputs 1–6 once per scan, then use that count to control outputs 7 and 8. The required ranges are 3 or 4 for output 7 and 5 or 6 for output 8.

Try direct contacts only when the condition names specific outputs

A normally open or normally closed contact using an output address can test that output’s logic state. That is useful when a rung depends on a particular output, such as “turn on output 7 when output 3 is on.” It does not by itself answer “how many of outputs 1–6 are on?”

Writing separate branches for every combination can implement the count condition, but it grows difficult to review and maintain. The count-based method avoids enumerating combinations. A shift register is also unnecessary: this is a running total for the current scan, not a history of past output states.

Attempt or symptom Why it misses the requirement Use instead
Test one or two output contacts Those contacts identify specific output states, not the total number of active outputs. Accumulate the six output conditions into a count.
List every combination of active outputs It can work, but changes to the six output rungs make the combination logic harder to maintain. Count each condition once and compare the result.
Increment a register without clearing it first The value carries over between scans and no longer represents the current scan’s six conditions. Reset the count before the six output conditions are evaluated.

Count the six output conditions once per scan

Use an integer data register as a temporary count. Initialize it to zero, add one for each of output conditions 1–6 that is true, and evaluate the result after all six conditions have been processed. The count can only be 0 through 6, so select an available register and data type that safely represents that range in the programming environment.

Count the logic conditions that command outputs 1–6, rather than counting output 7 or 8. The two dependent outputs must not contribute to their own decision. If the six conditions are represented by internal logic rather than a single output coil each, count the condition that actually determines each output.

Each scan, before output conditions 1–6:
    count := 0

For each condition 1–6 that is true:
    count := count + 1

After condition 6:
    evaluate count for outputs 7 and 8

This is conceptual logic, not model-specific instruction syntax. Implement the reset, conditional increment, and comparisons with the instructions and data-memory conventions available for the installed PLC and software.

Reset the count before processing outputs 1–6

PLC logic normally executes repeatedly in scan order. A reset placed before the six conditions makes the register a fresh count on each execution; conditional increments then build the total for that execution. Place the comparison logic after the six counting points so it sees the completed value.

  1. Choose an available integer register for the temporary count.
  2. At the start of the relevant logic, before any of the six output conditions, write zero to that register.
  3. For each of the six output conditions, add one only when that condition is true.
  4. After the sixth condition, compare the register against the required ranges and drive outputs 7 and 8.

Do not put the reset after the increments or in logic that executes only when one output condition is true. Either placement can erase or preserve stale values, making the result depend on scan history rather than the current six states.

Compare the count using the specified ranges

The stated requirements describe exact ranges, not “at least” thresholds. Use this decision table unless the machine specification is changed:

Count of true conditions 1–6 Output 7 Output 8
0, 1, or 2 Off Off
3 or 4 On Off
5 or 6 Off On

That table interprets “3 or 4” and “5 or 6” as mutually exclusive conditions. If the intended rule is instead “output 7 on at three or more” while output 8 turns on at five or more, output 7 must remain on for counts 5 and 6; confirm that requirement before programming. Avoid overlapping or contradictory comparisons that can write the same output in more than one place.

Keep scan order and output ownership consistent

Each of the six conditions should contribute no more than one increment during a scan. Put the increment on the true path for that condition, and ensure the path cannot execute repeatedly because of multiple branches or duplicated counting logic. If an output condition is built from several branches, count the resulting condition once; do not add one for every true branch.

Assign each output coil a clear controlling rung or logic location. If later logic rewrites output 7 or 8, the count comparison may appear correct while the final commanded output is not. Keep output 7 and 8 dependent on the completed count, and do not use their states to calculate that same count.

A count of commanded logic states is not electrical feedback. If the requirement concerns whether loads actually energized, rather than whether the PLC commanded outputs 1–6 on, use suitable field feedback and define the counting rule around those feedback signals. The original condition is based on outputs being “on,” so confirm whether command state is the intended meaning.

Verify the count before returning the machine to service

Monitor the temporary count and each output condition while testing safely. Exercise cases below, at, and above both boundaries: counts 2, 3, 4, 5, and 6. Also test count 0 or 1 if the machine can produce those states. Verify that output 7 changes only at the 3/4 range and output 8 only at the 5/6 range under the stated interpretation.

  • Confirm the register returns to zero at the beginning of each scan before increments occur.
  • Confirm each true condition among outputs 1–6 adds exactly one and each false condition adds none.
  • Confirm outputs 7 and 8 are evaluated after condition 6 and follow the range table.
  • Repeat transitions between ranges, such as 4 to 5 and 5 to 4, to catch stale counts or retained output commands.

Use the PLC’s normal programming and diagnostic tools to inspect the logic and register. Do not infer actual load energization solely from a commanded output bit; check the appropriate field indication or feedback when physical operation matters.

Check these C0-00DR-D output-counting questions

Can I use output contacts to count how many outputs are on?

Contacts can test individual output logic states, but you still need logic that accumulates the six states into a total. Increment the count once for each true condition among outputs 1–6.

Does the count register need to be reset every scan?

Yes. Reset it to zero before the six output conditions are evaluated, then add the true conditions for that scan. Without the reset, the value carries forward and stops representing the current scan.

Can I use a shift register for outputs 7 and 8?

A shift register is not needed for this requirement because the decision depends on the current number of true conditions, not their history. Use an integer register as a temporary count.

Does output 7 stay on when five or six outputs are on?

Not under the stated exact-range interpretation: output 7 is on for counts 3 or 4, and output 8 is on for counts 5 or 6. If output 7 should stay on at five or six, change its rule to a threshold and confirm that behavior with the machine specification.

When should I stop and contact official support?

Stop before downloading or returning the machine to service if the available register type or instruction behavior is unclear, or if online logic does not match the actual outputs. Check the programming documentation for the installed PLC and contact AutomationDirect official support for model-specific programming help.

Back to blog