Uploaded by Ayrton Felix

PAM PWM Lab Sessions

advertisement
The purpose of the laboratory sessions is to design and demonstrate a PAM and PWM communication system
in MATLAB. The modulation methods of PAM and PWM approaches are digital baseband modulation
methods. Being baseband, they are not used in broadband applications. These modulation methods are used
for communication applications that can be executed at a low bit rate. The PAM method can be used in digital
motor control systems. Such motors find meaningful applications in several power and control systems. These
systems are widely used in industrial and several commercial applications.
Some of the notable application areas of the Pulse Amplitude Modulation Technique are:
1. Audio Systems – The PAM technique is used in low bandwidth and low data rate applications to
enable the conversion of audio signals to digital format. Such a capability finds usefulness in digital
audio systems. The use of PAM in this case involves the sampling of the analog signal and assigning
a binary code to represent the amplitude value of each sample.
2. High-speed fiber optic communications – The PAM technique is used to encode digital data onto a
light signal in fiber systems. The light signal amplitude is varied to represent the digital data. This
application finds usefulness in communication systems.
3. Medical Imaging – PAM can be used to realize the goal of generating high resolution in medical
imaging techniques such as ultrasound and MRI. The amplitude of the acoustic or electromagnetic
signal is varied to obtain a 2D or 3D image.
4. Signal Amplification – Power amplifiers benefit from the use of the PAM technique in realizing the
amplification of signal power.
In the context of communication systems, the PAM is used in applications such as Digital Audio, Fibre
Communications, Radar, SONAR, and wireless communications. The Pulse Width Modulation technique
enables the variation of the width of pulses being used in different applications that inherently involve signal
communications. The variation of the pulse width influences the amount of power delivered to different
components in various systems. Examples of such component-related applications are:
1. Audio Amplification – The PWM technique is used in Class D audio amplifiers. In this context, they
play an important role in the conversion of audio signal to a PWM signal. The PWM is used to vary
the width of pulses to represent audio signal amplitude.
2. Motor Control – In this case, pulse width is varied to control the power received by the motor. This
results in the variation of the motor speed. Applicable motors are DC motors, stepper motors and servo
motors.
3. Lighting Control – The width of the pulses influences the amount of current delivered to a light
source. This in turn controls the brightness of the concerned light source. Examples of such light
sources are LEDs, incandescent bulbs, and fluorescent lamps.
4. Power Converters – Used for power conversion in DC–DC converters and AC – AC converters. In
this case, the pulse width is used to determine the amount of power received by the load.
5. Power Systems – Used in the control of battery charging circuits. This is necessary to prevent battery
overcharging and is achieved by varying the pulse width. In a similar manner pulse width modulation
is also used to regulate the output current or voltage. This is realizable by varying the width of the
pulses. This enables control of the switching frequency of the power supply.
The stages associated with the demonstration of the PAM and PWM signals are given as:
1. Stage 1 – Specification of signal parameters.
2. Stage 2 – Generation of Bits being modulated by the Pulse Amplitude Modulation (PAM)
method.
3. Stage 3 – Execution of the PAM modulation involving the creation and realization of PAM
symbols. A symbol is a group of bits.
4. Stage 4 – Execution of the PWM modulation in a manner like that of PAM modulation. In this
case, a symbol is also a group of bits.
5. Stage 5 – Realization of Channel Effect: This is done by introducing noise into the PAM and
PWM-associated signals. Essentially, this stage involves adding noise to the signal being
transmitted.
6. Stage 6 – Reception: The process of signal reception involves the execution of the core
functionality of PAM and PWM signal demodulation.
7. Stage 7 – This is the stage where error arising from the execution of PAM and PWM
transmission is computed. The error is quantified using the bit error rate (BER), a parameter
that is frequently used and associated with digital communication systems.
8. Stage 8 – Visualization of Results
%PAM-PWM Communication System
Stage 1 – Specification of signal parameters
% Define Parameters
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
N = 10000; % Number of samples
fc = 100; % Carrier frequency
A = 1; % Amplitude of the signal
M = 2; % Number of bits in each symbol
N_symbols = N/M; % Number of symbols
symbol_rate = 10; % Symbol rate
Stage 2 – Generation of Bits being modulated by the Pulse Amplitude Modulation (PAM) method.
% Generate random bits
bits = randi([0 1], 1, N_symbols*M);
Stage 3 – Execution of the PAM modulation involving the creation and realization of PAM symbols. A
symbol is a group of bits.
% Perform PAM modulation
pam_symbols = reshape(bits, M, N_symbols)';
pam_symbols = 2*pam_symbols-1;
Stage 4 – Execution of the PWM modulation in a manner like that of PAM modulation. In this case, a
symbol is also a group of bits.
% Perform PWM modulation
t = (0:N-1)*T; % Time vector
pwm_symbols = zeros(1,N);
for n = 1:N_symbols
pwm_symbols((n-1)*M+1:n*M) = pam_symbols(n);
end
pwm_signal = A*cos(2*pi*fc*t + pi/2 + pi/2*pwm_symbols);
Stage 5 – Realization of Channel Effect: This is done by introducing noise into the PAM and PWMassociated signals. Essentially, this stage involves adding noise to the signal being transmitted.
% Add noise to the signal
SNR = 10; % Signal to noise ratio
noise_power = A^2/(2*10^(SNR/10));
noise = sqrt(noise_power)*randn(1,N);
received_signal = pwm_signal + noise;
Stage 6 – Reception: The process of signal reception involves the execution of the core functionality of
PAM and PWM signal demodulation.
% Perform PWM demodulation
pwm_demod_signal = received_signal.*cos(2*pi*fc*t + pi/2);
pwm_demod_signal_lp = lowpass(pwm_demod_signal, fc/10, Fs);
pwm_demod_symbols = sign(pwm_demod_signal_lp);
% Perform PAM demodulation
bits_received = reshape((pwm_demod_symbols+1)/2, 1, N_symbols*M);
Stage 7 – This is the stage where error arising from the execution of PAM and PWM transmission is
computed. The error is quantified using the bit error rate (BER), a parameter that is frequently used
and associated with digital communication systems.
% Calculate Bit Error Rate
BER = sum(abs(bits_received-bits))/length(bits);
disp(['Bit Error Rate: ', num2str(BER)])
Stage 8 – Visualization of Results
% Plot results
figure;
subplot(4,1,1)
plot(t(1:10), pam_symbols(1:10), 'b')
title('PAM Symbols')
subplot(4,1,2)
plot(t, pwm_symbols, 'g')
title('PWM Symbols')
subplot(4,1,3)
plot(t, received_signal, 'r')
title(['Received Signal (SNR = ', num2str(SNR), ' dB)'])
subplot(4,1,4)
plot(t, pwm_demod_symbols, 'm')
title('PWM Demodulated Symbols')
The entire code listing in this case is given as:
%PAM-PWM Communication System
% Define Parameters
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
N = 10000; % Number of samples
fc = 100; % Carrier frequency
A = 1; % Amplitude of the signal
M = 2; % Number of bits in each symbol
N_symbols = N/M; % Number of symbols
symbol_rate = 10; % Symbol rate
% Generate random bits
bits = randi([0 1], 1, N_symbols*M);
% Perform PAM modulation
pam_symbols = reshape(bits, M, N_symbols)';
pam_symbols = 2*pam_symbols-1;
% Perform PWM modulation
t = (0:N-1)*T; % Time vector
pwm_symbols = zeros(1,N);
for n = 1:N_symbols
pwm_symbols((n-1)*M+1:n*M) = pam_symbols(n);
end
pwm_signal = A*cos(2*pi*fc*t + pi/2 + pi/2*pwm_symbols);
% Add noise to the signal
SNR = 10; % Signal to noise ratio
noise_power = A^2/(2*10^(SNR/10));
noise = sqrt(noise_power)*randn(1,N);
received_signal = pwm_signal + noise;
% Perform PWM demodulation
pwm_demod_signal = received_signal.*cos(2*pi*fc*t + pi/2);
pwm_demod_signal_lp = lowpass(pwm_demod_signal, fc/10, Fs);
pwm_demod_symbols = sign(pwm_demod_signal_lp);
% Perform PAM demodulation
bits_received = reshape((pwm_demod_symbols+1)/2, 1, N_symbols*M);
% Calculate Bit Error Rate
BER = sum(abs(bits_received-bits))/length(bits);
disp(['Bit Error Rate: ', num2str(BER)])
% Plot results
figure;
subplot(4,1,1)
plot(t(1:10), pam_symbols(1:10), 'b')
title('PAM Symbols')
subplot(4,1,2)
plot(t, pwm_symbols, 'g')
title('PWM Symbols')
subplot(4,1,3)
plot(t, received_signal, 'r')
title(['Received Signal (SNR = ', num2str(SNR), ' dB)'])
subplot(4,1,4)
plot(t, pwm_demod_symbols, 'm')
title('PWM Demodulated Symbols')
Critical Reasoning Related Questions
Q1: What is the effect of changing the signal-to-noise ratio on the bit error rate for the PAM and
PWM signals considered above. Present the appropriate plots in your explanation.
Q2: Please, write the MATLAB implementation for the PCM system.
Download