|
Prev: HW interrupt problem
Next: O-QPSK Demodulation
From: kameren on 14 Dec 2005 10:47 sin signal frequency 10^4/(2*pi) Hz sampling rate 8 kHz Applied to a sample-and-hold circuit to produce a flat-topped PAM signal with pulse duration 500us. how do i compute the waveform of the PAM signal? how do i compute and denote the magnitude spectrum of the PAM signal? how do i compute the envelope? Thus far this is what i have. i'm still adjusting the length part. hope someone can help. thanks clf; fs=8000; Ts=1/fs; td=1.25e-5; f0=10000/(2*pi); t=[0:td:100*td]; y=sin(2*pi*f0*t); axis([0 0.1 -1 1]); plot(t,y,'r-'); hold on; t2=[0:Ts:100*td]; y2=sin(2*pi*f0*t2); plot(t2,y2,'b*'); y3=zeros(1,length(t)); x=(length(t)/length(t2)); for n=1:length(t2) for m=1:(length(t)/length(t2)) y3((n-1)*floor(x)+m)=y2(n); end end plot (t,y3(1:length(t)),'m'
From: Fred Marshall on 14 Dec 2005 23:27 "kameren" <t.tharmarasan(a)gmail.com> wrote in message news:v-OdnSnDP_Y0oz3eRVn-sg(a)giganews.com... > sin signal frequency 10^4/(2*pi) Hz > sampling rate 8 kHz > Applied to a sample-and-hold circuit to produce a flat-topped PAM signal > with pulse duration 500us. > > how do i compute the waveform of the PAM signal? It looks like you did. The only thing that might be a bit misleading is that the sampling frequency appears to be very close to being a multiple of the signal frequency: 5.0266. You might want to to two things: 1) make it very much not such a multiple like relating them by a multiple of pi. 2) make it exactly a multiple just to see what happens (understanding it is a very special case). > how do i compute and denote the magnitude spectrum of the PAM signal? abs(fft(y)) > how do i compute the envelope? Here is one, rather simple way: r(i) = abs(y(i)); interim rectified version of the input. s(i) =s (i-1) + k*[r(i)-s(i-1)] where k<1 s(i) = k*r(i) + (1-k)*s(i-1); the output k is a coefficient that works to lowpass filter the result to remove the sampling frequency. You will recognize this as an IIR filter. If r(i) goes to zero and stays there, then the output will decay exponentially to zero. If r() is a step, then the output will rise exponentially to the value of the step. If k is large, the exponential rise/fall will be fast. If k is small, the exponential rise/fall will be slow. Generally, k is set high enough to respond as rapidly to the peak values as needed and low enough to respond slowly to the sampling frequency. If k is too high then the sampling frequency will be evident. Now, if you meant the "complex envelope" that's a different matter! Fred
From: Fred Marshall on 15 Dec 2005 21:36 And to get a meaningful envelope you probably need to have a lot more cycles of the underlying sinusoid. Fred
From: kameren on 21 Dec 2005 10:05 >sin signal frequency 10^4/(2*pi) Hz >sampling rate 8 kHz >Applied to a sample-and-hold circuit to produce a flat-topped PAM signal >with pulse duration 500us. > >how do i compute the waveform of the PAM signal? >how do i compute and denote the magnitude spectrum of the PAM signal? >how do i compute the envelope?(to see if the envelope is 20khz) > >k completed the part i needed but i'm confused with the envolope. my final form of matlab code: clear all clf; fs=8000; Ts=1/fs; td=1.25e-5; f0=10000/(2*pi); t=[0:td:100*td]; y=sin(2*pi*f0*t); SUBPLOT(3,1,1), plot(t,y,'b'); %input signal(message) xlabel('Time(s)'); ylabel('Amplitude') hold; t2=[0:Ts:100*td]; y2=sin(2*pi*f0*t2); plot(t2,y2,'g*'); %sampled at 8kHz y3=zeros(1,length(t)); m=1; for n=1:101; if t(n)== t2(m); m=m+1; y3(n)=y2(m-1); else y3(n)=y2(m-1); end end plot (t,y3,'m'); %sample and hold z=ones(1,length(t2)); %-----------------------------Getting Pulse signal at sampling frequency 8khz------------------------------------ c=1; for n=1:101; if t(n)==t2(c); z2(n)=z(c); c=c+1; else z2(n)=0; end end %plot (t,z2) st=z2.*y; % resultant of input signal and sampled pulse signal %plot(t,st) %------------------------------Procedure to get better graphics of a Flat top Pam Signal------------------------- for k=1:101; if st(k)~=0&k<101 st2(k-1)=st(k); st2(k)=st(k); st2(k+1)=st(k); else st2(100)=st(101); st2(101)=st(101); end end SUBPLOT(3,1,2), plot (t,st2) % Pam signal xlabel('Time(s)'); ylabel('Amplitude'); Sf= fft (st2,512); % in frequency domain mag= abs(Sf); % magnitude of Sf f = (0:511)*fs/length(Sf); SUBPLOT(3,1,3), plot(f,mag); %-------------------------------------disregard----------------------------------------------- %plot (t,y6) %y9=(y6.*y); %plot (t,y9) %Y=fft (y3,101); %S(f) %mag= abs (Y); %magnitude of S(f) %f = (0:100)*fs/length(Y); %plot(f,mag) %magnitude spectrum %y4=(square(2*pi*8000*t)); %y5=ones(1,length(t)); %y6=(y5+y4)/2; %pulse sampling at 8000hz %plot(t,y,'b'); %powerdB=20*log10(mag); %plot (t,abs(hilbert(y))) %stem(t2,y2) %plot (abs(fft(y))) %plot(linspace(-5*1e9,5*1e9,512),fftshift(abs(fft(Pulse,512))))
|
Pages: 1 Prev: HW interrupt problem Next: O-QPSK Demodulation |