Bird
Raised Fist0
PLC Programmingscripting~10 mins

Count-down counter (CTD) behavior in PLC Programming - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Count-down counter (CTD) behavior
Start
↓
Load preset value
↓
Wait for count-down input
↓
Input active?
No→Hold current count
Yes↓
Decrement count by 1
↓
Count = 0?
No→Wait for next input
Yes↓
Set done flag
↓
Stop or reset
↓
End
The count-down counter starts with a preset value, waits for input to decrement, decreases the count each input, and sets a done flag when count reaches zero.
Execution Sample
PLC Programming
PRESET = 5
COUNT = PRESET
DONE = False
INPUT = True
if INPUT and COUNT > 0:
  COUNT = COUNT - 1
if COUNT == 0:
  DONE = True
This code simulates a countdown from 5, decreasing count by 1 when input is active, and sets done when count reaches zero.
Execution Table
StepINPUTCOUNT BeforeCondition INPUT?COUNT AfterCOUNT == 0?DONE Flag
1True5Yes4NoFalse
2True4Yes3NoFalse
3True3Yes2NoFalse
4True2Yes1NoFalse
5True1Yes0YesTrue
6True0Yes0YesTrue
7False0No0YesTrue
💡 Count reached zero at step 5, DONE flag set; further inputs do not decrement count below zero.
Variable Tracker
VariableStartAfter 1After 2After 3After 4After 5After 6After 7
COUNT54321000
DONEFalseFalseFalseFalseFalseTrueTrueTrue
INPUTTrueTrueTrueTrueTrueTrueTrueFalse
Key Moments - 3 Insights
Why does the COUNT not go below zero after step 5?
Because the condition COUNT == 0 sets the DONE flag and the count is not decremented further, as shown in execution_table rows 5 to 7.
What happens if INPUT is False at step 7?
The count does not decrement because the condition INPUT? is No, so COUNT stays at zero and DONE remains True, as seen in execution_table row 7.
Why is the DONE flag set only when COUNT reaches zero?
The DONE flag is set exactly when COUNT == 0 condition is true, indicating the countdown finished, as shown in execution_table at step 5.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the COUNT value after step 3?
A1
B2
C3
D4
💡 Hint
Check the 'COUNT After' column for step 3 in the execution_table.
At which step does the DONE flag first become True?
AStep 6
BStep 4
CStep 5
DStep 7
💡 Hint
Look at the 'DONE Flag' column in the execution_table to find when it changes to True.
If INPUT was False at step 2, what would happen to COUNT at step 3?
ACOUNT would stay at 4
BCOUNT would decrement to 3
CCOUNT would reset to 5
DDONE flag would be set
💡 Hint
Refer to the 'Condition INPUT?' column in execution_table and see how COUNT changes when INPUT is False.
Concept Snapshot
Count-down counter (CTD) behavior:
- Start with PRESET value loaded into COUNT.
- When INPUT is active, decrement COUNT by 1.
- If COUNT reaches zero, set DONE flag.
- COUNT does not go below zero.
- Further inputs after zero do not change COUNT or DONE.
Full Transcript
This visual execution trace shows how a count-down counter (CTD) works in PLC programming. The counter starts at a preset value, here 5. Each time the input signal is active, the counter decreases by one. When the count reaches zero, a done flag is set to indicate completion. The count does not go below zero even if the input remains active. If the input is inactive, the count holds its current value. This behavior is shown step-by-step in the execution table and variable tracker, helping beginners understand how the CTD operates in real time.

Practice

(1/5)
1. What does a Count-down counter (CTD) do in a PLC program?
easy
A. It resets the count value to zero automatically.
B. It increases a count value each time an input signal is active.
C. It decreases a count value each time an input signal is active.
D. It counts the number of times a timer has finished.

