Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the counter value to zero.
PLC Programming
CTU_Counter.PV := [1];Attempts:
3 left
💡 Hint
Common Mistakes
Setting the initial value to 1 or a negative number causes incorrect counting.
✗ Incorrect
The preset value (PV) of a count-up counter should start at 0 to count upwards correctly.
2fill in blank
mediumComplete the code to increment the counter when the input is true.
PLC Programming
IF InputSignal THEN CTU_Counter.CU := [1]; END_IFAttempts:
3 left
💡 Hint
Common Mistakes
Using numeric values instead of boolean TRUE or FALSE.
✗ Incorrect
The count-up input (CU) must be set to TRUE to increment the counter.
3fill in blank
hardFix the error in resetting the counter value.
PLC Programming
IF ResetSignal THEN CTU_Counter.CV := [1]; END_IFAttempts:
3 left
💡 Hint
Common Mistakes
Resetting to the preset value or current value does not clear the counter.
✗ Incorrect
The current value (CV) must be reset to zero to clear the counter.
4fill in blank
hardFill both blanks to check if the counter has reached its preset value.
PLC Programming
IF CTU_Counter.CV [1] CTU_Counter.PV THEN CTU_Counter.Q := [2]; END_IF
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>=' causes wrong output.
Setting Q to FALSE when the count is reached.
✗ Incorrect
The counter output (Q) becomes TRUE when current value (CV) is greater than or equal to preset value (PV).
5fill in blank
hardFill all three blanks to create a dictionary of counts for items with counts above zero.
PLC Programming
CountsAboveZero := { [1]: [2] for [3] in Items if Items[[3]] > 0 }Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Not accessing the dictionary value correctly.
✗ Incorrect
We use 'item' as key, 'Items[item]' as value, and iterate over 'item' in Items to filter counts > 0.
