Here's an example MATLAB code for simulating a second-order delta-sigma modulator:
main.m1274 chars56 lines
This code generates a sinusoidal input signal, applies a second-order delta-sigma modulator, and then decimates the output signal by a factor of two. The power spectrum of the input and output signals are plotted for comparison.
Note that the loop filter gain K
and cutoff frequency f1
should be chosen carefully to avoid instability and achieve the desired noise shaping performance. Additionally, this example code uses a symmetric (mid-tread) quantizer for simplicity, but other quantization schemes can be used depending on the application.
gistlibby LogSnag