🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Timers, Counters, and Comparison Instructions in PLCs

Industrial Automation & PLCPLC InstructionsđŸŸĸ Free Lesson

Timers, Counters, and Comparison Instructions in PLCs

What You'll Learn

  • 1Select the correct timer type for a delay requirement
  • 2Count events with up and down counters
  • 3Combine comparisons for bands and interlocks
  • 4Explain timer reset and retentive behavior

Timers, counters, and comparisons are the working vocabulary of discrete control. A timer delays or stretches an action relative to a rung condition, a counter accumulates events such as parts or jams, and comparison instructions turn numbers into decisions. Choosing the wrong timer type or forgetting a reset is a frequent source of intermittent faults, so reset rules and status bits deserve close attention.

Timer Types and Reset Rules

An on delay timer starts timing when its rung becomes true and sets the done bit when the accumulated time reaches the preset; if the rung goes false first, a non retentive timer resets immediately. An off delay timer does the opposite, timing after the rung goes false, which suits fan coast after stop or flash off logic. A pulse timer produces a fixed length pulse on a rising edge, ideal for stroke or blip outputs.

A retentive timer keeps its accumulated value when the rung drops out and advances again when the rung is true, and it must be cleared by an explicit reset. That behavior fits total run time for maintenance and soak cycles. Timers use their own time base, and mixing millisecond and second presets is a classic commissioning error, as is assuming a timer tracks wall clock time, which requires a real time clock instruction instead.

Counters and Event Accumulation

An up counter increments on a false to true transition of its input, a down counter decrements, and a reset instruction clears the accumulator. Only the edge matters, so holding a sensor on for many scans counts once provided the input transitions properly. Presets define a target such as a batch size or a jam threshold, and reaching the preset sets the done bit used by comparisons.

For pulses faster than the scan can resolve, use a high speed counter module or an encoder input rather than a program counter, because a scan can miss short edges entirely. Beware signed integer limits: an integer that reaches its maximum wraps or faults depending on the platform. Design counters with explicit reset conditions and handle overflow so a run counter cannot silently corrupt a batch quantity.

Comparisons and Bands

Comparison instructions test equal, not equal, greater than, less than, and the inclusive variants between limits. They convert measurements into alarms and interlocks: run the pump only when level is above minimum and below maximum, or stop when temperature exceeds trip. Limit comparisons provide a simple band check with a single instruction.

Analog values fluctuate, so a single comparison chatter creates alarm storms. Add hysteresis by using separate trip and reset thresholds, or a timer that must see the condition persist. Deadband tuning in the transmitter or the scaling block also reduces noise. Keep alarm limits documented with engineering units so a later range change cannot silently break the logic.

Timer and Counter Behavior

TypeTriggerReset Behavior
On delay TONRung goes trueResets when rung goes false
Off delay TOFRung goes falseAccumulates after rung drops
Pulse TPRising edgeRuns one preset width
Retentive RTORung true, accumulatesRequires explicit reset
Up counter CTUInput rising edgeExplicit reset only
Down counter CTDInput rising edgeExplicit reset only

Real-World Examples

  • Motor start delay — An on delay timer holds start until lubrication pressure is proven for three seconds before contactor pickup.
  • Conveyor jam detection — An up counter counts box edges and trips when a preset is reached without an empty gap clearing the count.
  • Batch box count — Two counters track total and remaining boxes, with a done bit triggering the discharge step.
  • High temperature alarm with hysteresis — A comparison trips at ninety degrees and resets at eighty five, preventing chatter at the limit.

📝Timers Are Not Clocks

A timer measures elapsed time while its rung conditions allow it to run. Scheduling by time of day needs a real time clock with calendar handling.

Common Mistakes

Assuming a non retentive timer holds its value

Fix: A false rung resets most timers, so use a retentive type or latch the value when accumulation matters.

Counting fast pulses in the scan

Fix: Short pulses between scans are missed; use a high speed counter or hardware interrupt input.

Using one threshold for trip and reset

Fix: Add hysteresis so an analog value sitting at the limit does not toggle the output every scan.

Key Takeaways

  • Timer type determines behavior when the rung condition disappears.
  • Counters count edges, not elapsed scans.
  • Retentive timers and counters need explicit resets.
  • Comparisons need hysteresis and persistence for analog signals.

Frequently Asked Questions

Why did my timer reset unexpectedly

A non retentive timer clears whenever its rung goes false, so check the rung conditions before blaming the preset.

How many pulses can a program counter catch

Only transitions the scan observes, so pulses shorter than the scan interval can be missed entirely.

What is the difference between a preset and a done bit

The preset is the target value; the done bit signals the accumulated value has reached it.

Interview Questions

Q1: Design a three second start delay that survives a momentary dropout

Use a retentive on delay timer with a separate reset condition, or filter the rung with a seal so a brief dropout does not restart the count.

Q2: How do you stop alarm chatter on an analog limit

Trip and reset at different thresholds, optionally combined with a confirmation timer so only sustained conditions annunciate.


Extended Learning: Beyond the Basics

Key Concepts Summary

This lesson covers fundamental concepts that serve as building blocks for more advanced topics. Master these basics before moving to intermediate and advanced material.

Prerequisite Knowledge

Before studying this topic in depth, ensure you understand:

  • Basic definitions and terminology
  • Core formulas and their derivations
  • Common applications in real-world scenarios
  • Typical pitfalls and misconceptions

Step-by-Step Walkthrough

Let us work through a complete example to solidify understanding:

Step 1: Identify the problem type. Determine which category this problem falls into and which approach is most appropriate.

Step 2: Apply the relevant formula. Substitute known values into the appropriate equation, paying attention to units and constraints.

Step 3: Simplify and solve. Work through the algebra step by step, checking each intermediate result.

Step 4: Verify the answer. Check that the solution satisfies the original conditions and makes logical sense.

Common Mistakes to Avoid

  1. Misidentifying the problem type — Always start by categorizing the problem
  2. Incorrect formula application — Verify the formula applies to your specific case
  3. Unit errors — Always check units are consistent throughout
  4. Sign errors — Pay careful attention to positive and negative values
  5. Rounding too early — Keep full precision until the final answer
  6. Forgetting constraints — Check that solutions satisfy all given conditions

Real-World Applications

Understanding this concept is essential for:

  • Advanced problem solving in examinations
  • Building intuition for more complex topics
  • Developing analytical thinking skills
  • Applying mathematical reasoning to practical situations

Practice Exercises

  1. Basic: Solve 5 problems of increasing difficulty using the core concept.
  2. Intermediate: Apply the concept to word problems with multiple steps.
  3. Advanced: Combine this concept with 2-3 other topics in a comprehensive problem.
  4. Challenge: Create your own problem that requires this concept plus additional knowledge.

Interview and Exam Tips

  • Common question patterns: Identify which exam or interview formats test this topic
  • Time management: Practice completing problems within time constraints
  • Common traps: Know the typical mistakes examiners set as distractors
  • Verification strategy: Develop a quick method to check your answer

Related Topics

Quick Reference Card

ConceptFormula/RuleKey InsightCommon Use
Core DefinitionSee main textUnderstand the intuitionFoundation for all applications
Key FormulaSee main textMemorize the derivationDirect problem solving
Special CaseSee main textRecognize when it appliesSimplifies complex problems
Edge CaseSee main textKnow the limitationsAvoids errors

Further Reading

For students who want to go deeper:

  • Standard textbooks on the subject
  • Research papers applying this concept
  • Online courses with video explanations
  • Practice problem collections with detailed solutions
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-11-14

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Industrial Automation & PLC Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement