K = 32;
N = 32;
x_num = 500;
%generate BPSK symbols randomly with value +1 or -1
x = bingen(x_num);
pause
%DS-SS modulate symbols with user code
UserCode = hadamard(N); % generation de code de walsh
c = UserCode(1,: ) ; %code column vector
y = ds_mod(c( : ) ,x ); %modulation ( i wrote a function named ds_mod wich do that we call this operation modulation or spreading.i used direc sequence of course
ige1986 said:hello, yes of course you must modulate your data , you can see my simulation :
K = 32;
N = 32;
x_num = 500;
%generate BPSK symbols randomly with value +1 or -1
x = bingen(x_num);
pause
%DS-SS modulate symbols with user code
UserCode = hadamard(N); % generation de code de walsh
c = UserCode(1,: ) ; %code column vector
y = ds_mod(c( : ) ,x ); %modulation ( i wrote a function named ds_mod wich do that we call this operation modulation or spreading.i used direc sequence of course
i'm in service
Aya2002 said:this is a sample for a Walsh of length 8:
1 1 1 1 1 1 1 1
1 -1 1 -1 1 -1 1 -1
1 1 -1 -1 1 1 -1 -1
1 -1 -1 1 1 -1 -1 1
1 1 1 1 -1 -1 -1 -1
1 -1 1 -1 -1 1 -1 1
1 1 -1 -1 -1 -1 1 1
1 -1 -1 1 -1 1 1 -1
and this is a randomly generated data for 8 users where each row is a message for a user:
1 1 -1 1 -1 1 1
-1 -1 1 -1 -1 -1 -1
1 1 1 -1 1 1 -1
-1 1 1 -1 1 -1 1
1 -1 1 -1 -1 1 1
1 1 -1 -1 -1 -1 1
1 -1 -1 -1 1 -1 1
-1 1 1 1 -1 -1 1
guide me please, as this is the first time for me to simulate a CDMA.
regards
a = rectpulse(User1Data,SF)
b = repmat(WalshCode,1,length(User1Data))
WalshCodeNorm = WalshCode/sqrt(SF)
WalshCode =
[1 1 1 1 1 1 1 1
1 -1 1 -1 1 -1 1 -1
1 1 -1 -1 1 1 -1 -1
1 -1 -1 1 1 -1 -1 1
1 1 1 1 -1 -1 -1 -1
1 -1 1 -1 -1 1 -1 1
1 1 -1 -1 -1 -1 1 1
1 -1 -1 1 -1 1 1 -1];
UserData =
[ 1 1 -1 1 -1 1 1
-1 -1 1 -1 -1 -1 -1
1 1 1 -1 1 1 -1
-1 1 1 -1 1 -1 1
1 -1 1 -1 -1 1 1
1 1 -1 -1 -1 -1 1
1 -1 -1 -1 1 -1 1
-1 1 1 1 -1 -1 1];
User1Data = UserData(1,:);
Walsh4User1 = WalshCodeNorm(1,:);
WalshCodeNorm = WalshCode/sqrt(SF)
User1Data = UserData(1,:);
Walsh4User1 = WalshCodeNorm(1,:);
a = rectpulse(User1Data,SF)
b = repmat(Walsh4User1,1,length(User1Data));
SpreadSig = a.*b;
Communications_Engineer said:1) Over sample your user data by a factor equal to spreading factor using
Code:a = rectpulse(User1Data,SF)
2) Repeat the spreading sequence for every bit/symbol of user data using
Code:b = repmat(WalshCode,1,length(User1Data))
3) finally, multiply both of them to get spread signal
Important: before multiplying make sure you normalize the energy of the spreading sequence to one (unity), do this by dividing WalshCode by sqrt(SF) i.eCode:WalshCodeNorm = WalshCode/sqrt(SF)
Communications_Engineer said:with out noise your ber should be zero. any way let me get this straight you are adding walsh sequence with your user data?
or you are adding multiple spread signals?
Hello Friends,
I have simulated the CDMA system by matlab. I used Walsh code of length 2^n where this number will be the number of users as well. The message will be a binary numbers randomly generated of same length for each user where the message length will be more than 2 bits (may be 2000 or more bits).
My question is:
after the summation of the coded messages, shall i use a bit mapping, i mean shall i use a baseband digital modulation such as BPSK or others before sending it to the channel?
thanks
%% DS - CDMA (SNR-Performance)
clear all;close all;clc;
nu=input('Number of Users = ');
u=[];s=[];
ml=input('Number of bits for each user = ');
hl=2^nextpow2(nu);
%
for k = 1:nu
u_binary(k,:)=randi([0 1],1,ml);
end
for k = 1:nu
u_BPSK(k,:)=u_binary(k,:)*2-1;
end
for n=1:nu
s(n,:)=cdmat(u_BPSK(n,:),hl,n);
end
cd1=sum(s);
%% Oversampling
cd =rectpulse(cd1,4);
loo=0;
for SNR=0:2:8
loo=loo+1;
t=awgn(cd,SNR,'measured');
%% Integrate and dump (downsampling)
or=intdump(t,4);
sr=[];
for p=1:nu
sr(p,:)=cdmar(or,hl,p,ml);
end
binary_rx=(sr+1)/2;
[n(loo),r(loo)]=symerr(u_BPSK,sr);
end
figure;%plot combined signals
%Tx
subplot(211);stem(cd1(1:20),'filled');
title('Combined signals (only 20 symbols');
xlabel('Index of Combined symbols');
ylabel('Magnitude');
grid;
%Rx
subplot(212);stem(or(1:20),'filled');
title('Combined noisy signals (only 20 symbols');
xlabel('Index of Combined symbols');
ylabel('Magnitude');
grid;
SNR=0:2:8;
figure; % plot the BER vs. SNR
semilogy(SNR,r,'r-x'),grid;
figure;% plot data for a randomly selected user such as user no. 1 before the BPSK mapping Tx and Rx
% Tx
subplot(211);stem(u_binary(1,1:10),'filled');grid
xlabel('Bits index');
title('Transmitted Bits (showing only 10 bits)');
% Rx
subplot(212);stem((sr(1,1:10)+1)/2,'filled');grid
xlabel('Bits index');
title('Received Bits (showing only 10 bits)');
figure;% plot data for a randomly selected user such as user no. 1 after the BPSK mapping Tx and Rx
% Tx
subplot(211);stem(u_BPSK(1,1:10),'filled');grid
xlabel('Symbol index');
title('Transmitted BPSK Symbols (showing only 10 Symbol)');
% Rx
subplot(212);stem(sr(1,1:10),'filled');grid
xlabel('Symbol index');
title('Received BPSK Symbols (showing only 10 Symbol)');
%% Code Division Multiple Access Reciever
% CDMAr - Function
% 1. (s) Input the data
% 2. (hl) Hadamard matrix length
% 3. (cn) code number to be used for this user (row - number of H - matrix)
% 4. (ml) original message length for this user
% 4. Despread the data by multiplying s by cn.
% 6. Outpot of the function is a despread data of user cn.
% Montadar Abas Taher
% 11/03/2011
function [outcdmar]=cdmar(s,hl,cn,ml)
if cn>hl
errordlg('The input code number must be equal or less than the Hadamard length','File Error');
end
%% Generate Hadamard Matrix of length (hl)
h=hadamard(hl);
%% Despread the input sequence
scused=ones(1,ml);
bds=kron(scused,h(cn,:));
ds=bds.*s;
rds=reshape(ds,hl,length(s)/hl);
ou=sum(rds);
t=length(ou);
en=[];
for a=1:t
if ou(a)>1
en(a)=1;
else
en(a)=-1;
end
end
outcdmar=en;
%% Code Division Multiple Access Transmitter
% CDMAt - Function
% 1. (s) Input the data
% Input data must be (+/- 1's) (this is a PSK modulation (BPSK))
% 2. (hl) Hadamard matrix length
% 3. (cn) code number to be used for this user (row - number of H - matrix)
% 4. Spread the data by multiplying s by cn.
% 6. Outpot of the function is spread symbol of user cn.
% Montadar Abas Taher
% 11/03/2011
function [outcdmat]=cdmat(s,hl,cn)
if cn>hl
errordlg('The input code number must be equal or less than the Hadamard length','File Error');
end
%% Generate Hadamard Matrix of length (hl)
h=hadamard(hl);
%% Spread the input sequence
outcdmat=kron(s,h(cn,:));
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?