Lab 5
Lab 5
Lab5 To do sheet
2.
(1).
500Hz 200Hz
100 Hz 80Hz
(2).
500Hz 200Hz
100Hz(on the edge of aliazing) 80Hz(aliazing)
(3).
Aliasing happens when a signal is sampled at a rate that is too low to accurately capture its details.
According to the Nyquist theorem, the sampling rate should be at least twice the highest frequency
in the signal. In this experiment, a 100 Hz sine wave is used, so the sampling rate should be at least
200 Hz to avoid aliasing.
At a sampling rate of 500 Hz, the signal is captured accurately, with no aliasing. The sampled data
matches the original 100 Hz sine wave well. When the sampling rate is reduced to 200 Hz, it still
works fine because it is just at the Nyquist limit. However, in practice, small errors in timing could
slightly affect the accuracy, but the signal is still mostly correct.
When the sampling rate drops to 100 Hz, aliasing becomes a problem. The sampling rate is now
equal to the signal frequency, which means the signal will be distorted and may appear to oscillate
at a lower frequency than it actually is. At 80 Hz, the aliasing is even worse, causing the 100 Hz
signal to appear as if it’s oscillating much slower, which leads to a big error in the representation.
(4)
3.
(1)
( set the freq to be 500 Hz)
10bit 8bit
5bit 3bit
(2)
10bit 8bit
5bit 3bit
In addition to the requirements in Lab1_ToDoSheet_Fall2024.pdf, better include the
following items in your report.
(1) What are the differences between polling based ADC sampling and interrupt based ADC
sampling?
Polling-based ADC sampling involves the microcontroller constantly checking the ADC for new
data in a loop. This can be inefficient because the microcontroller is fully occupied with checking
the ADC status and may miss samples or have timing problems, especially if it's handling other
tasks at the same time.
In contrast, interrupt-based ADC sampling allows the microcontroller to be alerted only when a new
sample is ready. This frees up the CPU to handle other tasks and ensures more efficient and
consistent sampling.
The key difference between the two methods is that interrupt-based sampling is more efficient since
it only responds when necessary. It also provides better accuracy in timing, while polling-based
sampling can lead to missed samples or timing errors due to constant checking.
(2). Why does the sampled sine signal (fs = 500 Hz or 200 Hz) look like an amplitude-
modulated (AM) sine wave (i.e., 100 Hz sine carrier with amplitude modulated envelope)
when the polling based ADC sampling is used? not like an expected sine wave?
If you try to interpolate the sampled sine signal, you will see the expected sine wave. Why?
(You can try using simulated sine signal)
Polling-based ADC sampling can result in irregular sampling because of CPU overhead or delays,
leading to timing jitter. This irregularity causes the amplitude of the sampled data to vary, making
the sine wave look modulated, similar to an AM signal. However, using interpolation helps to
correct this issue. By resampling the data at regular intervals, interpolation fills in the missing or
unevenly spaced samples, restoring the original sine wave shape and correcting the distortions
caused by polling-based sampling.
(3). In the experiment, you're using the highest baud rate (i.e., 115200 bps) of the serial port.
What would happen if you set a lower baud rate, e.g., 9600 bps or 19200 bps?
The fft
9600bps 19200bps
waveforms:
The baud rate controls the data transmission speed between the ADC and the serial port. A lower
baud rate will result in slower data transmission, leading to possible data loss or delays in capturing
samples.
At 115200 bps, the data is transmitted fast enough for real-time processing, but at lower baud rates
(9600 or 19200 bps), the transmission may not keep up with the ADC sampling, causing the loss of
data and inaccurate waveforms.
(4). Please remember to elaborate the spectral difference between the 10-bit and 3-bit sampled
sine wave, and what causes the difference.
In 10-bit sampling, the higher resolution allows the sine wave to be represented more accurately
with less quantization noise, as the signal is divided into 1024 discrete levels. In contrast, 3-bit
sampling has much lower resolution, using only 8 levels, which introduces higher quantization
noise. This noise shows up as extra frequency components, or spectral artifacts, in the signal’s FFT.
The difference arises because with fewer levels, the signal is more coarsely quantized, leading to
more distortion and greater noise in the frequency spectrum.
The experiment reinforced the understanding that the sampling rate must exceed twice the highest
signal frequency to avoid aliasing, in accordance with the Nyquist criterion. It also highlighted the
effects of quantization, showing how bit resolution significantly impacts signal quality; higher
resolution reduces quantization noise and improves spectral accuracy. Additionally, insights were
gained into the practical advantages of interrupt-based sampling over polling for real-time
applications. Lastly, the importance of setting an appropriate baud rate became clear, as it is
essential for ensuring smooth data transmission without loss.