C12 Embedded systems in MicroPython and C · Practice
State machines
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
Check
The crossing spends at least 1000 ms in green, 300 in yellow, 1500 in walk and 1000 in red. With a request always waiting, how long is one full cycle?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
How many bits does it take to store one of 5 states?
Check
A machine has 4 states and 2 kinds of event. How many entries does a complete transition table have?
Check
Green must last at least 1000 ms, and the walk button is pressed 400 ms after green began. When does green end?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A button cycles a machine through 3 states (0 → 1 → 2 → 0 ...), starting at 0. After 5 presses, which state is it in?
Check
A table-driven state machine has 6 states and 3 events, 2 byte(s) per entry.
(a)
How big is the table?
(b)
How many transition tests cover every entry?
Check
A crossing runs green 10 s, yellow 3 s, all-red 2 s, then walk 12 s, and back to green.
(a)
How long is a full cycle?
Write units the way you normally would: 1.5 s and 1500 ms are the same answer.
(b)
If a pedestrian presses just as green starts, how long until walk begins (green runs its full time)?
Check
Cycle time: green 2000, yellow 400, walk 2000, red 600 ms?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
Bits for 6 states?
Check
Table entries for 5 states and 3 events?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in C12