2 Theory of Operation

Analog-to-Digital Conversion

Before an analog voice signal can be stored digitally, it must be converted to a digital signal. This is done in multiple steps.

Figure 2-1. Example Analog Signal

First, the analog signal, depicted in the figure above, is converted to a time discrete signal by taking periodic samples, as shown in the figure below. The time interval between two samples is called the “sampling period” and its reciprocal the “sampling frequency”. According to the sampling theorem, the sampling frequency has to be at least double the maximum frequency component present in the sampled signal. Otherwise, the periodic continuation of the signal in the frequency domain would result in spectral overlap, called “aliasing”. An aliased signal can not be uniquely reconstructed from its samples.

Figure 2-2. Time Discrete Signal

A speech signal contains its major information below 3 kHz, therefore a low-pass filter can be used to band-limit the signal. For an ideal low-pass filter with a cut-off frequency of 3000 Hz, the sampling frequency must be 6000 Hz or more. Depending on the filter, the filter slope is more or less steep. Especially for a first order filter like the RC filter used in this application, it is necessary to choose a much higher sampling frequency. The upper limit is set by the features of the analog-to-digital converter.

Determining the digital values that represent the analog samples taken at this sampling frequency is called quantization. The analog signal is quantized by assigning an analog value to the nearest allowed digital value, as depicted in the figure below. The number of available digital values is called resolution and is always limited, for example to 256 values for an 8-bit digital sample. Therefore, the quantization of the analog signals always results in a loss of information. This quantization error is inversely proportional to the resolution of the digital signal. It is also inversely proportional to the dynamic range of the signal, the range between minimum and maximum values. The conversion range of the AVR ADC can be adjusted to the dynamic range of the signal by setting the voltage reference to a maximum value suitable for the application.

Figure 2-3. Quantized Signal

Alternatively, the microphone amplifier can be designed to cover the ADC dynamic range. Both methods reduce the quantization error.

The figure below shows the digital values that represent the analog signal. These are the values that are read as ADC conversion results, and can be stored in memory.

Figure 2-4. Digital Signal

Digital-to-Analog Conversion

The AVR Digital-to-Analog Converter (DAC) peripheral can be used to convert the digitally stored values to an analog output. By setting the voltage reference correctly to define maximum output value and use a timer to replicate sampling frequency as output frequency, the original signal is reconstructed. Each sample is held on the output for one output period (corresponding to the time in-between the samples being taken). For the example signal, this would look similar to the figure below.

Figure 2-5. Reconstructed Signal

The output filter smoothens the signal from the DAC. For example, the output signal would end up similar to the figure below. The signal is very similar to the original analog input signal, except for error from quantization, which is large in the depicted example as the 3-bit samples have only eight possible values.

Figure 2-6. Output Signal After Filtering