Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C Programming for microcontrollers (Joe Pardue, 2005).pdf
Скачиваний:
260
Добавлен:
12.08.2013
Размер:
4.55 Mб
Скачать

Chapter 9 – Digital Meets Analog – ADC and DAC

Timer/Counter 1 Capture Event

Conversion Timing

The successive approximations are clocked between 50kHz and 200kHz to get the maximum resolution. You can use higher sampling rate frequencies, but you get lower resolution. The sampling rate is determined by the input clock and by a prescaler value set in the ADPS bits of the ADCSRA register. The first conversion takes 25 clock cycles to initialize the hardware. Normal conversions take 13 clock cycles and auto triggered conversions take 13.5.

Changing Channels

There are some complexities involved in changing channels and voltage references that lead to the recommendation that you always wait till a conversion is complete before making a change. If this is inconvenient, read the data book and figure it out yourself.

Digital Noise Reduction

The CPU and I/O peripherals can generate a lot of electrical noise that affect the accuracy of the ADC. We can put the system to sleep to shut it up and then take our ADC readings in the quietened environment. Details in the data book.

Conditioning the Analog Input Signal

The accuracy of the conversion will depend on the quality of the input signal. A few recommendations:

Filter out signal components higher than the Nyquist sampling frequency (double the frequency of interest) with a low pass filter.

Sampling time depends on the time needed to charge the sample and hold circuit so always use a source with an output impedance of 10 kOhm or less.

Use only slowly varying signals.

Keep analog signal paths as short as possible.

Use the ADC noise canceller function.

214

Chapter 9 – Digital Meets Analog – ADC and DAC

If any of the ADC port pins are used for digital output, don’t switch them while a conversion is going on.

Accuracy

The data book has some cursory discussion of the extremely dense topic of ADC accuracy. Just be aware that in the accompanying project we don’t use any of these recommendations, so take the accuracy of our measurements with a grain of salt.

215