Bird
Raised Fist0
PLC Programmingscripting~10 mins

Count-up counter (CTU) behavior in PLC Programming - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Count-up counter (CTU) behavior
Start
↓
Input: CU (Count Up) signal
↓
Is CU rising edge?
No→Hold current count
Yes↓
Increment counter value
↓
Compare counter with preset
↓
If count >= preset
Yes→Set Q (Output) = TRUE
No↓
Set Q = FALSE
↓
End cycle
The CTU counts up on each rising edge of the CU input, increments the count, compares it to a preset, and sets output Q accordingly.
Execution Sample
PLC Programming
CU = [0,1,0,1,1,0,1]
Preset = 3
Count = 0
Q = FALSE
For each CU rising edge:
  Count += 1
  Q = (Count >= Preset)
This simulates a CTU counting rising edges of CU input and setting Q when count reaches preset.
Execution Table
StepCU InputRising Edge?Count BeforeCount AfterCount >= Preset?Q Output
10No00NoFALSE
21Yes01NoFALSE
30No11NoFALSE
41Yes12NoFALSE
51No (no rising edge)22NoFALSE
60No22NoFALSE
71Yes23YesTRUE
💡 End of CU input sequence; count reached preset at step 7, Q set to TRUE.
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5After 6After 7
CU0101101N/A
Count00112223
QFALSEFALSEFALSEFALSEFALSEFALSEFALSETRUE
Key Moments - 3 Insights
Why doesn't the counter increment when CU stays at 1 in step 5?
Because the CTU only increments on a rising edge (0 to 1). At step 5, CU was already 1, so no rising edge occurred (see execution_table step 5).
Why is Q FALSE even when count is less than preset?
Q only becomes TRUE when count is equal or greater than preset. Before step 7, count was less than preset, so Q remained FALSE (see execution_table steps 2-6).
What triggers the count to increase?
A rising edge on CU input triggers the count to increase by 1 (see execution_table steps 2,4,7).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the count value after step 4?
A2
B1
C3
D0
💡 Hint
Check the 'Count After' column at step 4 in the execution_table.
At which step does Q output become TRUE?
AStep 5
BStep 7
CStep 3
DStep 2
💡 Hint
Look at the 'Q Output' column in the execution_table to find when it changes to TRUE.
If CU input was always 0, what would happen to the count?
ACount would keep increasing
BCount would stay at 0
CCount would reset to preset
DCount would become negative
💡 Hint
Refer to the 'Rising Edge?' column in the execution_table; no rising edge means no count increment.
Concept Snapshot
Count-up counter (CTU) behavior:
- Counts rising edges of CU input
- Increments count on each rising edge
- Compares count to preset value
- Sets output Q TRUE if count >= preset
- Holds count and Q otherwise
Full Transcript
A count-up counter (CTU) in PLC programming increases its count each time the CU input signal changes from 0 to 1, called a rising edge. The counter starts at zero and increments by one on each rising edge. After incrementing, it compares the current count to a preset value. If the count is equal to or greater than the preset, the output Q becomes TRUE. If not, Q stays FALSE. If CU stays high without changing from 0 to 1, the count does not increase. This behavior ensures the counter only counts distinct events signaled by rising edges.

Practice

(1/5)
1. What does the done bit in a CTU (Count-Up Counter) indicate?
easy
A. The counter has reached its preset value
B. The counter is reset to zero
C. The counter is currently counting down
D. The counter input is inactive

Solution

  1. Step 1: Understand the done bit role

    The done bit is a signal that shows when the counter has reached its preset value.
  2. Step 2: Relate done bit to counting

    When the count equals the preset, the done bit turns ON to indicate completion.
  3. Final Answer:

    The counter has reached its preset value -> Option A
  4. Quick Check:

    Done bit = preset reached [OK]
Hint: Done bit means count reached preset value [OK]
Common Mistakes:
  • Confusing done bit with reset signal
  • Thinking done bit means counting down
  • Assuming done bit is always ON
