Highlevel design and simulation of deltasigma modulators
Editor's Note: This file was selected as MATLAB Central Pick of the Week
The DeltaSigma Toolbox includes nearly 100 functions which support NTF synthesis, modulator simulation (from an NTF or a structure), realization, dynamic range scaling, SNR estimation and more. The toolbox is welldocumented via the accompanying DSToolbox.pdf manual.
For further information regarding the Toolbox and DeltaSigma modulators in general consider purchasing "Understanding DeltaSigma Data Converters" by Schreier and Temes (ISBN 0471465852).
2016.1  Added demoLPandBP.m. Updated dsexample1.m and dsexample2.m 

2016.0  Actually uploaded the delsig.zip file this time. 

2016.0  Added designPBF.m (for designing polynomialbased filters using Hunter's method). Added dsexample*.m. Replaced simulateESL with simulateMS for simulating mismatchshaping. Expanded dsdemo5.m (demonstration of mismatch shaping). 

1.3  Incorporated Jeffrey Gealow's improvements which remove restrictions on the tdac argument in realizeNTF_ct and mapCtoD. Values such as [1 3] or [2 3] are now OK. 

1.2  Added functions for realizing an NTF with a continuoustime loop filter and for handling quadrature modulators. 

Updated clans.m so that it works with old and new versions of the Optimization Toolbox. Corrected the documentation for designHBF.m 

Expanded functionality and updated for Matlab 6. 

modifying description 

Mathworks changed the internal representation of the zpk object in

Aminreza Ahari Kaleibar (view profile)
Hello, I am trying to use Clans function from your toolbox. While I have optimization toolbox installed, I am getting an error message as soon as I run Clans. The error message says Clans needs optimization toolbox. Please advise me how I can resolve this issue.
David (view profile)
rajput jyoti prakash (view profile)
Dear sir/ madam,
I am trying to implement my base paper on A Genetic Algorithm for the Estimation of Nonidealities in ContinuousTime Sigma–Delta Modulators or Hybrid of unscented Kalman filter and genetic algorithm for state and parameter estimation in sigma–delta modulators.
please help me regarding this how can i apply Genetic Algorithm on SDM.
Thanks and regards
jyoti prakash (jyotiet@gmail.com)
SUCHISMITA KONER (view profile)
Is there any manual/video to learn how this toolbox work??
It will be really helpful if you give me the link.
hamid r (view profile)
is there any video to show how this toolbox work??
i couldn't find any.
i'll be really appreciated if sb give me a link.
LI Daxiang (view profile)
Electa Alice (view profile)
how to convert the digital to analog after doing ADC using simulatedsm
Jens Tingleff (view profile)
The following substitution will compile (with what I presume is the correct semantics  a double precision random value with a range of [0, 1] uniformly distributed )
Instead of drand48() use
(double)rand()/(double)RAND_MAX
Soumyajit Mandal (view profile)
Can't compile simulateESL.c or simulateMS.c in R2015b with MinGW64 compiler:
Error using mex
C:\Users\xxx\AppData\Local\Temp\mex_712607430100517_10136\simulateMS.obj:simulateMS.c:(.text+0xf5e):undefined reference to `drand48'
collect2.exe: error: ld returned 1 exit status
Lars (view profile)
simulateESL.c cannot be compiled in 2015b:
Error using mex
C:\Users\xxxxxx\AppData\Local\Temp\mex_450160929617192_10528\simulateESL.obj:simulateESL.c:(.text+0xec7): undefined reference
to `drand48'
collect2.exe: error: ld returned 1 exit status
Chiang Mingchou (view profile)
nasir hurrah (view profile)
I have downloaded it but don't know how to use it. Please if anyone can describe the procedure.
Liang (view profile)
I am just wonder if we could download the old version of this toolbox? The latest one changed something that cause more problem than the previous one. For example, if I use CIFB model, all the zeros are changed to new positions with real part value composed to changed to 1. And it is not I hope to see these things that change data automatically.
Marko Neitola (view profile)
Extremely helpful and educational toolbox.
Not sure if the author reads this, but here is a tiny improvement for clans.m:
For better convergence, transform the errors in minimization functions (dsclansObj6a,dsclansObj6b) into quadratic errors.
Howto:
1. Open clans6.m
2. in subfunction dsclansObj6a, after "f = abs(evalTF(H,exp(1i*pi/OSR)));" type "f=f*f".
3. in subfunction dsclansObj6a, after "g = sum(abs(impulse(H,100))) 1  Q;" type "g=g*g".
This way the target value for Q will be reached quite accurately at low OSR.
shilpi (view profile)
i have downloaded the sigma delta toolbox but unable to run simulateDSM.c file. it gives the error mex at 222, i have also update SDK and dotnet but still not working.please help me
Byoung Kim (view profile)
JF (view profile)
Kong (view profile)
Abhishek Bhat (view profile)
Very useful toolbox for Delta sigma folks like us...
achuth (view profile)
It is very good
Pankaj Jha (view profile)
I am trying to implement a Band Pass Sigma Delta modulator SDM using delsig toolbox.
These are the MATLAB commands that I am running to get the modulator coefficients:
NTF = synthesizeNTF(4,320/(2*10),0,1.5*1,0.25);
STF = zpk([1 , 1 , 1 , 1],[0.2302  0.7241i , 0.2302 + 0.7241i , 0.2302  0.7241i , 0.2302 + 0.7241i],0.0976,[ ]);
[a,g,b,c] = realizeNTF(NTF,'CRFF',STF);
The MATLAB outputs:
a =
0.5558 0.2435 0.0436
g =
8.5267e004
b =
0.1316 1.0603 4.4905 0.3558
c =
1 1 1
This is wrong because there should be 4 coefficients for 'a' vector, whereas what we get only 3 coefficients for vector 'a' . Similarly is the case for vectors'b', 'c' and 'g'.
What could be possibly wrong?
Dedong (view profile)
liu (view profile)
ding (view profile)
Dear Richard Schreier,
I am a new man in deltasigma, so I follow your book" Understanding DeltaSigma Data Converters by Schreier and Temes (ISBN 0471465852)" step by step, and I meet a problem "figure 8.4" and "figure 8.5" in page "265" and "266".
In your book, the SNR without window is "SNR = 76.4 dB @ OSR = 64",the SNR with window is "SNR = 119.2 dB @ OSR = 64".
But to my simulation, the result is "SNR = 86.1 dB @ OSR = 64" without window, "SNR = 85.7 dB @ OSR = 64" with window.
this is my code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;
clc;
close all;
%synthesizeNTF
OSR= 64;
H= synthesizeNTF(5, OSR, 1);
nLev= 3;
Nfft= 2^ 13;
tone_bin= 57;
t= [0: Nfft 1];
u= 0.5* (nLev 1)* sin(2* pi* tone_bin/ Nfft* t);
v= simulateDSM(u, H, nLev);
n= 1: 150;
stairs(t(n), u(n), 'g');
hold on;
stairs(t(n), v(n), 'b');
%NTF simulation, SQNR cal and spectral estimation without window
spec = fft(v)/(Nfft*(nLev1)/2);
snr = calculateSNR(spec(1:ceil(Nfft/(2*OSR))+1),tone_bin);
NBW = 1/Nfft;
f = linspace(0,0.5,Nfft/2+1); %this may be ahead?
Sqq = 4*(evalTF(H,exp(2i*pi*f))/(nLev1)).^2/3;
figure; %add a new figure
plot(f,dbv(spec(1:Nfft/2+1)),'b')
hold on;
plot(f,dbp(Sqq*NBW),'m','Linewidth',1);
s= sprintf('SNR= %4.1fdB @ OSR= %2.0f\n', snr, OSR);
text(0.05, 20, s);
%NTF simulation, SQNR cal and spectral estimation without window
spec = fft(v.*(hann(Nfft)'))/(Nfft*(nLev1)/4); %convert hann(Nfft) to vector matrix
snr = calculateSNR(spec(1:ceil(Nfft/(2*OSR))+1),tone_bin);
NBW = 1.5/Nfft;
f = linspace(0,0.5,Nfft/2+1); %this may be ahead?
Sqq = 4*(evalTF(H,exp(2i*pi*f))/(nLev1)).^2/3;
figure; %add a new figure
plot(f,dbv(spec(1:Nfft/2+1)),'b')
hold on;
plot(f,dbp(Sqq*NBW),'m','Linewidth',1);
s= sprintf('SNR= %4.1fdB @ OSR= %2.0f\n', snr, OSR);
text(0.05, 20, s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I use matlab r2011b for windows 64bit;
Pankaj Jha (view profile)
I am trying to implement a SDM using delsig toolbox. The following are the commands I try to run, along with the errors.
H = synthesizeChebyshevNTF(2,12.5,1,1.5,0);
>> stf = zpk([],[],1,1) ;
>> [a g b c] = realizeNTF(H,'CRFFD',stf)
Error using /
Matrix dimensions must agree.
Error in realizeNTF (line 246)
a = real(zL1/T);
Can you suggest me how to rectify the error???
Maxim (view profile)
Possible bug in function quantize() (file simulateDSM.c).
In saturate code:
if( vv > nLevels )
vv = nLevels1;
else if( vv < nLevels )
vv = 1nLevels;
May be correctly:
if( vv > (nLevels 1))
vv = nLevels1;
else if( vv < (1nLevels) )
vv = 1nLevels;
Regards,
Maxim
macau (view profile)
good thanks
Zhao Li (view profile)
To the folks having trouble compiling the Mex files on Windows with 64bit Matlab (bizet74 perhaps?), you will need to define the '__STDC__' symbol. For example, to compile simulateDSM.c, you would do 'mex D__STDC__
simulateDSM.c'
Regards,
Zhao
Pankaj Jha (view profile)
Respected Sir,
I am trying to simulate a sixth order sigma delta modulator using the
"Delta Sigma Toolbox".
1) My desired NTF is a 6th order Chebyshev type II high pass filter.
Hence, I ran the following command :
>> ntf = synthesizeChebyshevNTF(6,64,2,1.5,0)
The toolbox outputs the function given below:
Zero/pole/gain:
(z^2  2z + 1) (z^2  1.999z + 1) (z^2  1.998z + 1)

(z^2  1.629z + 0.6655) (z^2  1.705z + 0.7437) (z^2  1.854z + 0.8979)
Sampling time: 1
2) I wish to implement the above NTF using the "CIFB" structure. So
I ran the following command:
>>[a,g,b,c] = realizeNTF(ntf,'CIFB')
which gives the output
a =
0.0001 0.0013 0.0124 0.0794 0.3223 0.8120
g =
0.0002 0.0022 0.0012
b =
0.0001 0.0013 0.0124 0.0794 0.3223 0.8120 1.0000
c =
1 1 1 1 1 1
3) I tried to construct the "CIFB" structure using the coefficient
values provided by the toolbox, mentioned in the previous step.
4) I try to analyse the frequency content of the output (y2 in the
simulink file attached with this mail). I ran the following commands :
>> NFFT = 2^nextpow2(length(y2)); % Next power of 2 from length of y
>> Y = fft(y2,NFFT)/length(y2);
>> f = 300e6/2*linspace(0,1,NFFT/2+1);
>> plot(f,2*abs(Y(1:NFFT/2+1)))
5) The output is more like a low pass filter and not a high pass expected.
Hence, i request you to kindly have look at the .mdl file and the
commands executed by me, and help me find the mistake that I have
committed.
Mike Woodward (view profile)
If you're interested in this submission, you might also like the new, free mixedsignal library available from here: http://www.mathworks.com/programs/mixedsignal/index.html
Kevin (view profile)
Irfan Chaudhry (view profile)
zhang fuquan (view profile)
good job
nont none (view profile)
hi.how can i download dsp toolbox?
Mohammad alhawari (view profile)
@ bizet74
did u find how to solve ur problem coz am facing the same problem???
Sridhar (view profile)
Dear Dr. Schreier I am trying to use the toolbox to simulate a Sigma Delta Converter in Simulink. I was able to do it succesfully for a CIFF structure and now I am doing it for a CIFB structure.
Although I am able to simulate the Sigma Delta with the toolbox, it is unstable in Simulink.
Moreover I find that the CIFB topology shown in the manual is different as in this report (refer to figure 4 on page 5):
http://www.terasoft.com.tw/events/conference/2006/cfp/2006CFP_selected_Papers/3/32.pdf
My code is:
order=4;
OSR=545;
OPT=1;
H_inf=1.2;
ntf=synthesizeNTF(order, OSR, OPT, H_inf, f0);
[a,g,b,c]=realizeNTF(ntf, 'CIFB');
ABCD = stuffABCD(a,g,b,c,'CIFB');
Then I use the calculated a,g,b,c values in simulink.
best regards and thanks
Sridhar
bizet74 (view profile)
Thanks for you answer but unfortunately this is what I usually do.
I have copied the toolbox in a directory (say c:\delsig) and I set this directory as the current Matlab directory and then I typed, for instance, mex simulateDSM.c and I obtained the afore mentioned errors.
ASH VLSI (view profile)
@ bizet74
hi friend
i faced same problem .... it can be solved by setting toolbox directory as matlab current directory and then giving the command
bizet74 (view profile)
Hi!
I have some problems trying to compile simulateDSM.c, flattenStruct.c, and simulateESL.c. A part from several warnings I obtain these errors
simulateDSM.c(363) : error C2371: 'mexFunction' : redefinition; different basic types
C:\PROGRA~2\MATLAB\R2010A\extern\include\mex.h(147) : see declaration of 'mexFunction'
flattenStruct.c(27) : error C2371: 'mexFunction' : redefinition; different basic types
C:\PROGRA~2\MATLAB\R2010A\extern\include\mex.h(147) : see declaration of 'mexFunction'
simulateESL.c(547) : error C2371: 'mexFunction' : redefinition; different basic types
C:\PROGRA~2\MATLAB\R2010A\extern\include\mex.h(147) : see declaration of 'mexFunction'
I'm working with MATLAB Version 7.10.0.499 (R2010a) and Microsoft Visual C++ 2008 Express.
Does any one can help me?
Thank a lot in advance.
ASH VLSI (view profile)
can i model non idealities using this tool box ..........is it possible ????
ASH VLSI (view profile)
may i know how to use this tool box please .with some simple examples ...can anybody share it on my email :ashu9919@gmail.com
yang shisong (view profile)
I want to know how to use the toolbox,can you share me some example?thanks. my email:yssggh@126.com
he shiqing (view profile)
I got it.It's free to download ! I am sorry for misundstaning it
he shiqing (view profile)
how to buy the Delta Sigma Toolbox ????
shaohuip ? (view profile)
Thanks very much for your sharing. For quadrature band pass sigmadelta ADC design, when we use the synthesizeQNTF to get the NTF, then we can get the ABCD matrix by the realizeQNTF function. Finally how we can determine the coefficient like the [a,g,b,c] in low pass or band pass structure? Also for the quadrature structure, there is FF/FB/PFF/PFB, what is the difference between them and the previous CIFF/CIFB/CRFF/CRFB?
Thanks very much.
Thierry Tambe (view profile)
Outstanding Work. Exceptionally helpful in the simulations of SNDR versus DAC jitter, thermal noise and THD.
Vishal Saxena (view profile)
The deltasigma toolbox by Dr Schreier is a mandatory tool for anyone serious about deltasigma ADC design. The CT DSM extensions in the 2009 version look very useful and we will be evaluating them in a deltasigma converter design course being taught at Boise State.
http://cmosedu.com/vsaxena/courses/ece697/s10/ECE697.htm
Praveen Kumar (view profile)
Can I access the older versions of this toolbox. I am particularly interested in the old documentation.
zhang (view profile)
Who can tell me, in the book "Understanding DeltaSigma Data Converters ", in page 265,
1. spec = fft(v)/(Nfft*(nLev1)/2),
why (nLev1)/2 should be counted in to the spectrum computation?
2. Sqq = 4 * (evalTF(H,exp(2*pi*f))/(nLev1)).^2/3,
why does 4/3 mean in this equation?
Thanks a lot!
Payam (view profile)
Dear Richard,
First of all many thanks for developing such a nice toolbox and authoring such a great book "Understanding DeltaSigma Data Converters".
I am about to design a 4th order/10MHz BW/CT/Quadrature deltasigma ADC.
Unfortunately, I couldn't find any function and demo regarding design and simulation of a complex filter in the delsig toolbox. I would be grateful if you inform me about any enhancement of this toolbox for designing complex DS ADCs.
Your time and consideration are appreciated in advance.
Aztec WeiTing (view profile)
When I download this toolbox and run synthesizeNTF.m, an error always comes out at line 209 and column 22. Does any method to solve this problem? Thank you very much!
Ras123 V (view profile)
Quan (view profile)
it's my mistake. it's the total power in the signal bins to the total power in the noise bin.
Quan (view profile)
Thanks for such a useful tool box. I have a question of SNR calculation.
In the tool box, the function, caltulateSNR,is used to approximate inband signal power and noise power, and then SNR is calculated. the codes are as follows:
signalBins = [fnsig+1:f+nsig+1];
signalBins = signalBins(signalBins>0);
signalBins = signalBins(signalBins<=length(hwfft));
s = norm(hwfft(signalBins)); % *4/(N*sqrt(3)) for true rms value;
noiseBins = 1:length(hwfft);
noiseBins(signalBins) = [];
n = norm(hwfft(noiseBins));
if n==0
snr = Inf;
else
snr = dbv(s/n);
end
My question is: Since the length of signal bins and noise bins are totally different, how can signal power and noise power be substituted by
s = norm(hwfft(signalBins)) and n = norm(hwfft(noiseBins)), respectively.
I think the signal power and noise power should be like s = norm(hwfft(signalBins))*(4/N*sqrt(length(signalBins))) and n = norm(hwfft(noiseBins))*(4/N*sqrt(length(noiseBins))), respectively.
May be I'm wrong. But i'm really confused.
After u download how to u run the files.always error is occuring
I doenloaded this toolbox,but now I have a question.when i run synthesizeNTF.m,an error always comes out in 209 line.Browsing a lots of forum ,I find that the question is very popular.I expect you give a way to the problem,thank you from my heart!looking forword to your letter!
A significant contribution to the mixedsignal community around the world.
very good
very good!
very useful?Thanks Very much!!
It is very useful for the filter design, thanks
Very good!
Thanks for useful toolbox.Is it compatible with
matlab clones liek Scilab n Octave.If not wat are the modifications required??
Thank you very much!!!
excellent
The matlab code is:
OSR=128; %over sampling rate
order =2; %the order of SDM
ntf0=synthesizeNTF(order,OSR,1); %create the optimized ntf.
stf0=ntf0; %copy the ntf to stf, so that they will have the same poles.
stf0.z=[]; %set the numerator of stf to 1.
form='CIFF';
[a,g,b,c]=realizeNTF(ntf0,form,stf0);
I have a problem of using function "realizeNTF", if I set the "stf" has the same poles as "ntf" and use it as the input for the fucntion. Matlab tell me that:
??? Error using ==> mrdivide
Matrix dimensions must agree.
Error in ==> realizeNTF at 327
b = real(x/A);
Error in ==> Test_7755_NTF_Cap2 at 10
[a,g,b,c]=realizeNTF(ntf0,form,stf0);
If zpk is properly modified, this software should be user friendly.
If zpk is properly modified, this software should be user friendly.
Thank you for your toolbox. I am reading your book.
Thank you very much.
I like sushi very much.
Need more examples for designing SD structure include it's coefficients.
Dear Richard Schreier
Thanks for your exellent book on delta sigma and this complete toolbox
First,I use this tool to get the coefficients of a fiftheorder sigma delta modulater.And then I made a model in simulink with these coefficients.Then filter the modulated signal with a lowpass analog filter,I could not get the original signal.I found that the third order coefficients can get the perfect results in simulink.why?Thanks.
Dear Richard Schreier. Thank you for your dela sigma toolbox. I want to know if by your toolbox it is possible to simulate Continuoustime quadrature bandpass sigmadelta modulator. And if possible, please tell me how to use. Next,I kow how to simulate the feedforward summing topology without input feedforward with which feed only first stage integrator.
I look forward your reply this week.
I don't know yet how to use the Delta Sigma Toolbox. Firstly, I want to inform how to use
in Matlab simulink
Good! helpful.
it's good
fair
Dear Richard,
thank you for your toolbox. It looks very impresive.
I have one questions:
if I sample 1 second audio with 8000 Khz I will get a variable with 8000 points(i.e. >>x=wavrecord(8000,8000);)
when I simulate the output of a delta sigma modulator (when the input is x) with OSR=64 the output signal has a length of 8000. Why is that?...shouldn't it be 512000 because of the oversampling?)
Thank you.
I have a simply question,like Jacob, how to initialize this toolbox in matlab?What steps should I take to use Sigma Delta modulator?I only need to give as an input some signal (ex.sinus)and observe an output as a spectrum...Thanks for answer
sigmadelta box
I have a simply question, maybe somebody will be laughing:), but how to initialize this toolbox in matlab?What steps should I take to use Sigma Delta modulator?I only need to give as an input some signal (ex.sinus)and observe an output as a spectrum...Thanks for answer
gaziantep university
I am trying to simulate a basic Boser and Wooley Sigma Delta modulator
in matlab. The SNR calculated using calculateSNR function of SDMtoolbox
doesn't give proper results and as STF of this B&W architecture is not
unity I am unable to simulate it using simulateSDM function of SDM
toolbox. I request you to guide me simulating second order B&W SDM in
matlab and predicting the SNR correctly.
I am trying to simulate a basic Boser and Wooley Sigma Delta modulator
in matlab. The SNR calculated using calculateSNR function of SDMtoolbox
doesn't give proper results and as STF of this B&W architecture is not
unity I am unable to simulate it using simulateSDM function of SDM
toolbox. I request you to guide me simulating second order B&W SDM in
matlab and predicting the SNR correctly.
RE: current mirror
Don't copy everything from the book. He was a professor at Oregon State U. when he created the toolbox  Professors don't test their codes, the graduate students do.
He just took whatever results or claims that his student gave to him...You have to try testing every code by yourself since you're not a professor :)
David Kiriev
seems i do not get the same simulation results and SNR value as the book written by the author (page 264, 265); anyone got the same problem?
so smart one
excellent toolbox for sdm design, realizeNTF function for CIFF topology seems not correct though.
Excellent toolbox. Essential for the design of sigma delta modulators.
>> H=clans(5,32,5,0.95,1)
??? Error: File: D:\st\delsig\clans6.m Line: 35 Column: 37
"identifier" expected, "(" found.
Error in ==> D:\st\delsig\clans.m
On line 19 ==> NTF=clans6(order,OSR,Q,rmax,opt);
I just do it as document says. what's wrong?
always error as following when run dsdemo6.m, who can tell me why? please
??? Undefined function or variable 'firpm'.
Error in ==> D:\st\delsig\designHBF.m (designF1)
On line 119 ==> h = firpm(2*n11,[0 4*fp1 1 1],[1 1 0 0]);
Error in ==> D:\st\delsig\designHBF.m
On line 42 ==> [f1 zetap phi] = designF1( delta, fp1 );
Error in ==> D:\st\delsig\dsdemo6.m
On line 19 ==> [f1,f2,info]=designHBF(fp,delta,1);
Can I use this toolbox to simulate digital DS modulators in DAC?
i am not able to download
The file firpm.m is missed when i run designHBF.m program in the matlab 6.5 R13 software. please give some suggestions if possible
The calculateSNR.m is a good approximation, but might have problem when the number of points considered increased.
Organization can be improved further.
its good
no
good!
Very good. But just failed to compile the simulateDSM.c under Linux Matlab 6.5, always says that the file is not normal or not existed. For Window Matlab, it is okay.
Very useful tool to design high order single loop SD modulators
It will be nice if this toolbox is added in the next versions of MATLAB.
I need the synthesizeNTF and CLAN original document
Nice tool. Makes life of novice delta sigma designer easy
Very good when modulator order greater than 3; otherwise the famous "0.5" coefficients do the same job. When very low OSR (<32), filter refinement does not flatten enough the NTF. Excellent tool at medium OSR, and high modulator order.
It does what it should... thanks.
Excellent Work. It will be great help to design sigmadelta modulator, especially in system level.
Great tools for design DeltaSigma modulator
Very useful, not only for understanding, but also for systemlevel simulation for IC design
Great work ... thank you.
It's a well done work!
Thank u!