Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a reusable function block named 'Counter'.
PLC Programming
FUNCTION_BLOCK [1]
VAR
Count: INT;
END_VAR
END_FUNCTION_BLOCKAttempts:
3 left
💡 Hint
Common Mistakes
Using a generic or unrelated name like 'Timer' or 'MotorControl'.
✗ Incorrect
The function block is named 'Counter' to create a reusable counting block.
2fill in blank
mediumComplete the code to call the reusable function block 'Counter' and increment its count.
PLC Programming
VAR
MyCounter: [1];
END_VAR
MyCounter.Count := MyCounter.Count + 1;Attempts:
3 left
💡 Hint
Common Mistakes
Declaring the variable with an unrelated type like 'Timer' or 'Sensor'.
✗ Incorrect
The variable 'MyCounter' is declared as type 'Counter' to use the reusable block.
3fill in blank
hardFix the error in the function block call to correctly reset the counter.
PLC Programming
IF ResetSignal THEN
MyCounter.[1] := 0;
END_IFAttempts:
3 left
💡 Hint
Common Mistakes
Trying to reset a non-existent 'Reset' or 'Start' variable.
✗ Incorrect
The 'Count' variable inside the 'MyCounter' block is reset to zero.
4fill in blank
hardFill both blanks to create a reusable function block that toggles a boolean output.
PLC Programming
FUNCTION_BLOCK [1] VAR Output: BOOL := [2]; END_VAR END_FUNCTION_BLOCK
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated block names or initializing the output to TRUE.
✗ Incorrect
The function block is named 'ToggleBlock' and the boolean output is initialized to FALSE.
5fill in blank
hardFill all three blanks to define a reusable function block with an integer input, output, and a method to double the input.
PLC Programming
FUNCTION_BLOCK [1] VAR_INPUT InputValue: INT; END_VAR VAR_OUTPUT OutputValue: INT; END_VAR METHOD DoubleInput : VOID BEGIN OutputValue := InputValue [2] [3]; END_METHOD END_FUNCTION_BLOCK
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication.
Incorrect block names.
✗ Incorrect
The block is named 'DoubleBlock'. The method doubles the input by multiplying by 2.
