Challenge - 5 Problems
Function Block Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediateOutput of multiple function block instances
Consider a PLC program where two instances of a function block
Counter are used. Each instance counts independently. What will be the output values of Counter1.CV and Counter2.CV after the following code runs?PLC Programming
FUNCTION_BLOCK Counter VAR CV : INT := 0; // Current value END_VAR METHOD Increment CV := CV + 1; END_METHOD END_FUNCTION_BLOCK PROGRAM PLC_PRG VAR Counter1 : Counter; Counter2 : Counter; END_VAR Counter1.Increment(); Counter1.Increment(); Counter2.Increment();
Attempts:
2 left
💡 Hint
Each function block instance maintains its own state independently.
✗ Incorrect
Each instance of the function block has its own variable
CV. Calling Increment() on Counter1 twice increases its CV to 2. Calling Increment() once on Counter2 sets its CV to 1.🧠 Conceptual
intermediateUnderstanding instance data in function blocks
Why do function block instances in PLC programming maintain separate data for each instance?
Attempts:
2 left
💡 Hint
Think about how multiple devices or sensors might be controlled independently.
✗ Incorrect
Each function block instance has its own memory to store variables so that it can operate independently without interfering with other instances.
🔧 Debug
advancedIdentify the error in function block instance usage
What error will occur when running this PLC code snippet?
PLC Programming
FUNCTION_BLOCK Timer VAR TimeElapsed : TIME := T#0s; END_VAR METHOD Start TimeElapsed := TimeElapsed + T#1s; END_METHOD END_FUNCTION_BLOCK PROGRAM PLC_PRG VAR Timer1 : Timer; END_VAR Timer1.Start(); Timer2.Start();
Attempts:
2 left
💡 Hint
Check variable declarations before usage.
✗ Incorrect
The variable 'Timer2' is used without declaration, causing a compilation error.
🚀 Application
advancedUsing multiple function block instances for independent control
You want to control two independent motors using the same function block
MotorControl. Which code snippet correctly creates two independent instances and starts both motors?Attempts:
2 left
💡 Hint
Each motor needs its own instance to operate independently.
✗ Incorrect
Declaring two separate instances 'Motor1' and 'Motor2' allows independent control. Calling Start() on both instances starts both motors separately.
📝 Syntax
expertCorrect syntax for declaring and using function block instances
Which option shows the correct syntax to declare two instances of a function block
FB_Process and call their Execute method?Attempts:
2 left
💡 Hint
Function block instances are declared without parentheses.
✗ Incorrect
Option A correctly declares two separate instances with individual lines and calls their methods. Parentheses are not used in declarations.
