C1220 of 55
0 XP
  1. Hook
  2. Problems

C12 · Problem set 4

Problem set 4: sensors, the ADC's input, fixed point and filters

These problems use lessons 16 to 19: reading sensors, the ADC's input, fixed point, and filtering in firmware. The ADC is 12 bits, 0 to 4095 for 0 to 3.3 V, and samples onto 10 pF through 1 kΩ. The thermistor is 10 kΩ at 25 °C with B = 3950 K, from 3.3 V to the pin, with 10 kΩ from the pin to ground.

Check

The thermistor is at 10 °C.

(a)

What is its resistance?

Write units the way you normally would: 1.5 kΩ, 1500 Ω and 0.0015 MΩ are the same answer.

(b)

What voltage reaches the pin?

(c)

What code does the ADC give?

Check

Near 25 °C, compare the thermistor's codes at 25 − 0.5 and 25 + 0.5 °C.

(a)

How many codes per degree is the sensor worth there?

(b)

What temperature step is one code?

Check

A battery of 4.2 V is measured through 100 kΩ over 200 kΩ.

(a)

What code does the ADC read (if the pin stays under 3.3 V)?

(b)

How much charge does the divider draw in a year (8766 hours)?

Write units the way you normally would: 1.5 mAh, 1500 µAh and 0.0015 Ah are the same answer.

(c)

What acquisition time settles a full-scale change to half a code?

Check

A scanned ADC switches between channels; channel A has a 20 kΩ source, and the acquisition time is 1 µs.

(a)

After a full-scale jump from the previous channel, how far off is channel A's reading?

(b)

What acquisition time would bring it within half a code?

Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.

Check

The 3.3 V rail, which is also the ADC's reference, is 2% low. One sensor is the ratiometric thermistor divider; another is a 10 mV/°C sensor whose output doesn't depend on the rail, reading 25 °C.

(a)

How far off does the thermistor read?

(b)

How far off does the 10 mV/°C sensor read, and in which direction (positive for high)?

Check

2.75 and 0.125 are multiplied in Q16.16 on a 32-bit processor.

(a)

How many bits, including the sign, does the product of their stored integers need?

(b)

Does that product overflow a signed 32-bit integer (1 for yes)?

(c)

What value does the product represent after the shift?

Check

A filter coefficient 0.3 is stored with 8 fraction bits.

(a)

What integer stores it?

(b)

How far off is the stored value?

Check

Firmware converts ADC code 2483 to millivolts with mv = code * 3300 / 4095 in 32-bit integers.

(a)

What does it compute?

Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.

(b)

How much does truncation lose?

(c)

What does code / 4095 * 3300 give instead?

Check

Readings arrive at 1000 Hz and carry hum at 50 Hz.

(a)

What moving-average length nulls the hum?

(b)

What is the largest running sum of 12-bit readings it can hold?

(c)

What delay does it add?

Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.

Check

A thermistor reading has 3 codes of rms noise, and near this temperature one degree is worth 23 codes. An exponential smoother uses α=2−3.

(a)

How much noise survives the smoother?

(b)

What is that in degrees?

Check

A 12-bit ADC sampling at 1000 Hz is oversampled and averaged, with enough noise to dither it, to gain 2 bits.

(a)

How many samples must each output average?

(b)

What output rate is left?

Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.

Check

A median-of-3 filter runs on readings that contain isolated spikes, never more than 1 in a row.

(a)

Does it remove every spike (1 for yes)?

(b)

What delay does it add to a clean step?

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.