Bird
Raised Fist0
PLC Programmingscripting~15 mins

Counter preset and reset in PLC Programming - Deep Dive

Choose your learning style10 modes available
Overview - Counter preset and reset
What is it?
A counter in PLC programming is a tool that counts events or pulses. The preset value is the target number the counter aims to reach. Resetting the counter means setting its current count back to zero or a starting point. These features help control processes by tracking how many times something happens and restarting the count when needed.
Why it matters
Without preset and reset functions, counters would keep counting endlessly or lose control over the process. This would make automation unreliable, causing machines to malfunction or produce errors. Using preset and reset allows precise control, ensuring machines act exactly when needed, improving safety and efficiency.
Where it fits
Before learning about counters, you should understand basic PLC programming concepts like inputs, outputs, and simple logic. After mastering counters, you can learn about timers, advanced control structures, and sequencing in automation.
Mental Model
Core Idea
A counter preset sets the goal number to reach, and reset clears the count to start fresh, controlling how many times an event is counted.
Think of it like...
Imagine a tally counter at a sports game: you set a goal number of cheers (preset), count each cheer, and when the game restarts, you press a button to reset the tally back to zero.
┌───────────────┐      ┌───────────────┐      ┌───────────────┐
│   Input Pulse │─────▶│   Counter     │─────▶│   Output      │
│ (Event Count) │      │ (Current Count│      │ (Reached Preset│
│               │      │   & Preset)   │      │   Signal)     │
└───────────────┘      └───────────────┘      └───────────────┘
         │                     │                      ▲
         │                     │                      │
         │                     │                      │
         │                 ┌───┴───┐                  │
         │                 │ Reset │◀─────────────────┘
         │                 └───────┘
Build-Up - 6 Steps
1
FoundationWhat is a Counter in PLC
🤔
Concept: Introduce the basic idea of a counter as a device that counts input events.
A counter in PLC programming counts how many times an input signal turns on. For example, it can count how many bottles pass on a conveyor belt. The counter increases by one each time the input pulse happens.
Result
The counter's current value increases by one for each input pulse.
Understanding that counters track events is the foundation for controlling processes based on counts.
2
FoundationUnderstanding Preset Value
🤔
Concept: Explain the preset as the target count the counter aims to reach.
The preset value is a number you set before running the counter. It tells the PLC when to stop counting or trigger an action. For example, if the preset is 10, the counter will signal when it reaches 10 counts.
Result
The counter compares its current count to the preset and signals when they match.
Knowing the preset lets you control when the counter triggers an output, making automation precise.
3
IntermediateHow Reset Works in Counters
🤔Before reading on: do you think resetting a counter sets it to zero or to the preset value? Commit to your answer.
Concept: Introduce the reset function that clears the current count to start over.
Resetting a counter means setting its current count back to zero (or sometimes another start value). This is useful when you want to begin counting again after reaching the preset or after a process cycle ends.
Result
The counter's current count returns to zero, ready to count new events.
Understanding reset is key to repeating counting cycles and avoiding incorrect counts.
4
IntermediateUsing Preset and Reset Together
🤔Before reading on: do you think the counter stops counting automatically at preset or needs a reset to continue? Commit to your answer.
Concept: Explain how preset and reset work together to control counting cycles.
When the counter reaches the preset, it can trigger an output signal. To count again, the counter must be reset. This cycle allows machines to perform repeated tasks, like filling bottles in batches of 10, then resetting to start counting the next batch.
Result
The counter triggers output at preset and resets to start a new count cycle.
Knowing the interaction between preset and reset enables designing repeatable and controlled automation steps.
5
AdvancedPreset and Reset in Different Counter Types
🤔Before reading on: do you think all counters reset the same way regardless of type? Commit to your answer.
Concept: Explore how preset and reset behave in up-counters, down-counters, and up/down counters.
Up-counters count up to the preset and reset to zero. Down-counters start at the preset and count down to zero. Up/down counters can count both ways and reset accordingly. The reset function always clears the current count but the starting point depends on counter type.
Result
Counters behave differently on reset depending on their counting direction and type.
Understanding counter types prevents errors when designing complex counting logic.
6
ExpertCommon Pitfalls with Preset and Reset Logic
🤔Before reading on: do you think resetting a counter during counting affects the output immediately or after next count? Commit to your answer.
Concept: Reveal subtle issues like resetting at wrong times or preset misconfiguration causing logic errors.
Resetting a counter while counting can cause missed counts or false outputs. Setting the preset too low or too high can trigger outputs too early or never. Also, forgetting to reset after reaching preset can stop the process. Proper timing and logic checks are essential.
Result
Incorrect reset or preset use leads to unreliable automation behavior.
Knowing these pitfalls helps avoid costly mistakes and ensures robust control systems.
Under the Hood
Internally, the PLC counter stores a current count value in memory. Each input pulse increments or decrements this value depending on counter type. The preset is stored as a fixed value to compare against. When current count equals preset, a status bit is set. Resetting clears the current count memory to zero or start value. The PLC scans inputs and updates counters every cycle, ensuring real-time counting.
Why designed this way?
Counters were designed to provide simple, reliable event counting in automation. Using a preset allows flexible target counts without changing program logic. Resetting lets processes repeat cleanly. Alternatives like continuous counting without reset would be less controllable and error-prone. This design balances simplicity and control.
┌───────────────┐
│ Input Pulse   │
└──────┬────────┘
       │
       ▼
