Section 21.3 Aliasing
Aliasing occurs when you donβt take data fast enough. The speed of taking data to avoid aliasing depends on the natural frequency of the system itself. To show this I changed the length of the pendulum which changed the natural frequency. I then proceeded to measure the angle as it oscillated at its natural frequency. I repeated this at sampling frequencies of 1, 10 and 100 Hz. The way I changed the sampling frequency was by changing the time.sleep value in the while True loop. The accelerometer code I used can be found on Github[33]. After I finished the experiment I had 3 data files that I plotted on top of each other. This what I got with the longest string. Itβs easy to see in the photo that sampling at 1 Hz was way too slow to capture the natural oscillations of the water bottle. However, 100 Hz and even 10 Hz was plenty fast to sample the oscillations. According to the recorded data there was above 19 cycles in 9 seconds which is about 2 Hz. In this case, as long as we sample at 4 Hz the signal will be captured properly which is why 10 Hz and 100 Hz is able to capture the signal correctly.

Once I sampled my waveform at 3 different sampling rates I elected to shrink the length of the pendulum to change the natural frequency and see if that affected any aliasing I saw. The results are shown in the figure below.

In this case you can see that there were 33 cycles in 10 seconds which is 3.3 Hz. The Nyquist criteria states that I need to sample at 6.6 Hz. The Nyquist criteria is very specific though in that if you sample at twice the frequency, you will just obtain the correct frequency. This does not mean that you will capture every data point properly. Hence in the chart above, the blue line at 100 Hz is perfect, the green line at 1 Hz is too slow (less than 6.6 Hz) and the orange line at 10 Hz captures the frequency correctly but between 5 and 8 seconds does not adequately capture the waveform. In my opinion, in order to sample the data effectively and not just obtain the frequency of the waveform, you need to sample at 4 times the natural frequency. So for the waveform of 3.3 Hz, the Montalvo frequency would be 13.2 Hz which is higher than the 10 Hz. This explains why the 10 hz sample is not perfect while the 100 hz sample rate is much better.
