C12 · Problem set 12
Problem set 12: embedded systems across the course
Multi-step problems drawing on the whole course, with lessons 49 to 53 in mind: comparing MicroPython and C, testing, the data logger and the thermostat. The board runs at 10 MHz, one instruction per cycle; MicroPython hardware calls take about 40 µs; the CPU draws 2 mA running, 0.5 mA asleep, 0.002 mA in deep sleep.
Check
A job makes 200 hardware accesses.
(a)
How long in MicroPython (40 µs each)?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
And in C at 6 cycles each?
Check
A chip has 512 KB of flash and 32 KB of RAM; MicroPython needs about 256 KB of flash and 16 KB of RAM.
(a)
How much flash is left for the application?
(b)
And how much RAM, beyond the minimum?
Check
A function has 6 independent decisions; a state machine has 4 states and 5 events.
(a)
How many paths through the function?
(b)
How many transition tests for the machine?
Check
A logger samples at 10 Hz with a 400-cycle ISR and keeps 60 s of 2-byte readings.
(a)
What share of the processor does sampling use?
(b)
How much RAM does its buffer need?
Check
10 readings in tenths of a degree sum to 2337.
(a)
What's the rounded average, in tenths?
(b)
What digit is printed after the decimal point?
Check
A room (4000 J/°C, R = 0.02 °C/W, outside 0 °C) is at 21 °C with a 1500 W heater.
(a)
How fast does it warm with the heater on?
(b)
How fast does it cool with the heater off?
Check
A thermostat's band is ±0.5 °C; the room warms at 0.2 and cools at 0.3 °C/s.
(a)
How long is a cycle?
Write units the way you normally would: 1.5 s and 1500 ms are the same answer.
(b)
About how many times does the heater switch on in 600 s?
Check
A device is awake 0.1% of the time at 2 mA and asleep at 0.05 mA, from 2000 mAh.
(a)
What's its average current?
Write units the way you normally would: 1.5 mA, 1500 µA and 0.0015 A are the same answer.
(b)
How many days does the battery last?
Check
A report of 25 characters goes out at 9600 baud every 5 s.
(a)
How long does each report take?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
What fraction of the time is the UART sending?
Check
A sampling timer has PRESCALE = 9999 and TOP = 99; each sample's I²C read is 4 bytes at 100 kHz plus two clocks.
(a)
How often does it sample?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
How long is each read on the bus?
Check
A main loop's longest pass is 10 ms; its watchdog gets a 3× margin. A bug hangs it 800 ms after each start.
(a)
What WDT_LOAD?
(b)
How many resets in 10 s?
Check
A task runs 20 times a second: 0.5 ms in MicroPython or 0.05 ms in C, at 2 mA awake.
(a)
What does the MicroPython version add to the average current?
Write units the way you normally would: 1.5 mA, 1500 µA and 0.0015 A are the same answer.
(b)
How much does the C version save?
Check
A heater-controlled plant (gain 1, τ = 20 s) is sampled every 1 s under proportional gain 8.
(a)
Where is the closed-loop pole?
(b)
What steady-state error does it leave?
Check
A logger sleeps at 0.003 mA and wakes every 60 s for 100 ms at 2 mA, from 220 mAh.
(a)
What is the average current?
Write units the way you normally would: 1.5 mA, 1500 µA and 0.0015 A are the same answer.
(b)
How many years does it last?
Check
A PI controller's proportional gain 0.6 is stored in Q8; the error is 333 codes.
(a)
What does the proportional term compute?
(b)
How far is that from the exact ?
Have paper and a calculator ready. Work each problem out by hand, then enter the answer. Your first try on each one counts toward your score.
Practice
Keep practicing
15 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.