A Function Block is a reusable code unit that contains inputs, outputs, and internal logic. It helps organize and simplify complex control tasks by grouping related operations together.
Click to reveal answer
beginner
How do you define inputs and outputs in a Function Block?
Inputs and outputs are defined in the interface section of the Function Block. Inputs receive data from outside, and outputs send data out after processing.
Click to reveal answer
intermediate
Why use Function Blocks instead of simple functions in PLC programming?
Function Blocks can keep internal states between calls, unlike simple functions. This makes them ideal for tasks that need memory, like timers or counters.
Click to reveal answer
beginner
What is the typical structure of a Function Block definition?
A Function Block usually has: an interface section (inputs, outputs, internal variables), a body with the logic, and sometimes an initialization part.
Click to reveal answer
intermediate
Can a Function Block be instantiated multiple times in a PLC program?
Yes, you can create multiple instances of a Function Block. Each instance keeps its own data and works independently.
Click to reveal answer
What part of a Function Block defines the data it receives and sends?
ABody section
BInterface section
CInitialization section
DComments section
✗ Incorrect
The interface section defines inputs and outputs, which are the data received and sent by the Function Block.
Which feature makes Function Blocks different from simple functions in PLC programming?
AThey can store internal state
BThey cannot have inputs
CThey run only once
DThey do not have outputs
✗ Incorrect
Function Blocks can keep internal state between calls, unlike simple functions.
How many instances of a Function Block can you create in a PLC program?
AOnly one
BExactly two
CMultiple independent instances
DNone
✗ Incorrect
You can create multiple instances of a Function Block, each with its own data.
Where do you write the logic inside a Function Block?
AIn the body section
BIn the interface section
CIn the comments
DIn the documentation
✗ Incorrect
The body section contains the logic that processes inputs and sets outputs.
What is a common use case for Function Blocks in PLC programming?
AText formatting
BOnly simple math
CWeb page design
DTimers and counters
✗ Incorrect
Timers and counters need to remember state, so Function Blocks are perfect for them.
Explain what a Function Block is and why it is useful in PLC programming.
Think about how you group related tasks in real life to keep things simple.
You got /4 concepts.
Describe the main parts of a Function Block definition and their roles.
Consider how you set up a recipe: ingredients (inputs), steps (logic), and final dish (outputs).
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of a Function Block in PLC programming?
easy
A. To group inputs, outputs, and code for repeated tasks
B. To store data permanently in the PLC
C. To create a graphical user interface
D. To connect the PLC to external devices
Solution
Step 1: Understand the role of function blocks
Function blocks group inputs, outputs, and code to perform tasks repeatedly in PLC programs.
Step 2: Compare options with the definition
Only To group inputs, outputs, and code for repeated tasks describes grouping inputs, outputs, and code for reuse, which matches the function block purpose.
Final Answer:
To group inputs, outputs, and code for repeated tasks -> Option A
Quick Check:
Function block purpose = Group inputs, outputs, and code [OK]
Hint: Function blocks bundle inputs, outputs, and code for reuse [OK]
Common Mistakes:
Confusing function blocks with data storage
Thinking function blocks create user interfaces
Assuming function blocks connect hardware directly
2. Which of the following is the correct way to start defining a function block named MotorControl in IEC 61131-3 structured text?
easy
A. PROGRAM MotorControl
B. FUNCTION MotorControl
C. VAR MotorControl
D. FUNCTION_BLOCK MotorControl
Solution
Step 1: Recall syntax for function block definition
In IEC 61131-3, function blocks start with the keyword FUNCTION_BLOCK followed by the name.
Step 2: Check each option
FUNCTION_BLOCK MotorControl uses FUNCTION_BLOCK MotorControl, which is correct. Options A, B, and D use other keywords for different constructs.
Final Answer:
FUNCTION_BLOCK MotorControl -> Option D
Quick Check:
Function block syntax = FUNCTION_BLOCK Name [OK]
Hint: Function blocks start with FUNCTION_BLOCK keyword [OK]
Common Mistakes:
Using FUNCTION instead of FUNCTION_BLOCK
Confusing PROGRAM with function block
Using VAR keyword to define function blocks
3. Given this function block code snippet, what will be the output of FB1.Output after calling FB1.Run() twice?
FUNCTION_BLOCK FB1
VAR_INPUT
In: BOOL;
END_VAR
VAR_OUTPUT
Output: INT;
END_VAR
VAR
Counter: INT := 0;
END_VAR
METHOD PUBLIC Run
IF In THEN
Counter := Counter + 1;
END_IF
Output := Counter;
END_METHOD
END_FUNCTION_BLOCK
// Usage:
FB1.In := TRUE;
FB1.Run();
FB1.Run();
medium
A. 2
B. 1
C. 0
D. TRUE
Solution
Step 1: Understand the counter increment logic
Each call to Run checks if In is TRUE, then increments Counter by 1.
Step 2: Trace two calls with In = TRUE
First call increments Counter from 0 to 1, second call increments from 1 to 2. Output is set to Counter.
Final Answer:
2 -> Option A
Quick Check:
Counter increments twice with In=TRUE = 2 [OK]
Hint: Count increments each Run call if input TRUE [OK]
Common Mistakes:
Assuming Output resets each call
Confusing BOOL and INT output types
Forgetting Counter is retained between calls
4. Identify the error in this function block definition:
FUNCTION_BLOCK FB_Error
VAR_INPUT
Start: BOOL;
END_VAR
VAR_OUTPUT
Status: BOOL;
END_VAR
VAR
Count: INT;
END_VAR
METHOD Run
IF Start THEN
Count := Count + 1
Status := TRUE;
END_IF
END_METHOD
END_FUNCTION_BLOCK
medium
A. Function block name cannot contain underscore
B. Missing semicolon after Count := Count + 1
C. Output variable Status should be input
D. Incorrect keyword METHOD used
Solution
Step 1: Check syntax inside the method
The line Count := Count + 1 is missing a semicolon at the end, which is required in structured text.
Step 2: Verify other parts
METHOD keyword is valid, output variable can be named Status, and underscores are allowed in names.
Final Answer:
Missing semicolon after Count := Count + 1 -> Option B
Quick Check:
Semicolon missing after assignment line [OK]
Hint: Check each line ends with semicolon in structured text [OK]
Common Mistakes:
Ignoring missing semicolons
Thinking METHOD keyword is invalid
Assuming variable naming rules are stricter
5. You want to create a function block TimerFB that counts seconds when Enable input is TRUE and resets when Reset input is TRUE. Which internal variable type should you use to store the count so it keeps its value between calls?
hard
A. VAR_INPUT
B. VAR_OUTPUT
C. VAR (internal variable)
D. VAR_TEMP
Solution
Step 1: Understand variable types in function blocks
VAR_INPUT and VAR_OUTPUT are for inputs and outputs, not for storing internal state. VAR_TEMP is temporary and does not keep value between calls.
Step 2: Identify variable type that retains value
VAR variables inside function blocks keep their value between calls, acting like memory.
Final Answer:
VAR (internal variable) -> Option C
Quick Check:
Use VAR for internal memory in function blocks [OK]
Hint: Use VAR for internal memory that persists between calls [OK]
Common Mistakes:
Using VAR_TEMP which resets each call
Confusing inputs/outputs with internal storage
Assuming VAR_INPUT can store internal state
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.