41099 Chap.6 Analog input, ADC resolution and pulse width modulation
Analog input, ADC resolution and pulse width modulation
What this chapter covers
- 01
Two voltage levels on a digital pin against a continuous range on an analog pin
- 02
Resolution: 1024 codes, a range of 0 to 1023 and a step of 4.9 millivolts
- 03
Converting a code to a voltage and a voltage to a code
- 04
Reading a resistive sensor through a divider, and choosing the fixed partner
- 05
Producing an average rather than a voltage, and the loads that can average it
Turn a changing resistance into a code, and read the useful span
- 2Identify which element of the divider the pin voltage appears across.
- 3Apply the divider ratio for the dim case and convert to a code.
- 3Repeat for the bright case and comment on the resulting span.
Key terms
- Analog signal
- An electrical signal whose voltage can take any value in a continuous range.
- Resolution
- The size of the smallest input change a converter can report as a different code.
- Quantisation
- The mapping of a continuous input onto a finite set of integer codes.
- Light dependent resistor
- A resistor whose resistance falls as the light falling on it increases.
- Duty cycle
- The fraction of each switching period for which the output is at its high level.
- Average voltage
- The mean level a slow load experiences from a switched output, equal to the duty fraction times the supply.
- Fixed partner
- The constant resistor placed with a sensor to turn its changing resistance into a changing voltage.
Analog input, ADC resolution and pulse width modulation FAQ
Does a higher resolution mean a more accurate reading?
Not by itself. Resolution is the smallest change the converter can report, while accuracy is whether the code corresponds to the voltage you believe it does. That depends on how steady the reference supply is and on noise along the way. In practice the last code or two wander even with a still input, which is why a threshold set exactly at a measured boundary chatters.
Why does a resistive sensor need a fixed resistor beside it?
Because the input measures voltage and the sensor changes resistance. Placing the two in series across the supply turns the changing resistance into a changing voltage at their junction, which is something the converter can read. The course materials give the arrangement directly: the sensor to the supply, the junction to the analog pin and that same pin to ground through a fixed resistor.
How is the fixed partner resistance chosen?
Place it near the middle of the sensor's working range, so that the steepest part of the response sits where your readings actually live. Two groups running identical code can obtain different thresholds purely because they chose different partners, and the group that can explain the choice is the one that can also explain the difference.
Does the board really produce an intermediate voltage when fading a light?
No. Its only output levels are the supply and ground. What varies is the fraction of each cycle spent at the high level, and a slow load such as an eye or a motor winding averages that into an apparent intermediate value. Measured with a fast instrument the pin is still snapping between the two levels.
Why does a multimeter read about half the supply on a half duty output?
Because it reports a time average rather than an instantaneous level, and the average of a half duty square wave is half the supply. That is the same reading a genuine intermediate source would give, so the measurement cannot distinguish the two. An oscilloscope settles it immediately by showing the square waveform.
How do you convert a sensor reading into an output level?
Take the reading as a fraction of its own full scale of 1023, then multiply that fraction by the output full scale of 255. Scaling the raw code directly into the output value is the usual slip, because the two ranges are different and the result saturates immediately.
Assessment move
Do both conversions explicitly rather than by feel: code times step size gives volts, and volts divided by step size gives the code. For every sensor, measure the codes at both ends of its real working range before choosing a threshold. When something looks like an intermediate voltage, ask what is doing the averaging.
Working through Analog input, ADC resolution and pulse width modulation in 41099? Sia is AskSia’s AI Engineering tutor — ask any 41099 Analog input, ADC resolution and pulse width modulation question and get a clear, step-by-step explanation grounded in how 41099 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.