Skip to content

Commit 520f1c8

Browse files
committed
Adding first version for multipath channel model support
Adding methods to generate rayleigh channel correlated in time domain (Jake spectrum) Adding method to emulate various multipath channel models Adding example with minimal OFDM transceiver Update documentation
1 parent 6df7dad commit 520f1c8

6 files changed

Lines changed: 617 additions & 2 deletions

File tree

docs/src/base.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Depth = 1
2424

2525
```@autodocs
2626
Modules = [DigitalComm]
27-
Pages = ["addNoise.jl"]
27+
Pages = ["Channel/addNoise.jl","Channel/rayleighChan.jl","Channel/getChannel.jl"]
2828
Order = [:function, :type]
2929
Depth = 1
3030
```
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# --- testingChannelApplication.jl
2+
# ---
3+
# Description
4+
# Testing how wo apply time varying channel model
5+
# ---
6+
# Syntax
7+
# include("testingChannelApplication.jl");
8+
# ---
9+
# v 1.0 - Robin Gerzaguet.
10+
11+
12+
module example_multipathChannel
13+
14+
# ----------------------------------------------------
15+
# --- Modules
16+
# ----------------------------------------------------
17+
# --- External
18+
using Plots
19+
using Printf
20+
using DSP
21+
using FFTW
22+
# --- Custom
23+
using DigitalComm
24+
25+
# ----------------------------------------------------
26+
## --- Functions
27+
# ----------------------------------------------------
28+
# --- Tx scheme
29+
function minimalPhy(nbSymb,mcs,ofdm)
30+
# Minimal transmitter scheme
31+
nbSubcarriers = length(ofdm.allocatedSubcarriers); # Subcarrier length
32+
nbBits = Int(nbSymb * nbSubcarriers * log2(mcs)); # nbBits
33+
bitSeq = genBitSequence(nbBits); # Binary sequence
34+
qamSeq = bitMappingQAM(mcs,bitSeq); # QAM generation
35+
qamMat = reshape(qamSeq,nbSubcarriers,nbSymb); # QAM matrix
36+
sigId = genSig(qamMat,ofdm); # OFDM signal
37+
return sigId;
38+
end
39+
function zeroPad(x,n)
40+
if n > length(x)
41+
out = [x;zeros(n-length(x))];
42+
else
43+
out = x;
44+
end
45+
return out;
46+
end
47+
# --- Receiver equalizer
48+
function minimalEqualizer(qamRx,ofdm,strucChan)
49+
# Simple ZF equalisation scheme:
50+
qamEq = zeros(Complex{Float64},size(qamRx));
51+
firAll = zeros(Complex{Float64},ofdm.nFFT,size(qamRx,2));
52+
for iN = 1 : 1 : size(qamRx,2)
53+
# --- Getting all channel samples in current symbol
54+
# We get a nFFT x nbTaps matrix (all channel taps in current symbol)
55+
# We will consider that channel is constant, and that channel of interest
56+
# is at the middle of the OFDM symbol
57+
if Bool(strucChan.timeVarying)
58+
currChan = strucChan.cir[(iN-1)*(ofdm.nFFT+ofdm.nCP) + ofdm.nCP + ofdm.nFFT÷2,:];
59+
else
60+
# COnstant FIR
61+
currChan = strucChan.cir;
62+
end
63+
# Switch to frequency domain
64+
firFreq = fft(zeroPad(currChan,ofdm.nFFT));
65+
qamEq[:,iN] = qamRx[:,iN] ./ firFreq[ofdm.allocatedSubcarriers];
66+
firAll[:,iN] = firFreq;
67+
end
68+
return qamEq,firAll;
69+
end
70+
71+
function plotFIR(fir,ofdm,samplingFreq)
72+
# --- Calculate freq axis
73+
freqAx = (((0:1:ofdm.nFFT-1) ./ ofdm.nFFT) .- 0.5) .* samplingFreq;
74+
firC = circshift(10*log10.(abs2.(fir)), ofdm.nFFT ÷2);
75+
pObj = plot(freqAx,firC[:,1],label="First Channel");
76+
plot!(pObj,freqAx,firC[:,end],label="Last Channel");
77+
xlabel!("Frequency [Hz]");
78+
ylabel!("Channel magnitude");
79+
return pObj;
80+
end
81+
82+
83+
function main()
84+
# ----------------------------------------------------
85+
# --- Parameters
86+
# ----------------------------------------------------
87+
sizeFFT = 1024;
88+
carrierFreq = 5.2e9;
89+
speed = 1300;
90+
samplingFreq = 15.36e6;
91+
allocatedSubcarriers= getLTEAlloc(sizeFFT);
92+
93+
# ----------------------------------------------------
94+
# --- Minimal Phy
95+
# ----------------------------------------------------
96+
# --- Init OFDM structure
97+
ofdm = initOFDM(
98+
sizeFFT, # --- nFFT : FFT size
99+
72, # --- nCP : CP size
100+
allocatedSubcarriers, # --- allocatedSubcarriers : Subcarrier allocation
101+
);
102+
# --- Init parameters
103+
sigId = minimalPhy(14,4,ofdm);
104+
# ----------------------------------------------------
105+
# --- Multipath Channel
106+
# ----------------------------------------------------
107+
# --- profile
108+
profile = "etu";
109+
# --- Channel object
110+
channelObj = initChannel(profile,carrierFreq,samplingFreq,speed);
111+
# --- Channel instance
112+
strucChan0 = getChannel(length(sigId),channelObj,-1);
113+
# ----------------------------------------------------
114+
# --- Channel application
115+
# ----------------------------------------------------
116+
sigChan = applyChannel(sigId,strucChan0);
117+
qamRx = ofdmSigDecode(sigChan,ofdm);
118+
scatter(qamRx[:])
119+
# ----------------------------------------------------
120+
# --- Setting a minimal equalizer
121+
# ----------------------------------------------------
122+
# --- Assuming a perfect CSI
123+
qamEq,firFreq = minimalEqualizer(qamRx,ofdm,strucChan0)
124+
#
125+
pObj = scatter(qamRx[:],xlims=(-1,1),ylims=(-1,1),label="before eq.");
126+
scatter!(pObj,qamEq[:],xlims=(-1,1),ylims=(-1,1),label="after eq.");
127+
display(pObj);
128+
#
129+
pObj2 = plotFIR(firFreq,ofdm,samplingFreq);
130+
display(pObj2);
131+
132+
133+
end
134+
135+
end
File renamed without changes.

0 commit comments

Comments
 (0)