2. Which of the following is the correct syntax to declare a CTU counter named C1 with a preset of 10 in a typical PLC program?
easy
A. CTU C1 PRE 10
B. CTU(C1, 10);
C. CTU C1, PRE:=10;
D. Counter CTU C1 = 10;

Solution

  1. Step 1: Identify correct CTU declaration syntax

    Typical PLC syntax uses the format: CTU counterName, PRE:=presetValue;
  2. Step 2: Match options to syntax

    CTU C1, PRE:=10; matches the correct syntax with CTU C1, PRE:=10;
  3. Final Answer:

    CTU C1, PRE:=10; -> Option C
  4. Quick Check:

    CTU declaration uses PRE:= preset [OK]
Hint: Look for PRE:= syntax in CTU declaration [OK]
Common Mistakes:
  • Using parentheses incorrectly
  • Missing PRE:= keyword
  • Using assignment '=' instead of ':='
3. Given a CTU counter with preset 5 and current count 3, what will be the count and done bit after two rising input pulses?
medium
A. Count = 3, Done bit = TRUE
B. Count = 4, Done bit = FALSE
C. Count = 5, Done bit = FALSE
D. Count = 5, Done bit = TRUE

Solution

  1. Step 1: Add two pulses to current count

    Starting at 3, two pulses increase count to 5 (3 + 2 = 5).
  2. Step 2: Check if count reached preset

    Count equals preset (5), so done bit becomes TRUE.
  3. Final Answer:

    Count = 5, Done bit = TRUE -> Option D
  4. Quick Check:

    Count + pulses = preset -> done bit TRUE [OK]
Hint: Add pulses to count, compare with preset [OK]
Common Mistakes:
  • Not updating count correctly
  • Confusing done bit state
  • Assuming done bit is TRUE before preset reached
4. A CTU counter is not setting the done bit even after the count reaches the preset. Which of the following is the most likely cause?
medium
A. The preset value is set higher than intended
B. The done bit is wired incorrectly in the program
C. The counter is counting down instead of up
D. The counter is not receiving rising edge pulses

Solution

  1. Step 1: Analyze why done bit is not set

    If count reaches preset but done bit stays off, wiring or logic for done bit is likely wrong.
  2. Step 2: Evaluate other options

    If pulses were missing or counting down, count wouldn't reach preset. Preset too high means count can't reach it.
  3. Final Answer:

    The done bit is wired incorrectly in the program -> Option B
  4. Quick Check:

    Done bit wiring error causes no done signal [OK]
Hint: Check done bit wiring if count reaches preset but no done [OK]
Common Mistakes:
  • Assuming pulses are missing without checking
  • Ignoring done bit wiring
  • Confusing counting direction with done bit issue
5. You have a CTU counter with preset 10. The input pulses come irregularly, sometimes multiple pulses at once. How should you modify the program to ensure the count never exceeds the preset and done bit is set correctly?
hard
A. Ignore extra pulses; CTU automatically limits count to preset
B. Use a separate timer to count pulses instead of CTU
C. Add logic to reset the counter when count exceeds preset
D. Increase the preset value to a higher number

Solution

  1. Step 1: Understand CTU behavior with irregular pulses

    CTU increments by 1 per rising edge and automatically limits the accumulator to the preset value, preventing overflow.
  2. Step 2: Verify done bit sets correctly

    No modification needed; done bit activates when accumulator reaches preset, even with irregular pulses.
  3. Final Answer:

    Ignore extra pulses; CTU automatically limits count to preset -> Option A
  4. Quick Check:

    CTU ACC ≤ PRE automatically, done sets [OK]
Hint: CTU automatically limits count to preset [OK]
Common Mistakes:
  • Assuming CTU allows count to exceed preset
  • Adding unnecessary reset logic for overflow
  • Using timer or increasing preset unnecessarily
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