┌───────────────┐       ┌───────────────┐       ┌───────────────┐
│ Current Count │──────▶│ Compare to    │──────▶│ Output Status │
│ (Memory)     │       │ Preset Value  │       │ (Bit Set)     │
└──────┬────────┘       └──────┬────────┘       └──────┬────────┘
       │                       │                       │
       │                       │                       │
       │                       │                       │
       │                 Equal? Yes/No                 │
       │                       │                       │
       │                       ▼                       │
       │                 ┌───────────┐                 │
       │                 │ Reset Cmd │◀────────────────┘
       │                 └───────────┘
       │                       │
       │                       ▼
       └───────────────── Clear Current Count
Myth Busters - 4 Common Misconceptions
Quick: Does resetting a counter erase the preset value? Commit to yes or no.
Common Belief:Resetting a counter clears both the current count and the preset value.
Tap to reveal reality
Reality:Reset only clears the current count; the preset value remains unchanged.
Why it matters:If you mistakenly think reset clears the preset, you might lose your target count and cause the process to malfunction.
Quick: Does a counter automatically reset after reaching the preset? Commit to yes or no.
Common Belief:Counters reset themselves automatically once they reach the preset value.
Tap to reveal reality
Reality:Counters do not reset automatically; a separate reset command or condition is needed.
Why it matters:Assuming automatic reset can cause the counter to stop counting further events, halting the process unexpectedly.
Quick: Can you reset a counter at any time without affecting counting accuracy? Commit to yes or no.
Common Belief:Resetting a counter anytime is safe and does not affect counting accuracy.
Tap to reveal reality
Reality:Resetting during counting can cause missed counts or false triggers if not timed properly.
Why it matters:Improper reset timing leads to unreliable automation and potential safety hazards.
Quick: Do up-counters and down-counters use preset and reset the same way? Commit to yes or no.
Common Belief:All counters use preset and reset identically regardless of counting direction.
Tap to reveal reality
Reality:Up-counters and down-counters handle preset and reset differently based on counting direction.
Why it matters:Ignoring these differences can cause logic errors and unexpected machine behavior.
Expert Zone
1
Some PLCs allow loading a custom reset value instead of zero, enabling flexible counting start points.
2
Preset values can be dynamically changed during runtime for adaptive control, but this requires careful synchronization.
3
Stacking multiple counters with shared reset signals can cause race conditions if not properly sequenced.
When NOT to use
Counters with preset and reset are not suitable for measuring time intervals; timers should be used instead. For complex counting like event frequency or pulse width, specialized function blocks or external sensors are better.
Production Patterns
In production, counters with preset and reset are used for batch processing, like counting items before packaging. They are combined with interlocks and safety checks to ensure resets happen only after confirming process completion.
Connections
Timers in PLC
Counters and timers both track events but timers measure time while counters measure quantity.
Understanding counters helps grasp timers since both use preset and reset concepts to control automation flow.
State Machines
Counters often serve as triggers within state machines to move between states after a set number of events.
Knowing counters clarifies how state transitions can be controlled by event counts in complex automation.
Inventory Management
Counters in PLCs relate to inventory counting systems that track stock levels and reorder points.
Seeing counters as physical inventory trackers bridges automation with business operations and logistics.
Common Pitfalls
#1Resetting the counter inside the counting loop causing missed counts.
Wrong approach:IF input_pulse THEN counter = counter + 1 counter = 0 // reset immediately END_IF
Correct approach:IF input_pulse THEN counter = counter + 1 END_IF IF reset_condition THEN counter = 0 END_IF
Root cause:Resetting immediately after increment prevents the count from increasing, losing event tracking.
#2Setting preset value after starting the counter causing inconsistent behavior.
Wrong approach:Start counter Set preset = 10 // Counting begins before preset is set
Correct approach:Set preset = 10 Start counter // Preset is ready before counting
Root cause:Changing preset during counting can cause the counter to miss or prematurely trigger outputs.
#3Assuming counter resets automatically after reaching preset.
Wrong approach:IF counter == preset THEN output = TRUE // No reset command END_IF
Correct approach:IF counter == preset THEN output = TRUE reset_counter() END_IF
Root cause:Forgetting to reset means the counter stops counting further events, halting process control.
Key Takeaways
Counters track how many times an event happens, using a preset to know when to act.
Resetting a counter clears its current count but does not change the preset target.
Preset and reset work together to create repeatable counting cycles essential for automation.
Different counter types handle preset and reset differently, so understanding their behavior is crucial.
Proper timing of reset commands prevents missed counts and ensures reliable machine operation.

