Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the batch counter to zero.
PLC Programming
BatchCounter := [1];Attempts:
3 left
💡 Hint
Common Mistakes
Setting the counter to 1 instead of 0
Using TRUE or FALSE which are boolean values
✗ Incorrect
The batch counter should start at zero to count batches correctly.
2fill in blank
mediumComplete the code to increment the batch counter by one when a batch is completed.
PLC Programming
IF BatchComplete THEN
BatchCounter := BatchCounter [1] 1;
END_IFAttempts:
3 left
💡 Hint
Common Mistakes
Using minus (-) which decreases the count
Using multiplication or division which changes the count incorrectly
✗ Incorrect
To increase the counter by one, use the plus (+) operator.
3fill in blank
hardFix the error in the condition to reset the batch counter when the reset button is pressed.
PLC Programming
IF [1] THEN BatchCounter := 0; END_IF
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operator ':=' inside IF
Using equality operator '==' which is not standard in PLC
Writing 'ResetButton = TRUE' which is an assignment, not a condition
✗ Incorrect
In PLC programming, using the variable directly in the IF condition checks if it is TRUE.
4fill in blank
hardFill both blanks to create a condition that checks if the batch counter has reached the target and sets the batch complete flag.
PLC Programming
IF BatchCounter [1] TargetBatchCount THEN BatchComplete := [2]; END_IF
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which checks the wrong condition
Setting the flag to FALSE instead of TRUE
✗ Incorrect
The batch is complete when the counter is greater or equal to the target, so set the flag to TRUE.
5fill in blank
hardFill all three blanks to create a dictionary-like structure that maps batch names to their counts, including only batches with counts greater than zero.
PLC Programming
BatchCounts := { [1]: [2] for [1], [2] in BatchData.items() if [2] > 0 }Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names
Using the key name in the condition instead of the count
✗ Incorrect
We use 'batchName' and 'count' as variable names for keys and values, and filter counts greater than zero.
