C12 Embedded systems in MicroPython and C · Practice
Reading sensors with the ADC
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
What code does the 12-bit ADC report for 1 V?
Check
The ADC reads 1000. What voltage is that?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
Check
A thermistor from 3.3 V to the pin, with 10 kΩ to ground, gives 1.2 V. What's the thermistor's resistance?
Write units the way you normally would: 1.5 kΩ, 1500 Ω and 0.0015 MΩ are the same answer.
Check
A thermistor with R₀ = 10 kΩ at 25 °C and B = 3950 K measures 6.5 kΩ. What's its temperature?
Check
Single readings scatter by 4 codes (standard deviation). What's the scatter of an average of 16?
Check
Each conversion takes 10 µs. If a program averages 16 conversions per reading and does nothing else, how many readings a second can it make?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
A potentiometer on ADC0 sits at some voltage. Print its raw code, then its voltage in millivolts, rounded to a whole number.
MicroPython on the course's board: machine (Pin, PWM, ADC, DAC, UART, I2C, SPI, Timer, WDT) and time. Each call into the hardware takes about 40 µs. Tab indents; press Esc and then Tab to move on.
Check
The 12-bit ADC (0 to 4095 for 0 to 3.3 V) measures 2.2 V.
(a)
What code does it give (nearest)?
(b)
How many millivolts is one code?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
A thermistor from 3.3 V to the pin, with 10 kΩ from the pin to ground, gives code 2048.
(a)
What is the pin voltage?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
(b)
What is the thermistor's resistance?
Check
Code for 0.5 V?
Check
Thermistor resistance at 1.2 V with 10 kΩ below?
Write units the way you normally would: 1.5 kΩ, 1500 Ω and 0.0015 MΩ are the same answer.
Check
Temperature at 4.7 kΩ (10 kΩ, B 3950)?
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