Implementation of Sampling Techniques in Python
Sampling is defined as, “The process of measuring the instantaneous values of continuous-time signal in a discrete form.”
Sample is a piece of data taken from the whole data which is continuous in the time domain.
Ex. When a source generates an analog signal and if that has to be digitized, having 1s and 0s i.e., High or Low, the signal has to be discretized in time. This discretization of analog signal is called as Sampling.
Types of Sampling Techniques
1. Impulse Sampling (Ideal Sampling)
- Ideal Sampling is also known as Instantaneous sampling or Impulse Sampling. Train of impulse is used as a carrier signal for ideal sampling.
- In this sampling technique the sampling function is a train of impulses and the principle used is known as multiplication principle.
- Spectrum of Ideal Sampled Signal is given by: G(f) = fs .[ Σ X(f-n fs)]
- A theoretical ideal sampler produces samples equivalent to the instantaneous value of the continuous signal at the desired points.
Firstly, we have to import these files,
Then we are assigning the values for amplitude and frequency and generating a train of impulses,
Then, we will plot the impulse signal,
Plotting the sine wave,
Plotting the wave that has been impulse sampled,
2. Natural Sampling
- Natural Sampling is a practical method of sampling in which pulses have finite width equal to τ. Sampling is done in accordance with the carrier signal which is digital in nature.
- In natural sampling, an analog signal is gated in such a way that the resulting signal consists of pulses with time-varying amplitudes that follow the contours of the original waveform.
- With the help of a functional diagram of a Natural sampler, a sampled signal g(t) is obtained by multiplication of sampling function c(t) and the input signal x(t).
- In this example, the original signal is a sinusoid with a period of Tx, and the sampled signal has a sampling interval of T, and a sample width of τ. Natural sampling is mathematically equivalent to multiplying the original signal with a train of unit-amplitude rectangular sampling pulses.
- Therefore, the spectrum of a naturally sampled signal can be determined by convolving the original signal’s spectrum with the spectrum of the train of sampling pulses.
Firstly we will be creating the square wave,
Plotting the naturally sampled wave,
3. Flat-top Sampling
- In flat top sampling, the top of the samples remains constant and equal to the instantaneous value of the modulating signal at the start of the sampling. Thus the amplitude of the pulse after sampling is kept constant and the top of the sampled pulse do not follow the contour of the modulating signal unlike Natural sampling.
- The switch S1 closes at each sampling instant to sample the modulating signal.
- The capacitor C holds the sampled voltage for period τ at the end of which switch S2 is closed in order to discharge the capacitor.
- The starting edge of the pulse corresponds to the instantaneous value of the modulating signal x(t).
There is no direct function to create a flat top wave so we have developed our own logic,
Plotting the flat top,
Final output
Finally we are combining all the techniques and integrating them in a single code,
NYQUIST RATE
Nyquist rate is the rate at which sampling of a signal is done so that overlapping of frequency does not take place.
When the sampling rate become exactly equal to 2fm samples per second, then the specific rate is known as Nyquist rate. It is also know aas the minimum sampling rate and given by: fs =2fm
Sampling theorem states that a band limited signal having no frequency components higher than fm hertz can be sampled if its sampling frequency is equal to or greater than Nyquist rate.
Effect of Under sampling: ALIASING
It is the effect in which overlapping of a frequency components takes place at the frequency higher than Nyquist rate.
Signal loss may occur due to aliasing effect. We can say that aliasing is the phenomena in which a high frequency component in the frequency spectrum of a signal takes identity of a lower frequency component in the same spectrum of the sampled signal.
The Effect of Aliasing can be reduced:
1) Pre-alias filter must be used to limit band of frequency of the required signal fm Hz.
2) Sampling frequency fs must be selected such that fs > 2fm.
SYET-A-B1-GROUP 6
Atharva Mali 28
Laukik Avhad 29
Avinash Gedam 30
Manas Baviskar 34