Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Python Pluto DPD
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
Python Pluto DPD
Commits
c0b98e82
Commit
c0b98e82
authored
Mar 22, 2024
by
Thomas Gambier
🚴🏼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autopep8
parent
88e24d90
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
73 deletions
+90
-73
commonFunctions.py
commonFunctions.py
+34
-28
pyPlutoDPD.py
pyPlutoDPD.py
+56
-45
No files found.
commonFunctions.py
View file @
c0b98e82
...
@@ -4,6 +4,7 @@ from scipy.signal import get_window
...
@@ -4,6 +4,7 @@ from scipy.signal import get_window
from
scipy.fft
import
fft
,
fftshift
from
scipy.fft
import
fft
,
fftshift
from
scipy
import
signal
from
scipy
import
signal
def
nmse
(
xMes
,
xEst
):
def
nmse
(
xMes
,
xEst
):
"""
"""
Function to compute the NMSE in time domain
Function to compute the NMSE in time domain
...
@@ -14,6 +15,7 @@ def nmse(xMes, xEst):
...
@@ -14,6 +15,7 @@ def nmse(xMes, xEst):
######################################
######################################
def
algoLMS
(
PPHI
,
out
,
start
,
nSample
):
def
algoLMS
(
PPHI
,
out
,
start
,
nSample
):
"""
"""
Classical LMS Algorithm
Classical LMS Algorithm
...
@@ -33,8 +35,8 @@ def algoLMS(PPHI, out, start, nSample):
...
@@ -33,8 +35,8 @@ def algoLMS(PPHI, out, start, nSample):
########################################
########################################
def
computeFFT
(
x
,
fs
,
win
):
def
computeFFT
(
x
,
fs
,
win
):
"""
"""
Perform FFT on x
Perform FFT on x
x : signal
x : signal
...
@@ -52,13 +54,14 @@ def computeFFT(x, fs, win):
...
@@ -52,13 +54,14 @@ def computeFFT(x, fs, win):
fftSig
=
fft
(
x
*
w
)
/
fft_block_size
fftSig
=
fft
(
x
*
w
)
/
fft_block_size
fftAbs
=
np
.
abs
(
fftSig
)
fftAbs
=
np
.
abs
(
fftSig
)
freq
=
(
np
.
arange
(
0
,
N
)
-
N
/
2
)
*
fs
/
fft_block_size
freq
=
(
np
.
arange
(
0
,
N
)
-
N
/
2
)
*
fs
/
fft_block_size
freq
=
fftshift
(
freq
)
# Shift zero frequency component to center of spectrum
# Shift zero frequency component to center of spectrum
freq
=
fftshift
(
freq
)
return
fftAbs
,
freq
return
fftAbs
,
freq
#########################################
#########################################
def
toPlotSpectrum
(
x
,
fs
,
win
,
Nblocks
,
interval
):
def
toPlotSpectrum
(
x
,
fs
,
win
,
Nblocks
,
interval
):
"""
"""
To plot the spectrum
To plot the spectrum
x : signal
x : signal
...
@@ -90,15 +93,14 @@ def toPlotSpectrum(x, fs, win, Nblocks, interval):
...
@@ -90,15 +93,14 @@ def toPlotSpectrum(x, fs, win, Nblocks, interval):
else
:
# spectre entre [-fs/2 fs/2]
else
:
# spectre entre [-fs/2 fs/2]
pxx
=
np
.
abs
(
fft_input
)
pxx
=
np
.
abs
(
fft_input
)
pxx
=
fftshift
(
pxx
)
pxx
=
fftshift
(
pxx
)
freq
=
(
np
.
arange
(
0
,
fft_block_size
)
-
fft_block_size
/
2
)
*
fs
/
fft_block_size
freq
=
(
np
.
arange
(
0
,
fft_block_size
)
-
fft_block_size
/
2
)
*
fs
/
fft_block_size
return
pxx
,
freq
return
pxx
,
freq
#################################################
#################################################
def
corelation
(
tx
,
rx
,
osf
):
def
corelation
(
tx
,
rx
,
osf
):
"""
"""
Performs tx/rx synchronization and signal alignement
Performs tx/rx synchronization and signal alignement
tx : transmitted signal
tx : transmitted signal
...
@@ -130,7 +132,8 @@ def corelation(tx, rx, osf):
...
@@ -130,7 +132,8 @@ def corelation(tx, rx, osf):
#################################################
#################################################
def
xcorr
(
x
,
y
):
def
xcorr
(
x
,
y
):
"""
"""
Perform Cross-Correlation on x and y
Perform Cross-Correlation on x and y
x : 1st signal
x : 1st signal
...
@@ -148,9 +151,10 @@ def xcorr(x,y):
...
@@ -148,9 +151,10 @@ def xcorr(x,y):
#################################################
#################################################
def
coarsePhaseCorrection
(
x
,
y
,
osf
):
def
coarsePhaseCorrection
(
x
,
y
,
osf
):
#
#
Coarse phase correction using the preambule (zeroing AM/PM)
# Coarse phase correction using the preambule (zeroing AM/PM)
preambule
=
5
*
80
# 2 STF + 2 LTF + 1 SIG
preambule
=
5
*
80
# 2 STF + 2 LTF + 1 SIG
n
=
int
(
osf
*
preambule
)
n
=
int
(
osf
*
preambule
)
...
@@ -163,8 +167,8 @@ def coarsePhaseCorrection(x, y, osf):
...
@@ -163,8 +167,8 @@ def coarsePhaseCorrection(x, y, osf):
##################################################
##################################################
def
amam_ampm_plot
(
tx
,
ty
):
def
amam_ampm_plot
(
tx
,
ty
):
"""
"""
Perform AM/AM and AM/PM curves
Perform AM/AM and AM/PM curves
ttx : transmitted signal
ttx : transmitted signal
...
@@ -179,13 +183,14 @@ def amam_ampm_plot(tx, ty):
...
@@ -179,13 +183,14 @@ def amam_ampm_plot(tx, ty):
plt
.
xlabel
(
'Normalized input'
)
plt
.
xlabel
(
'Normalized input'
)
plt
.
ylabel
(
'Normalized output'
)
plt
.
ylabel
(
'Normalized output'
)
plt
.
subplot
(
212
)
plt
.
subplot
(
212
)
plt
.
plot
(
np
.
abs
(
tx
),
np
.
angle
(
np
.
conj
(
tx
)
*
ty
),
'.'
)
plt
.
plot
(
np
.
abs
(
tx
),
np
.
angle
(
np
.
conj
(
tx
)
*
ty
),
'.'
)
plt
.
title
(
'Dynamical AM/PM'
)
plt
.
title
(
'Dynamical AM/PM'
)
plt
.
xlabel
(
'Normalized input'
)
plt
.
xlabel
(
'Normalized input'
)
plt
.
ylabel
(
'Dephase (deg)'
)
plt
.
ylabel
(
'Dephase (deg)'
)
###################################################
###################################################
def
identif_dpd_GMP
(
x
,
y
,
dpdModel
):
def
identif_dpd_GMP
(
x
,
y
,
dpdModel
):
dpdModel
=
estimGMPopt
(
y
,
x
,
dpdModel
)
dpdModel
=
estimGMPopt
(
y
,
x
,
dpdModel
)
...
@@ -195,8 +200,8 @@ def identif_dpd_GMP(x, y, dpdModel):
...
@@ -195,8 +200,8 @@ def identif_dpd_GMP(x, y, dpdModel):
#################################################
#################################################
def
estimGMPopt
(
x
,
y
,
gmpModel
):
def
estimGMPopt
(
x
,
y
,
gmpModel
):
"""
"""
To estimate GMP coefficients
To estimate GMP coefficients
x : reference signal
x : reference signal
...
@@ -229,7 +234,8 @@ def estimGMPopt(x, y, gmpModel):
...
@@ -229,7 +234,8 @@ def estimGMPopt(x, y, gmpModel):
for
m
in
range
(
1
,
Mb
+
1
):
for
m
in
range
(
1
,
Mb
+
1
):
it1
=
np
.
concatenate
((
np
.
zeros
(
l
+
m
),
x
[:
nSample
-
l
-
m
]))
it1
=
np
.
concatenate
((
np
.
zeros
(
l
+
m
),
x
[:
nSample
-
l
-
m
]))
for
k
in
range
(
1
,
Kb
+
1
):
for
k
in
range
(
1
,
Kb
+
1
):
PPHI
[:,
La
*
Ka
+
(
Lb
*
Mb
*
(
k
-
1
))
+
(
Mb
*
l
)
+
(
m
-
1
)]
=
(
np
.
abs
(
it1
))
**
k
*
it2
PPHI
[:,
La
*
Ka
+
(
Lb
*
Mb
*
(
k
-
1
))
+
(
Mb
*
l
)
+
(
m
-
1
)]
=
(
np
.
abs
(
it1
))
**
k
*
it2
for
l
in
range
(
Lc
):
for
l
in
range
(
Lc
):
it2
=
np
.
concatenate
((
np
.
zeros
(
l
),
x
[:
nSample
-
l
]))
it2
=
np
.
concatenate
((
np
.
zeros
(
l
),
x
[:
nSample
-
l
]))
...
@@ -239,7 +245,8 @@ def estimGMPopt(x, y, gmpModel):
...
@@ -239,7 +245,8 @@ def estimGMPopt(x, y, gmpModel):
else
:
else
:
it1
=
np
.
concatenate
((
np
.
zeros
(
m
-
l
),
x
[
m
-
l
:
nSample
]))
*
0
it1
=
np
.
concatenate
((
np
.
zeros
(
m
-
l
),
x
[
m
-
l
:
nSample
]))
*
0
for
k
in
range
(
1
,
Kc
+
1
):
for
k
in
range
(
1
,
Kc
+
1
):
PPHI
[:,
La
*
Ka
+
Lb
*
Kb
*
Mb
+
(
Lc
*
Mc
*
(
k
-
1
))
+
(
Mc
*
l
)
+
(
m
-
1
)]
=
(
np
.
abs
(
it1
))
**
k
*
it2
PPHI
[:,
La
*
Ka
+
Lb
*
Kb
*
Mb
+
(
Lc
*
Mc
*
(
k
-
1
))
+
(
Mc
*
l
)
+
(
m
-
1
)]
=
(
np
.
abs
(
it1
))
**
k
*
it2
start
=
0
start
=
0
gmpModel
[
'coefGMP'
],
gmpModel
[
'H'
]
=
algoLMS
(
PPHI
,
y
,
start
,
nSample
)
gmpModel
[
'coefGMP'
],
gmpModel
[
'H'
]
=
algoLMS
(
PPHI
,
y
,
start
,
nSample
)
...
@@ -249,8 +256,8 @@ def estimGMPopt(x, y, gmpModel):
...
@@ -249,8 +256,8 @@ def estimGMPopt(x, y, gmpModel):
######################################################
######################################################
def
simGMPopt
(
x
,
gmpModel
):
def
simGMPopt
(
x
,
gmpModel
):
"""
"""
Simulates GMP model
Simulates GMP model
x : input signal (stimulus)
x : input signal (stimulus)
...
@@ -282,7 +289,8 @@ def simGMPopt(x, gmpModel):
...
@@ -282,7 +289,8 @@ def simGMPopt(x, gmpModel):
for
m
in
range
(
1
,
Mb
+
1
):
for
m
in
range
(
1
,
Mb
+
1
):
it1
=
np
.
concatenate
((
np
.
zeros
(
l
+
m
),
x
[:
nSample
-
l
-
m
]))
it1
=
np
.
concatenate
((
np
.
zeros
(
l
+
m
),
x
[:
nSample
-
l
-
m
]))
for
k
in
range
(
1
,
Kb
+
1
):
for
k
in
range
(
1
,
Kb
+
1
):
PPHI
[:,
La
*
Ka
+
(
Lb
*
Mb
*
(
k
-
1
))
+
(
Mb
*
l
)
+
(
m
-
1
)]
=
(
np
.
abs
(
it1
))
**
k
*
it2
PPHI
[:,
La
*
Ka
+
(
Lb
*
Mb
*
(
k
-
1
))
+
(
Mb
*
l
)
+
(
m
-
1
)]
=
(
np
.
abs
(
it1
))
**
k
*
it2
for
l
in
range
(
Lc
):
for
l
in
range
(
Lc
):
it2
=
np
.
concatenate
((
np
.
zeros
(
l
),
x
[:
nSample
-
l
]))
it2
=
np
.
concatenate
((
np
.
zeros
(
l
),
x
[:
nSample
-
l
]))
...
@@ -292,7 +300,8 @@ def simGMPopt(x, gmpModel):
...
@@ -292,7 +300,8 @@ def simGMPopt(x, gmpModel):
else
:
else
:
it1
=
np
.
concatenate
((
np
.
zeros
(
m
-
l
),
x
[
m
-
l
:
nSample
]))
*
0
it1
=
np
.
concatenate
((
np
.
zeros
(
m
-
l
),
x
[
m
-
l
:
nSample
]))
*
0
for
k
in
range
(
1
,
Kc
+
1
):
for
k
in
range
(
1
,
Kc
+
1
):
PPHI
[:,
La
*
Ka
+
Lb
*
Kb
*
Mb
+
(
Lc
*
Mc
*
(
k
-
1
))
+
(
Mc
*
l
)
+
(
m
-
1
)]
=
(
np
.
abs
(
it1
))
**
k
*
it2
PPHI
[:,
La
*
Ka
+
Lb
*
Kb
*
Mb
+
(
Lc
*
Mc
*
(
k
-
1
))
+
(
Mc
*
l
)
+
(
m
-
1
)]
=
(
np
.
abs
(
it1
))
**
k
*
it2
outEst
=
np
.
zeros
(
nSample
,
dtype
=
np
.
complex128
)
outEst
=
np
.
zeros
(
nSample
,
dtype
=
np
.
complex128
)
outEst
=
PPHI
@
gmpModel
[
'coefGMP'
]
outEst
=
PPHI
@
gmpModel
[
'coefGMP'
]
...
@@ -300,6 +309,3 @@ def simGMPopt(x, gmpModel):
...
@@ -300,6 +309,3 @@ def simGMPopt(x, gmpModel):
return
outEst
return
outEst
##################################################
##################################################
pyPlutoDPD.py
View file @
c0b98e82
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
# In[47]:
# In[47]:
from
commonFunctions
import
*
# XLIM used functions
import
numpy
as
np
import
numpy
as
np
import
adi
# API for Adalm-Pluto
import
adi
# API for Adalm-Pluto
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
...
@@ -50,9 +51,6 @@ start = time.time() # start time to measure the execution time
...
@@ -50,9 +51,6 @@ start = time.time() # start time to measure the execution time
# In[48]:
# In[48]:
from
commonFunctions
import
*
# XLIM used functions
# ## Transmission without DPD
# ## Transmission without DPD
# ### Transmit original samples
# ### Transmit original samples
...
@@ -69,8 +67,8 @@ osf = 3
...
@@ -69,8 +67,8 @@ osf = 3
filePreambule
=
"preambule_BW20osf"
+
str
(
osf
)
+
"_single.bin"
filePreambule
=
"preambule_BW20osf"
+
str
(
osf
)
+
"_single.bin"
fileRx
=
"lteBW20osf"
+
str
(
osf
)
+
"_single.bin"
fileRx
=
"lteBW20osf"
+
str
(
osf
)
+
"_single.bin"
sample_rate
=
61.44e6
# 61.44e6 46.08e6 30.72e6 23.04e6 11.52e6
sample_rate
=
61.44e6
# 61.44e6 46.08e6 30.72e6 23.04e6 11.52e6
#fileRx = "wlanBW20osf" + str(osf) + "_single.bin"
#
fileRx = "wlanBW20osf" + str(osf) + "_single.bin"
#sample_rate = 60e6
#
sample_rate = 60e6
fp
=
open
(
path
+
filePreambule
,
'rb'
)
fp
=
open
(
path
+
filePreambule
,
'rb'
)
preambule
=
np
.
fromfile
(
fp
,
dtype
=
np
.
complex64
)
preambule
=
np
.
fromfile
(
fp
,
dtype
=
np
.
complex64
)
...
@@ -107,10 +105,11 @@ sdr.sample_rate = sample_rate
...
@@ -107,10 +105,11 @@ sdr.sample_rate = sample_rate
freq
=
int
(
3650
)
freq
=
int
(
3650
)
win_fft
=
'flattop'
# The used window for FFT ans spectrum plot
win_fft
=
'flattop'
# The used window for FFT ans spectrum plot
initialGain
=
int
(
0
)
# Here, the initial gain of TX is set to the minimal value for safety
# Here, the initial gain of TX is set to the minimal value for safety
initialGain
=
int
(
0
)
sdr
.
tx_rf_bandwidth
=
int
(
sample_rate
)
# filter cutoff
sdr
.
tx_rf_bandwidth
=
int
(
sample_rate
)
# filter cutoff
sdr
.
tx_lo
=
freq
*
10
**
6
sdr
.
tx_lo
=
freq
*
10
**
6
sdr
.
tx_hardwaregain_chan0
=
initialGain
#
sdr
.
tx_hardwaregain_chan0
=
initialGain
sdr
.
tx_destroy_buffer
()
# Stop transmitting for safe
sdr
.
tx_destroy_buffer
()
# Stop transmitting for safe
sdr
.
tx_cyclic_buffer
=
True
# Enable cyclic buffers
sdr
.
tx_cyclic_buffer
=
True
# Enable cyclic buffers
...
@@ -128,9 +127,10 @@ while (valid):
...
@@ -128,9 +127,10 @@ while (valid):
valid
=
input
(
"1 to set txGain || 0 to compute DPD : "
)
valid
=
input
(
"1 to set txGain || 0 to compute DPD : "
)
valid
=
bool
(
int
(
valid
))
valid
=
bool
(
int
(
valid
))
if
valid
==
True
:
if
valid
==
True
:
value
=
input
(
f"enter new txGain (Actual txGain =
{
sdr
.
tx_hardwaregain_chan0
}
) : "
)
value
=
input
(
f"enter new txGain (Actual txGain =
{
sdr
.
tx_hardwaregain_chan0
}
) : "
)
gain
=
float
(
value
)
gain
=
float
(
value
)
if
gain
<
safetyGain
:
#
# Gain limitation for safety
if
gain
<
safetyGain
:
# Gain limitation for safety
sdr
.
tx_hardwaregain_chan0
=
gain
sdr
.
tx_hardwaregain_chan0
=
gain
else
:
else
:
sdr
.
tx_hardwaregain_chan0
=
safetyGain
sdr
.
tx_hardwaregain_chan0
=
safetyGain
...
@@ -145,7 +145,8 @@ sdr.rx_lo = sdr.tx_lo
...
@@ -145,7 +145,8 @@ sdr.rx_lo = sdr.tx_lo
sdr
.
rx_rf_bandwidth
=
sdr
.
tx_rf_bandwidth
sdr
.
rx_rf_bandwidth
=
sdr
.
tx_rf_bandwidth
sdr
.
rx_buffer_size
=
3
*
num_samps
# 3 times to capture one sequence
sdr
.
rx_buffer_size
=
3
*
num_samps
# 3 times to capture one sequence
sdr
.
gain_control_mode_chan0
=
'manual'
sdr
.
gain_control_mode_chan0
=
'manual'
sdr
.
rx_hardwaregain_chan0
=
8
# set the receive gain, but be careful not to saturate the ADC
# set the receive gain, but be careful not to saturate the ADC
sdr
.
rx_hardwaregain_chan0
=
8
# Clear buffer just to be safe
# Clear buffer just to be safe
...
@@ -153,7 +154,7 @@ sdr.rx_hardwaregain_chan0 = 8 # set the receive gain, but be careful not to satu
...
@@ -153,7 +154,7 @@ sdr.rx_hardwaregain_chan0 = 8 # set the receive gain, but be careful not to satu
# In[54]:
# In[54]:
for
i
in
range
(
0
,
10
):
for
i
in
range
(
0
,
10
):
raw_data
=
sdr
.
rx
()
raw_data
=
sdr
.
rx
()
...
@@ -164,8 +165,9 @@ for i in range (0, 10):
...
@@ -164,8 +165,9 @@ for i in range (0, 10):
rx_samples
=
sdr
.
rx
()
rx_samples
=
sdr
.
rx
()
avg_pwr
=
np
.
mean
(
np
.
abs
(
rx_samples
/
coeff
)
**
2
)
avg_pwr
=
np
.
mean
(
np
.
abs
(
rx_samples
/
coeff
)
**
2
)
avg_pwr_dB
=
round
(
10
*
np
.
log10
(
avg_pwr
),
2
)
avg_pwr_dB
=
round
(
10
*
np
.
log10
(
avg_pwr
),
2
)
print
(
"check_rx = "
,
avg_pwr_dB
,
": Best in -30 +/- 5. Else, adjust the rx_hardwaregain"
)
print
(
"check_rx = "
,
avg_pwr_dB
,
": Best in -30 +/- 5. Else, adjust the rx_hardwaregain"
)
# Synchronization and coarse phase correction using the preambule (zeroing AM/PM)
# Synchronization and coarse phase correction using the preambule (zeroing AM/PM)
...
@@ -173,13 +175,15 @@ print("check_rx = ", avg_pwr_dB, ": Best in -30 +/- 5. Else, adjust the rx_hardw
...
@@ -173,13 +175,15 @@ print("check_rx = ", avg_pwr_dB, ": Best in -30 +/- 5. Else, adjust the rx_hardw
# In[56]:
# In[56]:
[
paIn
,
paOut
]
=
corelation
(
samples
,
rx_samples
,
osf
)
# Synchronization using cross-corelation
# Synchronization using cross-corelation
[
paIn
,
paOut
]
=
corelation
(
samples
,
rx_samples
,
osf
)
# In[57]:
# In[57]:
paOut
=
coarsePhaseCorrection
(
paIn
,
paOut
,
osf
)
# Coarse phase correction using the preambule (zeroing AM/PM)
# Coarse phase correction using the preambule (zeroing AM/PM)
paOut
=
coarsePhaseCorrection
(
paIn
,
paOut
,
osf
)
paIn
/=
np
.
max
(
np
.
abs
(
paIn
))
# scaling
paIn
/=
np
.
max
(
np
.
abs
(
paIn
))
# scaling
paOut
/=
np
.
max
(
np
.
abs
(
paOut
))
# scaling
paOut
/=
np
.
max
(
np
.
abs
(
paOut
))
# scaling
...
@@ -193,7 +197,8 @@ paOut /= np.max(np.abs(paOut)) # scaling
...
@@ -193,7 +197,8 @@ paOut /= np.max(np.abs(paOut)) # scaling
plt
.
figure
(
10
)
plt
.
figure
(
10
)
plt
.
plot
((
f
+
freq
)
/
1e6
,
10
*
np
.
log10
(
pxxWithout
))
plt
.
plot
((
f
+
freq
)
/
1e6
,
10
*
np
.
log10
(
pxxWithout
))
plt
.
grid
()
plt
.
grid
()
plt
.
xlabel
(
'Frequency (MHz)'
);
plt
.
ylabel
(
'Spectrum'
)
plt
.
xlabel
(
'Frequency (MHz)'
)
plt
.
ylabel
(
'Spectrum'
)
plt
.
legend
([
'Original signal'
])
plt
.
legend
([
'Original signal'
])
plt
.
show
()
plt
.
show
()
...
@@ -220,13 +225,15 @@ plt.show()
...
@@ -220,13 +225,15 @@ plt.show()
dpdModel
=
{
'fs'
:
sample_rate
}
dpdModel
=
{
'fs'
:
sample_rate
}
[
Ka
,
La
,
Kb
,
Lb
,
Mb
,
Kc
,
Lc
,
Mc
]
=
[
7
,
1
,
0
,
1
,
1
,
0
,
1
,
1
]
# set the dpd orders and memory depths
# set the dpd orders and memory depths
dpdModel
[
'parameters'
]
=
{
'Ka'
:
Ka
,
'La'
:
La
,
'Kb'
:
Kb
,
'Lb'
:
Lb
,
'Mb'
:
Mb
,
'Kc'
:
Kc
,
'Lc'
:
Lc
,
'Mc'
:
Mc
};
[
Ka
,
La
,
Kb
,
Lb
,
Mb
,
Kc
,
Lc
,
Mc
]
=
[
7
,
1
,
0
,
1
,
1
,
0
,
1
,
1
]
dpdModel
[
'parameters'
]
=
{
'Ka'
:
Ka
,
'La'
:
La
,
'Kb'
:
Kb
,
'Lb'
:
Lb
,
'Mb'
:
Mb
,
'Kc'
:
Kc
,
'Lc'
:
Lc
,
'Mc'
:
Mc
}
gainATT
=
1
gainATT
=
1
dpdModel
=
identif_dpd_GMP
(
paIn
,
paOut
/
gainATT
,
dpdModel
)
dpdModel
=
identif_dpd_GMP
(
paIn
,
paOut
/
gainATT
,
dpdModel
)
print
(
"nmse of identification :"
,
np
.
round
(
dpdModel
[
'nmseTimedB'
],
2
),
" dB"
)
print
(
"nmse of identification :"
,
np
.
round
(
dpdModel
[
'nmseTimedB'
],
2
),
" dB"
)
dpdOutput
=
simGMPopt
(
paIn
,
dpdModel
)
# generate DPD signal
dpdOutput
=
simGMPopt
(
paIn
,
dpdModel
)
# generate DPD signal
dpdOutput
=
dpdOutput
/
np
.
max
(
np
.
abs
(
dpdOutput
))
dpdOutput
=
dpdOutput
/
np
.
max
(
np
.
abs
(
dpdOutput
))
...
@@ -253,9 +260,10 @@ while (valid):
...
@@ -253,9 +260,10 @@ while (valid):
valid
=
input
(
"1 to set txGain || 0 to compute DPD : "
)
valid
=
input
(
"1 to set txGain || 0 to compute DPD : "
)
valid
=
bool
(
int
(
valid
))
valid
=
bool
(
int
(
valid
))
if
valid
==
True
:
if
valid
==
True
:
value
=
input
(
f"enter new txGain (Actual txGain =
{
sdr
.
tx_hardwaregain_chan0
}
) : "
)
value
=
input
(
f"enter new txGain (Actual txGain =
{
sdr
.
tx_hardwaregain_chan0
}
) : "
)
gain
=
float
(
value
)
gain
=
float
(
value
)
if
gain
<
safetyGain
:
#
# Gain limitation for safety
if
gain
<
safetyGain
:
# Gain limitation for safety
sdr
.
tx_hardwaregain_chan0
=
gain
sdr
.
tx_hardwaregain_chan0
=
gain
else
:
else
:
sdr
.
tx_hardwaregain_chan0
=
safetyGain
sdr
.
tx_hardwaregain_chan0
=
safetyGain
...
@@ -271,8 +279,9 @@ while (valid):
...
@@ -271,8 +279,9 @@ while (valid):
rx_samples
=
sdr
.
rx
()
rx_samples
=
sdr
.
rx
()
avg_pwr
=
np
.
mean
(
np
.
abs
(
rx_samples
/
coeff
)
**
2
)
avg_pwr
=
np
.
mean
(
np
.
abs
(
rx_samples
/
coeff
)
**
2
)
avg_pwr_dB
=
round
(
10
*
np
.
log10
(
avg_pwr
),
2
)
avg_pwr_dB
=
round
(
10
*
np
.
log10
(
avg_pwr
),
2
)
print
(
"check_rx = "
,
avg_pwr_dB
,
": Best in -30 +/- 5. Else, adjust the rx_hardwaregain"
)
print
(
"check_rx = "
,
avg_pwr_dB
,
": Best in -30 +/- 5. Else, adjust the rx_hardwaregain"
)
# Synchronization of input and output
# Synchronization of input and output
...
@@ -315,7 +324,8 @@ plt.subplot(223)
...
@@ -315,7 +324,8 @@ plt.subplot(223)
plt
.
plot
(
np
.
real
(
paIn
)
-
np
.
real
(
paLin
))
plt
.
plot
(
np
.
real
(
paIn
)
-
np
.
real
(
paLin
))
plt
.
title
(
"Error in phase (I)"
)
plt
.
title
(
"Error in phase (I)"
)
plt
.
xlabel
(
"Samples"
)
plt
.
xlabel
(
"Samples"
)
plt
.
subplot
(
224
);
plt
.
plot
(
np
.
imag
(
paIn
)
-
np
.
imag
(
paLin
))
plt
.
subplot
(
224
)
plt
.
plot
(
np
.
imag
(
paIn
)
-
np
.
imag
(
paLin
))
plt
.
title
(
"Error in qudadrature (Q)"
)
plt
.
title
(
"Error in qudadrature (Q)"
)
plt
.
xlabel
(
"Samples"
)
plt
.
xlabel
(
"Samples"
)
plt
.
show
()
plt
.
show
()
...
@@ -330,7 +340,9 @@ plt.show()
...
@@ -330,7 +340,9 @@ plt.show()
plt
.
figure
(
10
)
plt
.
figure
(
10
)
plt
.
plot
((
f
+
freq
)
/
1e6
,
10
*
np
.
log10
(
pxxWith
))
plt
.
plot
((
f
+
freq
)
/
1e6
,
10
*
np
.
log10
(
pxxWith
))
plt
.
grid
()
plt
.
grid
()
plt
.
xlabel
(
'Frequency (MHz)'
);
plt
.
ylabel
(
'Spectrum'
);
plt
.
legend
([
'With DPD'
])
plt
.
xlabel
(
'Frequency (MHz)'
)
plt
.
ylabel
(
'Spectrum'
)
plt
.
legend
([
'With DPD'
])
plt
.
show
()
plt
.
show
()
...
@@ -356,5 +368,4 @@ print(f'Elapsed time : {elapsed:.2}ms')
...
@@ -356,5 +368,4 @@ print(f'Elapsed time : {elapsed:.2}ms')
for
i
in
dpdModel
[
'coefGMP'
]:
for
i
in
dpdModel
[
'coefGMP'
]:
print
(
np
.
round
(
i
,
3
))
print
(
np
.
round
(
i
,
3
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment