Search code examples
pam

Flat top Pulse Amplitude Modulation


i want to plot flat-topped PAM of sinusoid. wave using matlab. the sinusoidal signal has frequency = 10^4/(2*pi) HZ and sampling frequency = 8 kHZ. pulse duration T = 50 microseconds. i wrote code for natural sampling, so how to do flat-top?

clear all;
close all;
Fs = 1e9;
t = 0:1/Fs:(0.2e-2);
fc = 8000; %sampling frequency
fm = 10^4/(2*pi); %message frequency
a = 1;
vm = a.*sin(2*pi*fm*t); %message
pulseperiods = [0:10]*1/fc;
pulsewidth = 50e-6;
vc = pulstran(t,pulseperiods,@rectpuls,pulsewidth);
y = vc.*vm;
figure
subplot(3,1,1);
plot(t,vm); % plot message
xlabel('Temps');
ylabel('Amplitude');
title('Message');
subplot(3,1,2);
plot(t,vc); % plot pulse 
xlabel('Temps');
ylabel('Amplitude');
title('Switching waveform');
subplot(3,1,3);
plot(t,y); % plot PAM naturel
xlabel('Temps');
ylabel('Amplitude');
title('PAM naturel');

Solution

  • The flat-top PAM means the instantaneous sampling, i.e. the message signal is sampled only once per period, so modulated signal does not change its value until returning to zero and next sampling period. The sampling takes place at rising edge of carrier signal, so the solution is quite straightforward: by adding the for loop to your code:

    for i = 2:length(t)
        if vc(i) == 1 && vc(i-1) == 0 %if the rising edge is detected
            y1(i) = vc(i) * vm(i);    %sampling occurs
        elseif vc(i) == 1 && vc(i-1) == 1 %and while the carrier signal is 1
            y1(i) = y1(i-1);              %the value of y1 remains constant
        else
            y1(i) = 0;                %otherwise, y is zero
        end
    end
    plot(t,y1); % flat-top PAM plot
    xlabel('Temps');
    ylabel('Amplitude');
    title('PAM flat-top');
    

    you get

    enter image description here