Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the CTD counter preset value.
PLC Programming
CTD_Counter.Preset := [1];Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name instead of a number for the preset.
Assigning a reset signal to the preset.
✗ Incorrect
The preset value sets the starting count for the CTD counter. Here, 10 is a valid preset number.
2fill in blank
mediumComplete the code to decrement the CTD counter when the input is active.
PLC Programming
IF [1] THEN CTD_Counter.Count := CTD_Counter.Count - 1; END_IF;
Attempts:
3 left
💡 Hint
Common Mistakes
Using the reset signal instead of the input signal.
Using the output signal as the condition.
✗ Incorrect
The counter decrements when the input signal is active, so 'Input' is the correct condition.
3fill in blank
hardFix the error in the code to reset the CTD counter correctly.
PLC Programming
IF [1] THEN
CTD_Counter.Count := CTD_Counter.Preset;
END_IF;Attempts:
3 left
💡 Hint
Common Mistakes
Using the input signal instead of reset.
Trying to reset using the output or count variables.
✗ Incorrect
The reset signal should trigger the counter to reset its count to the preset value.
4fill in blank
hardFill both blanks to check if the CTD counter has reached zero and set the output.
PLC Programming
IF CTD_Counter.Count [1] 0 THEN CTD_Counter.[2] := TRUE; ELSE CTD_Counter.Output := FALSE; END_IF;
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '<=' for the count check.
Setting the count variable instead of output to TRUE.
✗ Incorrect
The counter output is set to TRUE when the count is less than or equal to zero, indicating the count-down is complete.
5fill in blank
hardFill all three blanks to create a dictionary that maps counter names to their current counts if counts are above zero.
PLC Programming
ActiveCounters := { [1]: [2] for [1], [2] in Counters.items() if [2] > 0 };Attempts:
3 left
💡 Hint
Common Mistakes
Using the same variable name for both key and value.
Not filtering counts greater than zero.
✗ Incorrect
The dictionary comprehension uses 'name' and 'count' as variable names to map counter names to counts, filtering counts greater than zero.
