Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start the drum sequencer timer.
PLC Programming
IF start_button = TRUE THEN
timer_[1] := TRUE;
END_IF;Attempts:
3 left
💡 Hint
Common Mistakes
Using TOF which is a timer off delay and does not start immediately.
Using TP which is a pulse timer, not suitable for continuous timing.
✗ Incorrect
The TON timer is used to start timing when the start button is pressed.
2fill in blank
mediumComplete the code to increment the step counter when the timer is done.
PLC Programming
IF timer_done = TRUE THEN step_counter := step_counter [1] 1; END_IF;
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' which would decrease the step counter.
Using '*' or '/' which would multiply or divide the counter incorrectly.
✗ Incorrect
The step counter should increase by 1 each time the timer finishes.
3fill in blank
hardFix the error in the code to reset the step counter after the last step.
PLC Programming
IF step_counter > max_steps THEN
step_counter := [1];
END_IF;Attempts:
3 left
💡 Hint
Common Mistakes
Setting the counter to max_steps which would cause an immediate reset loop.
Assigning step_counter to itself which does nothing.
✗ Incorrect
Resetting the step counter to 0 starts the sequence over.
4fill in blank
hardFill both blanks to check if the current step matches the drum hit and activate the output.
PLC Programming
IF step_counter = [1] THEN drum_output_[2] := TRUE; ELSE drum_output_[2] := FALSE; END_IF;
Attempts:
3 left
💡 Hint
Common Mistakes
Using different numbers for step and output causing no activation.
Using numbers outside the valid step range.
✗ Incorrect
When the step counter is 1, the first drum output should be activated.
5fill in blank
hardFill all three blanks to create a dictionary mapping steps to drum sounds and check if the current step triggers a sound.
PLC Programming
drum_map := { [1]: 'kick', [2]: 'snare', [3]: 'hihat' };
IF step_counter = [1] OR step_counter = [2] OR step_counter = [3] THEN
play_sound(drum_map[step_counter]);
END_IF;Attempts:
3 left
💡 Hint
Common Mistakes
Using mismatched keys causing the sound not to play.
Repeating the same step number for multiple sounds.
✗ Incorrect
Steps 1, 2, and 3 are mapped to kick, snare, and hihat sounds respectively.
