Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to draw the power spectral of the PWM and calculate THD in Matlab?

Status
Not open for further replies.

clarken

Newbie level 4
Joined
Jun 20, 2007
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,378
i am doing the final year project about class D amplfier , use some algorithm to produce PWM , then pass to the power amplifier and low pass filter to generate sound.

Since i finish to build the class D amplifier in fypga and also able to see the Power spectral of the generated PWM to measure the THD of the board. The only thing i need to do now is use the matlab to see the Power spectral of the PWM inside the matlab.

I already can produce the PWM in matlab.But i did not know how to draw the power spectral of the PWM and calculate THD. Anyone know, please help me .

My system start with the signa sine wave 5khz, carrier frequency is 200khz , so the PWM had the frequency is 200khz, and will contain the information of 5khz.
Thanks
 

Re: matlab simulation

Hi you First try this with simulink
 

    V

    Points: 2
    Helpful Answer Positive Rating
matlab simulation

i knew something about the fft function , but i do not know how to choose the N for my application. Each period (1/200khz) will have 4096 point ( some will be 1 and some will be zero--> PWM) .... The duty cycle is not fixed but changed.

So what i should choose N value for my system and how to draw the power density spectral ?

All i read is a example for the sine or cosine wave, i do not know how to apply it
 

matlab simulation

Normally by default 512 point fft is seen at the ouput. You can see psd at the output using following command
where x is filtered output


y=fft(x,512);
df=fs/512;
m=fftshift(abs(y));
m=m.^2;
m1=20*log10(m);
p=unwrap(angle(y));
f = -(fs/2)+df:df:(fs/2);
plot(f,m1);title('magnitude')
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top