High BER for QAM
Afficher commentaires plus anciens
I am facing a problem here. I tried to implement a simulation for QAM from the scratch without using qammod, but the error rate seems to be so high, to the point I think the received symbols is just random. Can someone help with the code:
% 16-QAM Modulation and Demodulation with carrier 1 GHz.
clear all
close all
clc
% QAM Parameters:
M = 16; % Order of Modulation "16-QAM"
bits_symbol = log2(M); % Number of Bits per Symbol
fc = 1e9; % Carrier frequency
fs = 10*fc; % Sampling rate at least 4 to 10 times fc
num_symbol = 250; % Number of Symbols to be transmitted
t = (0:1/fs:num_symbol*(1/fs)-1/fs); % Time vector
% Random Input Generation:
input = randi([0,1], num_symbol, bits_symbol);
% Constellation Mapping:
constellation = (-sqrt(M)+1:2:sqrt(M)-1); %Constellation [-3, -1, 1, 3]
% Map the symbols:
I = constellation(bi2de(input(:,1:bits_symbol/2),'left-msb')+1); % In-phase component
Q = constellation(bi2de(input(:, bits_symbol/2+1:end),'left-msb')+1); % Quadrature component
% Modulated signal:
Tx = I .* cos(2*pi*fc*t) + Q .* sin(2*pi*fc*t);
% Tx = awgn(Tx, 20, 'measured'); % Adding noise for testing
% Demodulation:
Rx_I = 2 * Tx .* cos(2*pi*fc*t); % In-phase demodulation
Rx_Q = 2 * Tx .* sin(2*pi*fc*t); % Quadrature demodulation
% Lowpass filter:
Rx_I_f = lowpass(Rx_I, fc/2, fs);
Rx_Q_f = lowpass(Rx_Q, fc/2, fs);
% Symbol decision (finding the closest constellation point):
I_org = zeros(num_symbol, 1);
Q_org = zeros(num_symbol, 1);
for x = 1:num_symbol
[~, I_org(x)] = min(abs(Rx_I_f(x) - constellation'));
[~, Q_org(x)] = min(abs(Rx_Q_f(x) - constellation'));
end
% Combine I_org and Q_org to get the original symbols:
output = [de2bi(I_org-1, bits_symbol/2, 'left-msb'), de2bi(Q_org-1, bits_symbol/2, 'left-msb')];
% Calculate the Bit Error Rate (BER):
[~, BER] = biterr(input, output);
fprintf('Bit Error Rate (BER): %f\n', BER);
Réponse acceptée
Plus de réponses (1)
Hi Muath, when developing a QAM (Quadrature Amplitude Modulation) simulation from scratch, it's crucial to focus on several key elements to ensure the modulation and demodulation processes are correctly executed. To achieve lower error rate, here are a few things that can be modified in your code :
- Increased SNR: The SNR can been set to 15 dB. You can adjust this value further based on your requirements. A higher SNR generally results in a lower BER.
- AWGN Noise Addition: The noise is added to the transmitted signal to simulate a more realistic communication channel.
- Improved Lowpass Filtering: The lowpass filter is retained but ensure that it effectively removes noise while preserving the signal.
Following is the modified code to achieve lower BER :
clear all;
close all;
clc;
% QAM Parameters:
M = 16; % Order of Modulation "16-QAM"
bits_symbol = log2(M); % Number of Bits per Symbol
fc = 1e9; % Carrier frequency
fs = 10 * fc; % Sampling rate at least 4 to 10 times fc
num_symbol = 250; % Number of Symbols to be transmitted
t = (0:1/fs:num_symbol*(1/fs)-1/fs); % Time vector
% Random Input Generation:
input = randi([0, 1], num_symbol, bits_symbol);
% Constellation Mapping:
constellation = (-3:2:3) + 1i * (-3:2:3)'; % Create a 4x4 grid for 16-QAM
constellation = constellation(:); % Reshape to a column vector
% Map the symbols:
I_bits = input(:, 1:bits_symbol/2); % In-phase bits
Q_bits = input(:, bits_symbol/2+1:end); % Quadrature bits
I_decimal = bi2de(I_bits, 'left-msb'); % Convert in-phase bits to decimal
Q_decimal = bi2de(Q_bits, 'left-msb'); % Convert quadrature bits to decimal
I = constellation(I_decimal + 1); % In-phase component
Q = constellation(Q_decimal + 1); % Quadrature component
% Modulated signal:
Tx = I .* cos(2 * pi * fc * t) - Q .* sin(2 * pi * fc * t);
% Add AWGN noise
SNR_dB = 15; % Increase SNR to reduce BER
Tx_power = mean(abs(Tx).^2);
noise_power = Tx_power / (10^(SNR_dB/10));
noise = sqrt(noise_power) * randn(size(Tx)); % Additive white Gaussian noise
Rx = Tx + noise; % Received signal
% Demodulation:
Rx_I = 2 * Rx .* cos(2 * pi * fc * t); % In-phase demodulation
Rx_Q = 2 * Rx .* sin(2 * pi * fc * t); % Quadrature demodulation
% Lowpass filter:
Rx_I_f = lowpass(Rx_I, fc/2, fs);
Rx_Q_f = lowpass(Rx_Q, fc/2, fs);
% Symbol decision (finding the closest constellation point):
I_org = zeros(num_symbol, 1);
Q_org = zeros(num_symbol, 1);
for x = 1:num_symbol
[~, I_org(x)] = min(abs(Rx_I_f(x) - real(constellation)));
[~, Q_org(x)] = min(abs(Rx_Q_f(x) - imag(constellation)));
end
% Combine I_org and Q_org to get the original symbols:
output_I = de2bi(I_org - 1, bits_symbol/2, 'left-msb'); % Convert in-phase to bits
output_Q = de2bi(Q_org - 1, bits_symbol/2, 'left-msb'); % Convert quadrature to bits
output = [output_I, output_Q]; % Combine in-phase and quadrature bits
% Calculate the Bit Error Rate (BER):
[~, BER] = biterr(input, output);
fprintf('Bit Error Rate (BER): %f\n', BER);
By increasing the SNR and ensuring that your modulation and demodulation processes are correctly implemented, you should see a reduction in the Bit Error Rate.
1 commentaire
Muath
le 9 Sep 2024
Catégories
En savoir plus sur Modulation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!