1、 fS = 2 fH Any sampling frequency selected above fS is considered to be over sampling, and when combined with averaging techniques, improves the ENOB. This is possible because averaging the oversampled results also averages the quantization noise, thus improving the Signal-to-Noise Ratio (SNR), whic
2、h has a direct effect on the ENOB. For each bit of accuracy improvement, the signal must be over sampled by a factor of four, meaning that the relationship between the over sampling frequency fOS and sampling frequency fS is as shown in Equation 2. Equation 2. Oversampling Frequency fOS = 4x * fS wh
3、ere x is the desired improvement on the ENOB (for example, for two bits of improvement, x = 2). Figure 1 shows how oversampling improves the accuracy of the conversion result. In this diagram, the input signal is oversampled by 4 (sample groups are shown in green and purple) and averaged. The sample
4、 points shown illustrate the difference between the raw, noisy signal and the average; the noise in this example affecting 3 bits of accuracy on an individual sample. Note that the averaged values (orange dots) are much closer to the ideal value than most of the single samples. Averaging Averaging a
5、cts as a low-pass filter on the input signal, with the pass band of the filter narrowing as the sample size increases. When averaging conversion results, there are two approaches that can be taken: normal average or rolling average.Normal Average Taking n samples, adding them, and dividing the resul
6、t by n is referred to as a normal average, and is shown in Figure 1. When using normal averaging in an oversampling scenario, after the technique is applied, the sample data used in the calculation is discarded. This process is repeated every time the application needs a new conversion result. Figur
7、e 1. Averaged Conversion Results In an application, the normal averaging approach is ideally used in cases where the sampling frequency is low compared to the sampling rate of the ADC. Important: When oversampling by n in a normal averaging scenario, the effective ADC sample rate is reduced by that
8、same factor. For example, oversampling an input signal by 4 cuts the maximum effective ADC sample rate by 4, meaning that a 250K-samples/sADC effectively becomes a 62.5K-samples/s ADC. Figure 2 shows a situation where normal averaging is used to over sample an input source by 4. For this example, th
9、e application requires that a new conversion value be ready (averaging complete) at each step of t (t0, t1, t2, and so on). When using averaging techniques, there is a slight delay associated with the calculated conversion result since it corresponds to the average of the last n samples. The delay c
10、an be calculated using the formula shown in Equation 3. Equation 3. Averaged Sample Delay tdelay = (tSn tS0) / 2 + tprocess where tS0 is the time at which the first sample of the average occurs, and tSn is where the last sample occurs. The time required by the interrupt handler to process the sample
11、 data and calculate the average tprocess to supply to the application is also factored into the equation. In Figure 2, the delayed conversion result is highlighted in orange.Rolling Average A rolling average uses a sample buffer of the n most recent samples in the averaging calculation, allowing the
12、 ADC to sample at its maximum rate (the ADC sample rate is not reduced by n as in normal averaging), making it ideally suited for applications requiring oversampling and higher sample rates. The sample buffer can be prefilled with valid sample data (by taking n1 samples prior to the first “real” dat
13、a point), or can be left in an unknown state, depending on the application. The disadvantage of not prefilling the buffer is that the first n1 samples contain invalid data and adversely affect the rolling average calculation. If acceptable by the application, buffer padding can be eliminated if the
14、software can account for the possibility of the first n1 samples being skewed. Figure 3 shows an example of oversampling with a rolling average. The diagram shows a case where the input signal is over sampled by 4, meaning that the sample buffer uses the 4 most recent samples to calculate the averag
15、e. In this example, the application requires a new sample at each step of t. Before the first over sampled result is calculated at t0, the sample buffer collects three samples so that the first data supplied to the application is valid.Figure 2. Normal Averaging When using a rolling average, the sam
16、e sample delay calculated by Equation 3 applies. In Figure 3, the delayed values for t0, t1 and t2 (shown as d0, d1 and d2, respectively) are highlighted in orange. Using a rolling average adds additional processing overhead due to the sample buffer manipulation that must be performed during each in
17、terrupt.Implementation Luminary Micros sample sequencer architecture in the ADC makes oversampling simple by allowing for up to 17 unique samples (from any of the analog channels) to be collected using a single trigger. This allows for flexibility in software by providing the means for an applicatio
18、n to over sample a number of channels at any given time. This section shows various implementations of over sampling using the Stellaris microcontrollers. There are numerous methods that work using combinations of sample sequencer configurations, ADC triggers and interrupts, however, the examples sh
19、own here focus on techniques that are most likely to be used. All the example code uses the Stellaris Family Driver Library ADC functions. The source code for the Driver Library and the software examples shown in this application note can be found on the Luminary Micro website at .Figure 3. Rolling
20、AverageOver sampling Up to 8 Times Using the Driver Library Functions The Stellaris Driver Library has built-in functions that allow oversampling up to 8 times. For most applications, this level of over sampling is sufficient since the improvement on the ENOB is approximately 1.4 bits. Using the Dri
21、ver Library oversampling functions is the easiest way to oversample the input signal. The main difference between configuring a “typical” ADC conversion and an oversampled conversion is the function calls. The oversampling functions have an ADC Software Over sample prefix, and are easily distinguish
22、ed from the standard ADC functions. Once the parameters for the ADC conversion process are determined (sample frequency, trigger source, channel, and so on), writing the code is straight-forward. For example, the code to set up a 10-ms periodic conversion (triggered by a timer) that is over sampled
23、by 8 consists of the code segments shown in Example 1.Example 1. 8x Oversampling with the Driver Library FunctionsCode Segment 1.a. ADC Configuration Driver Library Functions/ Initialize the ADC to oversample channel 1 by 8x using sequencer 0./ Sequencer will be triggered by one of the general-purpo
24、se timers.ADCSequenceConfigure(ADC_BASE, 0, ADC_TRIGGER_TIMER, 0);ADCSoftwareOversampleConfigure(ADC_BASE, 0, 8);ADCSoftwareOversampleStepConfigure(ADC_BASE, 0, 0, (ADC_CTL_CH1 | ADC_CTL_IE | ADC_CTL_END);/ Initialize Timer 0 to trigger an ADC conversion once every 10 millisecondsTimerConfigure(TIME
25、R0_BASE, TIMER_CFG_32_BIT_PER);TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet() / 100);TimerControlTrigger(TIMER0_BASE, TIMER_A, true); The ADC configuration shown in Code Segment 1.a dictates that an interrupt occur when sampling completes, meaning that an interrupt handler must be implemented (
26、see Code Segment 1.b). Since the Driver Library oversampling functions automatically average the sampled data, the interrupt handler function is relatively basic. Keep in mind that having the average calculated during each interrupt adds computational overhead to the interrupt handler.Code Segment 1
27、.b. ADC Interrupt HandlervoidADCIntHandler(void) long lStatus; / / Clear the ADC interrupt ADCIntClear(ADC_BASE, 0); / Get averaged data from the ADC lStatus = ADCSoftwareOversampleDataGet(ADC_BASE, 0, &g_ulAverage); / Placeholder for ADC processing code With the configuration steps and interrupt ha
28、ndler in place, the conversion process is initiated. Before the timer is turned on (begins counting), the ADC sequencer and interrupt must be enabled (see Code Segment 1.c).Code Segment 1.c. Enabling the ADC and Interrupts/ Enable ADC sequencer 0 and its interrupt (in both the ADC and NVIC)ADCSequenceEnable(ADC_BASE, 0);ADCIntEnable(ADC_BASE, 0);IntEnable(INT_ADC0);/ Enable the timer and start conversion processTimerEnable(TIMER0_BASE, TIMER_A);Oversampling More Than 8 Times Using Multiple Sequencers or a Timer The Driver Library oversampling functions are limited to over sampling by 8 times
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1