Solution

  1. Step 1: Understand CTD basic function

    A Count-down counter decreases its count value when triggered by an input signal.
  2. Step 2: Compare options with CTD behavior

    Only It decreases a count value each time an input signal is active. describes decreasing the count on input signal activation, matching CTD behavior.
  3. Final Answer:

    It decreases a count value each time an input signal is active. -> Option C
  4. Quick Check:

    CTD decreases count on input = C [OK]
Hint: CTD always counts down, not up or reset automatically [OK]
Common Mistakes:
  • Confusing CTD with count-up counter
  • Thinking CTD resets count automatically
  • Assuming CTD counts timer completions
2. Which of the following is the correct syntax to declare a CTD counter named CTD1 with a preset value of 10 in a typical PLC program?
easy
A. CTD1.CNT := 10;
B. CTD1.PV = 10;
C. CTD1.PRESET = 10;
D. CTD1.PRE := 10;

Solution

  1. Step 1: Identify correct preset syntax

    In PLCs, the preset value for counters is often set with the .PRE property using := for assignment.
  2. Step 2: Check each option

    CTD1.PRE := 10; uses CTD1.PRE := 10; which is correct syntax. Others use incorrect property names or assignment operators.
  3. Final Answer:

    CTD1.PRE := 10; -> Option D
  4. Quick Check:

    Preset uses .PRE and := assignment = A [OK]
Hint: Preset value uses .PRE and := in PLC counters [OK]
Common Mistakes:
  • Using wrong property names like PV or PRESET
  • Using = instead of := for assignment
  • Assigning count value instead of preset
3. Given a CTD counter with preset 5 and current count 3, what will be the count after one input pulse activates the count-down input?
medium
A. 2
B. 5
C. 3
D. 4

Solution

  1. Step 1: Understand CTD count behavior on input pulse

    Each input pulse decreases the current count by 1, but never below zero.
  2. Step 2: Calculate new count

    Starting from 3, after one pulse, count becomes 3 - 1 = 2.
  3. Final Answer:

    2 -> Option A
  4. Quick Check:

    3 - 1 = 2 [OK]
Hint: Count decreases by one per input pulse, never below zero [OK]
Common Mistakes:
  • Adding instead of subtracting count
  • Not changing count on input pulse
  • Resetting count to preset incorrectly
4. A CTD counter is not decreasing its count when the input signal is active. Which of the following is the most likely cause?
medium
A. The preset value is set to zero.
B. The input signal is connected to the count-up input instead of count-down.
C. The count value is already zero.
D. The counter is not enabled.

Solution

  1. Step 1: Analyze why count does not decrease

    If the input signal is connected to the wrong input (count-up instead of count-down), the count will not decrease as expected.
  2. Step 2: Evaluate other options

    Preset zero or count zero would not prevent counting down if input is correct. Counter enable is usually implicit or separate.
  3. Final Answer:

    The input signal is connected to the count-up input instead of count-down. -> Option B
  4. Quick Check:

    Wrong input connection stops count down = B [OK]
Hint: Check input wiring: count-down input must receive signal [OK]
Common Mistakes:
  • Assuming preset zero stops counting
  • Ignoring input wiring errors
  • Confusing enable with input signal
5. You have a CTD counter with preset 8 and current count 1. If the count-down input activates twice quickly before the PLC scans again, what will be the count value after the scan?
hard
A. 0
B. -1
C. 1
D. 2

Solution

  1. Step 1: Understand count-down behavior with rapid inputs

    The CTD counter decreases count by 1 per input pulse but never below zero.
  2. Step 2: Calculate count after two pulses from 1

    First pulse: 1 - 1 = 0; second pulse: cannot go below 0, so remains 0.
  3. Final Answer:

    0 -> Option A
  4. Quick Check:

    Count never negative, min is zero = A [OK]
Hint: Count never goes below zero, even with multiple pulses [OK]
Common Mistakes:
  • Allowing count to go negative
  • Ignoring multiple pulses before scan
  • Assuming count resets automatically
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