Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define the initial state in the ladder logic.
PLC Programming
IF current_state = [1] THEN
next_state := STATE_1;
END_IFAttempts:
3 left
💡 Hint
Common Mistakes
Choosing a state other than the initial one.
Using a state number that does not exist.
✗ Incorrect
The initial state is usually defined as STATE_0 to start the state machine.
2fill in blank
mediumComplete the code to transition to the next state when the input is true.
PLC Programming
IF input_signal = TRUE THEN
current_state := [1];
END_IFAttempts:
3 left
💡 Hint
Common Mistakes
Assigning the wrong next state.
Not updating the current_state variable.
✗ Incorrect
When the input is true, the machine moves to STATE_2 as the next step.
3fill in blank
hardFix the error in the state transition condition.
PLC Programming
IF current_state = STATE_1 AND [1] = TRUE THEN
current_state := STATE_2;
END_IFAttempts:
3 left
💡 Hint
Common Mistakes
Using output_signal or timer_done incorrectly.
Confusing reset_signal with input_signal.
✗ Incorrect
The transition depends on the input_signal being TRUE to move from STATE_1 to STATE_2.
4fill in blank
hardFill both blanks to complete the state machine logic for resetting and advancing states.
PLC Programming
IF [1] = TRUE THEN current_state := STATE_0; ELSIF current_state = STATE_0 AND [2] = TRUE THEN current_state := STATE_1; END_IF
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up reset and input signals.
Using timer_done or output_signal incorrectly.
✗ Incorrect
The reset_signal resets the state machine to STATE_0, and input_signal moves it from STATE_0 to STATE_1.
5fill in blank
hardFill all three blanks to complete the dictionary comprehension that maps states to their next states based on input.
PLC Programming
state_transitions = {
[1]: [2],
STATE_1: STATE_2,
STATE_2: [3]
}Attempts:
3 left
💡 Hint
Common Mistakes
Incorrectly mapping states out of order.
Repeating the same state as next state.
✗ Incorrect
STATE_0 maps to STATE_1, STATE_1 maps to STATE_2, and STATE_2 maps to STATE_3 in the state machine.
