C12 Embedded systems in MicroPython and C · Practice
Capturing time and counting motion: input capture and encoders
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
A capture timer at 1 MHz records edges 25000 counts apart.
(a)
What is the signal's frequency?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
(b)
What is the resolution for ±1 count?
Check
A 500-line encoder, decoded 4×, turns at 600 rpm; each edge costs an 80-cycle interrupt at 10 MHz.
(a)
How many edges arrive per second?
(b)
What share of the processor does decoding take?
Check
A 256-line encoder in 4× mode gives 150 counts in a 20 ms window.
(a)
What is the speed?
(b)
What fraction of the reading is one count?
Check
An ultrasonic echo returns 5.83 ms after the ping, in air at 0 °C, where sound travels at m/s.
(a)
How far away is the target?
Write units the way you normally would: 1.5 cm, 15 mm and 0.015 m are the same answer.
(b)
What distance does one 100 ns count represent?
Check
A frequency is measured either by counting edges for 0.1 s or by timing one period with a 10 MHz clock.
(a)
Above what frequency is counting better?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
(b)
What does counting resolve?
Check
A 16-bit capture timer runs at Hz with PRESCALE = 9.
(a)
What is the longest period it can time without counting overflows?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
What is its resolution?
Check
Frequency from captures 1000 counts apart at 1 MHz?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
Edges per second for a 200-line encoder at 1200 rpm, 4× decoding?
Check
Distance for an echo after 2 ms at 343 m/s?
Write units the way you normally would: 1.5 cm, 15 mm and 0.015 m are the same answer.
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