کد برنامه رایگان مدولاسیون دلتا سیگما مرتبه اول و دوم در کلاس d

پروژه ۸۲۳: شبیه سازی مدولاتور دلتا سیگما در فضای متلب 

در شبیه سازی حاضر به بررسی کد مدولاتور دلتا سیگما در کلاس d پرداخته ایم. کد برنامه حاضر در زبان متلب نوشته شده است. دو حالت برای این منظور در نظر گرفته شده: یکی مرتبه اول و دیگری مرتبه دوم. هر دو در کلاس d طراحی شده اند. 

مرتبه اول: 

% This function simulates first order delta sigma modulation without feedback.
% Its intended application is the Class D Audio Amplifier MQP, to be used with
% input signals in the audio band to assess noise and modulation techniques.
function output = dssim2(sigfreq, modfreq, simlength,C,R1,R2,Vqout,Vthres)
sigfreq=100000;
modfreq=100000;
simlength=10;
C=5e-6;
R1=1;
R2=3;
Vqout=30;
Vthres=3;
% Set sampling frequency
fs = modfreq*100;
% Create a basic sine wave
t = linspace(0,simlength-1/fs,fs*simlength);
f = sin(sigfreq*2*pi*t);
tqon=1/modfreq;
% Modulate!
bias = -max(f);
f=f+bias;
output = zeros(1,length(t));
dlatchstate = 0;
intvalue = Vthres-eps;
check = 0;
for i = 1:length(t)
 intvalue = intvalue - (1/(R1*C*fs))*f(i) - dlatchstate*(1/(R2*C*fs))*Vqout;
if mod(i,100)==0
if intvalue > Vthres
dlatchstate=1;
else
check = check + dlatchstate;
dlatchstate=0;
end
end
output(i)=1-dlatchstate;
end
check
%Plot fft
figure;
semilogx(linspace(0,fs,length(output)),20*log10(abs(fft(output))));
xlabel('Frequency (Hz)');
ylabel('Amplitude (dB)');
title('Delta Sigma Modulation');
sfft=abs(fft(output));
snrreg = sfft(11)/sum(sfft(15:floor(length(sfft)/2)));
dBsnr = 20*log10(snrreg);

 

مرتبه دوم: 

% This function simulates second order delta sigma modulation. Its
% intended application is the Class D Audio Amplifier MQP, to be used with
% input signals in the audio band to assess noise and modulation techniques.
function qoutput = secondorderdsm(sigfreq, modfreq, simlength)
% Set output pulsewidth and the reset voltage threshold for the d-latch and
% integrator
fs = modfreq*100;
%Create a basic sine wave
t = linspace(0,simlength-1/fs,fs*simlength);
f = sin(sigfreq*2*pi*t);

% insert test values
tqon=1/modfreq;
a1=4/9;
a2=1+3/9;
a3=11/18;
b1=1/3;
c1=modfreq;
c2=modfreq;
% Modulate!
qoutput = zeros(1,length(t));
c1output = zeros(1,length(t));
c2output = zeros(1,length(t));

T=1/fs;
qstate = 0;
c1value = 0;
c2value = 0;
check = 0;
for i = 1:length(t)
c1value = c1value + (1/(fs))*(b1*f(i) - qstate*a1);
c2value = c2value + (1/(fs))*(c1*c1value - qstate*a2);
qin = c2value*c2 - a3*qstate;
if mod(i,100)==0
if qin > 0.5
qstate = 1;
elseif qin < -0.5

qstate = -1;
else
qstate = 0;
end
end
qoutput(i)=qstate;
c1output(i)=c1*c1value;
c2output(i)=c2*c2value;

end
plot(t,5*qoutput,’b’,t,f,’r’);
semilogx(linspace(0,fs,length(qoutput)),20*log10(abs(fft(qoutput))),’b’);
xlabel(’Frequency (Hz)’);
ylabel(’Amplitude (dB)’);
title(’Delta Sigma Modulation (System Model)’);
max(20*log10(abs(fft(qoutput))))
end

 در صورت سوال در مورد این کد برنامه می توانید از بخش تماس با ما (منوی بالا)، با شماره تلفن مورد نظر مکاتبه نمایید.  

متلب تولز: سایت تخصصی پروژه های خاص 

 

برای عضویت در کانال روی عکس زیر کلیک کنید : (آخرین اخبار مرتبط با مهندسی و سایر تکنولوژی ها)

یا آدرس لینک زیر را در تلگرام خود جستجو نمایید:

m_b_coll@


مجموعه: پروژه هابرچسب ها , , , , , , , , , , , , , , , , , , , ,

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *