Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Two User CDMA-OFDM (MC-CDMA) code

Status
Not open for further replies.

moneer

Newbie level 5
Joined
Dec 22, 2009
Messages
10
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Jordan
Activity points
1,481
CDMA-OFDM code

hi
iam doing ofdm-cdma matlab code.
the problem when i simulate for 2 users i get the recieved data wrong or when try to simulate using raylighy channels. i cant decide what is wrong with the code if some one can help me
thanks

%% code
clc
clear all
close all
sf=64;
user1=randint(16, 1, 2)
user2=randint(16, 1, 2);
% Create BPSK mod-demod objects
P = 2; % modulation order
bpskmod = modem.pskmod('M', P, 'SymbolOrder', 'Gray');
bpskdemod = modem.pskdemod(bpskmod);
user1tx = modulate(bpskmod, user1); % BPSK modulation
user2tx = modulate(bpskmod, user2);
user1_ofdm = ifft(user1tx,16);
user2_ofdm = ifft(user2tx,16);
pn1 = [1; -1; 1; -1; 1; 1; 1; -1];
pn2 = [-1; 1; -1; 1; -1; -1; -1; 1];
user1spread = rectpulse(user1_ofdm, sf);
user2spread = rectpulse(user2_ofdm, sf);
user1pn = rectpulse(pn1, 2*sf);
user2pn = rectpulse(pn2, 2*sf);
tx1 = user1spread .* user1pn;
tx2 = user2spread .* user2pn;
rec = (tx1+tx2);
user1rec = rec .* user1pn;
user1down = intdump (user1rec, sf);
user1_fft = fft (user1down, 16);
user1rx = demodulate(bpskdemod, user1down)
 

Communications_Engineer

Advanced Member level 3
Joined
Oct 10, 2008
Messages
895
Helped
179
Reputation
358
Reaction score
105
Trophy points
1,323
Location
Sindh, Pakistan
Activity points
5,542
CDMA-OFDM code

the pn sequences you are using seem to be antipodal rather than orthogonal. Thats where the problem is. You cannot properly multiplex with non-orthogonal codes

Try Walsh sequences, it will work

Added after 55 seconds:

look thats the most obvious mistake, I haven't really gone through it, so if every thing else is fine, then it will work

Added after 42 seconds:

If you have any more questions, post 'em here
 

Aya2002

Advanced Member level 4
Joined
Dec 12, 2006
Messages
1,142
Helped
184
Reputation
376
Reaction score
118
Trophy points
1,343
Location
Iraq
Activity points
8,019
CDMA-OFDM code

Communications_Engineer said:
the pn sequences you are using seem to be antipodal rather than orthogonal. Thats where the problem is. You cannot properly multiplex with non-orthogonal codes

Try Walsh sequences, it will work

Added after 55 seconds:

look thats the most obvious mistake, I haven't really gone through it, so if every thing else is fine, then it will work

Added after 42 seconds:

If you have any more questions, post 'em here

I agree with you, the codes are not orthogonal, i suggest to use the walsh-hadamard code,

in Matlab it is only this command:

hadamard(N)

where N = 2, 4, 8, 16, 32, and so on

Added after 3 hours 35 minutes:

see this example:

h=hadamard(8)

h =

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
 

moneer

Newbie level 5
Joined
Dec 22, 2009
Messages
10
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Jordan
Activity points
1,481
Re: CDMA-OFDM code

thank you for replaying
I tried hadamard code but the result is still the same

%% modified code
clc
clear all
close all
sf=64; %spreading factor
user1=randint(1, 16, 2)
user2=randint(1, 16, 2);
% Create BPSK mod-demod objects
P = 2; % modulation order
bpskmod = modem.pskmod('M', P, 'SymbolOrder', 'Gray');
bpskdemod = modem.pskdemod(bpskmod);
user1tx1 = modulate(bpskmod, user1); % BPSK modulation
user2tx1 = modulate(bpskmod, user2); % BPSK modulation
user1tx = reshape(user1tx1, length(user1tx1), 1);
user2tx = reshape(user2tx1, length(user2tx1), 1);
user1_ofdm1 = ifft(user1tx,16);
user2_ofdm1 = ifft(user2tx,16);
user1_ofdm = reshape(user1_ofdm1, 1, length(user1_ofdm1));
user2_ofdm = reshape(user2_ofdm1, 1, length(user2_ofdm1));
h=hadamard( 8 ) ;
pn1 = h(1, : ) ;
pn2 = h(2, : ) ;
user1spread = rectpulse(user1_ofdm, sf);
user2spread = rectpulse(user2_ofdm, sf);
user1pn = rectpulse(pn1, 2*sf);
user2pn = rectpulse(pn2, 2*sf);
tx1 = user1spread .* user1pn;
tx2 = user2spread .* user2pn;
rec = awgn(tx1+tx2, 10);
user1rec = rec .* user1pn;
user1down = intdump (user1rec, sf);
user1_fft = fft(user1down, 16);
user1rx = demodulate(bpskdemod, user1_fft)
user2rec = rec .* user2pn ;
user2down = intdump(user2rec, sf) ;
user2_fft = fft(user2down, 16) ;
user2
user2rec= demodulate(bpskdemod, user2_fft)
 

Aya2002

Advanced Member level 4
Joined
Dec 12, 2006
Messages
1,142
Helped
184
Reputation
376
Reaction score
118
Trophy points
1,343
Location
Iraq
Activity points
8,019
CDMA-OFDM code

i think it is not correct to use the function "rectpulse" to perform the spreading operation, i used to use the finction "kron", i have about zero BER when i use this function.
try it.

Regards
 

moneer

Newbie level 5
Joined
Dec 22, 2009
Messages
10
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Jordan
Activity points
1,481
Re: CDMA-OFDM code

thank you again
the problem in my code was using the ifft and fft function for OFDM,OFDM need alot more work so i removed them untill i do it complete.
the program work fine with AWGN channels but the problem now that when i insert rayleigh fading channel i get the signal wrong
%% code with rayleigh channel
clc
clear all
close all
sf=128; %spreading factor
user1=randint(1, 16, 2)
user2=randint(1, 16, 2);
% Create BPSK mod-demod objects
P = 2; % modulation order
bpskmod = modem.pskmod('M', P, 'SymbolOrder', 'Gray');
bpskdemod = modem.pskdemod(bpskmod);
user1tx1 = modulate(bpskmod, user1); % BPSK modulation
user2tx1 = modulate(bpskmod, user2); % BPSK modulation
h=hadamard( 128 ) ;
pn1 = h(1, : ) ;
pn2 = h(2, : ) ;
user1spread = rectpulse(user1tx1, sf);
user2spread = rectpulse(user2tx1, sf);
user1pn = repmat(pn1, 1, 16);
user2pn = repmat(pn2, 1, 16);
tx1 = user1spread .* user1pn;
tx2 = user2spread .* user2pn;
V=0.001*sqrt(0.5)*(randn(1,2048)+1i*randn(1,2048));
rec = awgn((tx1.*V + tx1.*V ),10);
user1rec = rec .* user1pn;
user1down = intdump (user1rec, sf);
user1rx = demodulate(bpskdemod, user1down)
user2rec = rec .* user2pn;
user2down = intdump(user2rec, sf);
user2
user2rx = demodulate(bpskdemod, user2down)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top