Practice

(1/5)
1. What does the preset value in a PLC counter do?
easy
A. It sets the target count the counter must reach.
B. It resets the counter to zero.
C. It increments the counter by one.
D. It pauses the counter from counting.

Solution

  1. Step 1: Understand the role of preset in counters

    The preset value defines the goal number the counter counts up to before triggering an action.
  2. Step 2: Differentiate preset from reset and increment

    Reset clears the count, increment adds to count, but preset sets the target number.
  3. Final Answer:

    It sets the target count the counter must reach. -> Option A
  4. Quick Check:

    Preset = target count [OK]
Hint: Preset is the goal number, reset clears count [OK]
Common Mistakes:
  • Confusing preset with reset
  • Thinking preset increments count
  • Assuming preset pauses counting
2. Which of the following is the correct way to reset a counter named CNT1 in ladder logic?
easy
A. Use RES CNT1 instruction.
B. Use PRE CNT1 instruction.
C. Use INC CNT1 instruction.
D. Use SET CNT1 instruction.

Solution

  1. Step 1: Identify reset instruction syntax

    In PLC ladder logic, RES is the standard instruction to reset a counter.
  2. Step 2: Confirm other instructions meanings

    PRE sets preset, INC increments, SET sets bits, not reset counter.
  3. Final Answer:

    Use RES CNT1 instruction. -> Option A
  4. Quick Check:

    Reset = RES instruction [OK]
Hint: Reset uses RES instruction, not PRE or INC [OK]
Common Mistakes:
  • Using PRE instead of RES to reset
  • Confusing increment with reset
  • Using SET which is for bits, not counters
3. Given a counter with preset 5 and current count 3, what will be the count after two increments?
medium
A. 4
B. 5
C. 3
D. 6

Solution

  1. Step 1: Calculate count after increments

    Starting count is 3, two increments add 2, so 3 + 2 = 5.
  2. Step 2: Compare count to preset

    The count reaches the preset value 5 after two increments.
  3. Final Answer:

    5 -> Option B
  4. Quick Check:

    3 + 2 = 5 [OK]
Hint: Add increments to current count, compare to preset [OK]
Common Mistakes:
  • Not adding increments correctly
  • Confusing preset with current count
  • Assuming count resets automatically
4. A PLC counter is not resetting when the reset button is pressed. Which of these is the most likely cause?
medium
A. The preset value is set too high.
B. The increment instruction is used instead of reset.
C. The counter is already at zero.
D. The reset instruction is missing or not connected to the reset button.

Solution

  1. Step 1: Check reset wiring and instruction

    If the reset button does not trigger reset, likely the reset instruction is missing or not linked to the button.
  2. Step 2: Eliminate other causes

    Preset value or current count does not prevent reset; increment instruction wrong but would not cause no reset on button press.
  3. Final Answer:

    The reset instruction is missing or not connected to the reset button. -> Option D
  4. Quick Check:

    Reset fails if instruction missing or unlinked [OK]
Hint: Reset needs instruction linked to button [OK]
Common Mistakes:
  • Blaming preset for reset failure
  • Ignoring wiring or logic connection
  • Confusing increment with reset
5. You want a counter to count up to 10, then reset automatically and start counting again from zero. Which ladder logic setup achieves this?
hard
A. Set preset to 0, increment counter indefinitely.
B. Set preset to 10, reset counter manually with a button.
C. Set preset to 10, use counter done bit to trigger reset instruction.
D. Use reset instruction before counting starts only.

Solution

  1. Step 1: Understand automatic reset logic

    To reset automatically, use the counter's done bit (which is true when count reaches preset) to trigger the reset instruction.
  2. Step 2: Evaluate other options

    Manual reset requires user action, preset 0 is invalid for counting, resetting only before counting won't loop.
  3. Final Answer:

    Set preset to 10, use counter done bit to trigger reset instruction. -> Option C
  4. Quick Check:

    Done bit triggers reset for auto count loop [OK]
Hint: Use done bit to auto reset counter [OK]
Common Mistakes:
  • Relying on manual reset for auto counting
  • Setting preset to zero
  • Resetting only once before counting
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard