Exercise: Analog Read Serial

Objective

Measure an physical property as a number.

The world is an analog place; physical phenomena have continuity and exist over time. To represent a physical property computationally, the physical process information must be transduced into electrical form and then converted from an analog voltage into a digital number by an analog-to-digital converter, or ADC.

This is a wide and deep topic ranging from signal and information theory to robotics and epistemology, and the entire semester will just begin to explore this idea. But to start, this exercise will represent a single light level as a stream of integers.

Steps and observations

  1. Load and run the AnalogReadSerial sketch.
  2. Observe the numbers printed in the serial monitor as the light level varies.
  3. Try slowing the sampling rate by increasing the delay.
  4. Determine the highest and lowest values observed given the available light levels.
  5. Observe the noise in the numbers for different constant light inputs.
  6. The numbers produced by the ADC are a voltage measurement expressed in the somewhat arbitrary units of the converter (e.g. 4.9 mV/unit). Formulate a strategy for calibrating the measurement so that the number has useful semantic meaning. What are useful units for expressing the light intensity? Hint: the arithmetic for the calibration mapping can be as simple as multiplying by a constant gain and adding an offset (e.g. a linear function); the key point is choosing a units system which is understandable and deciding how to take repeatable reference measurements.

Comments

The Arduino analog inputs are converted at 10 bits of precision, that is, voltages between 0 and 5V are measured as integer numbers between 0 and 1023, with a nominal resolution of about 4.9 mV per step. However, analog noise in the conversion also limits the precision, so the minimum detectable signal change may be somewhat larger.

The frequency resolution is determined by the sampling rate and the Nyquist-Shannon sampling theorem, which states that a periodic sampling rate must be at least twice as fast as the highest frequency in the input. The Arduino ADC converter runs at a maximum of about 10 kHz, so in principle it can measure signals which vary at up to a 5 kHz rate.

Other Files

  1. analog-read-serial.fzz