Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
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
0
Merge Requests
0
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
Michael Black
OpenXG-RAN
Commits
3007400b
Commit
3007400b
authored
Jan 07, 2016
by
Raymond Knopp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autodetection of UHD version for gain/bw scaling prior to 3.9.2
parent
54a21b63
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
20 deletions
+85
-20
targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
+73
-10
targets/RT/USER/lte-softmodem.c
targets/RT/USER/lte-softmodem.c
+3
-2
targets/RT/USER/lte-ue.c
targets/RT/USER/lte-ue.c
+9
-8
No files found.
targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
View file @
3007400b
...
...
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <uhd/version.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
...
...
@@ -304,27 +305,59 @@ int trx_usrp_stop(int card) {
rx_gain_calib_table_t
calib_table_b210
[]
=
{
{
3500000000.0
,
4
6
.0
},
{
3500000000.0
,
4
7
.0
},
{
2660000000.0
,
53.0
},
{
2300000000.0
,
54.0
},
{
1880000000.0
,
55.0
},
{
816000000.0
,
62.0
},
{
-
1
,
0
}};
rx_gain_calib_table_t
calib_table_b210_38
[]
=
{
{
3500000000.0
,
44.0
},
{
2660000000.0
,
49.8
},
{
2300000000.0
,
51.0
},
{
1880000000.0
,
53.0
},
{
816000000.0
,
57.0
},
{
-
1
,
0
}};
rx_gain_calib_table_t
calib_table_x310
[]
=
{
{
3500000000.0
,
77.0
},
{
2660000000.0
,
8
0
.0
},
{
2660000000.0
,
8
1
.0
},
{
2300000000.0
,
81.0
},
{
1880000000.0
,
82.0
},
{
816000000.0
,
85.0
},
{
-
1
,
0
}};
void
set_rx_gain_offset
(
openair0_config_t
*
openair0_cfg
,
int
chain_index
)
{
void
set_rx_gain_offset
(
openair0_config_t
*
openair0_cfg
,
int
chain_index
,
int
bw_gain_adjust
)
{
int
i
=
0
;
// loop through calibration table to find best adjustment factor for RX frequency
double
min_diff
=
6e9
,
diff
;
double
min_diff
=
6e9
,
diff
,
gain_adj
=
0.0
;
if
(
bw_gain_adjust
==
1
)
{
switch
((
int
)
openair0_cfg
[
0
].
sample_rate
)
{
case
30720000
:
break
;
case
23040000
:
gain_adj
=
1.25
;
break
;
case
15360000
:
gain_adj
=
3.0
;
break
;
case
7680000
:
gain_adj
=
6.0
;
break
;
case
3840000
:
gain_adj
=
9.0
;
break
;
case
1920000
:
gain_adj
=
12.0
;
break
;
default:
printf
(
"unknown sampling rate %d
\n
"
,(
int
)
openair0_cfg
[
0
].
sample_rate
);
exit
(
-
1
);
break
;
}
}
while
(
openair0_cfg
->
rx_gain_calib_table
[
i
].
freq
>
0
)
{
diff
=
fabs
(
openair0_cfg
->
rx_freq
[
chain_index
]
-
openair0_cfg
->
rx_gain_calib_table
[
i
].
freq
);
printf
(
"cal %d: freq %f, offset %f, diff %f
\n
"
,
...
...
@@ -333,7 +366,7 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index) {
openair0_cfg
->
rx_gain_calib_table
[
i
].
offset
,
diff
);
if
(
min_diff
>
diff
)
{
min_diff
=
diff
;
openair0_cfg
->
rx_gain_offset
[
chain_index
]
=
openair0_cfg
->
rx_gain_calib_table
[
i
].
offset
;
openair0_cfg
->
rx_gain_offset
[
chain_index
]
=
openair0_cfg
->
rx_gain_calib_table
[
i
].
offset
+
gain_adj
;
}
i
++
;
}
...
...
@@ -367,7 +400,12 @@ int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_
uhd
::
device_addrs_t
device_adds
=
uhd
::
device
::
find
(
args
);
size_t
i
;
printf
(
"Checking for USRPs
\n
"
);
int
vers
=
0
,
subvers
=
0
,
subsubvers
=
0
;
int
bw_gain_adjust
=
0
;
sscanf
(
uhd
::
get_version_string
().
c_str
(),
"%d.%d.%d"
,
&
vers
,
&
subvers
,
&
subsubvers
);
printf
(
"Checking for USRPs : UHD %s (%d.%d.%d)
\n
"
,
uhd
::
get_version_string
().
c_str
(),
vers
,
subvers
,
subsubvers
);
if
(
device_adds
.
size
()
==
0
)
{
...
...
@@ -388,6 +426,7 @@ int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_
}
printf
(
"Found USRP X300
\n
"
);
s
->
usrp
=
uhd
::
usrp
::
multi_usrp
::
make
(
args
);
// s->usrp->set_rx_subdev_spec(rx_subdev);
...
...
@@ -410,21 +449,29 @@ int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_
// from usrp_time_offset
openair0_cfg
[
0
].
samples_per_packet
=
2048
;
openair0_cfg
[
0
].
tx_sample_advance
=
15
;
openair0_cfg
[
0
].
tx_bw
=
20e6
;
openair0_cfg
[
0
].
rx_bw
=
20e6
;
openair0_cfg
[
0
].
tx_scheduling_advance
=
8
*
openair0_cfg
[
0
].
samples_per_packet
;
break
;
case
15360000
:
openair0_cfg
[
0
].
samples_per_packet
=
2048
;
openair0_cfg
[
0
].
tx_sample_advance
=
45
;
openair0_cfg
[
0
].
tx_bw
=
10e6
;
openair0_cfg
[
0
].
rx_bw
=
10e6
;
openair0_cfg
[
0
].
tx_scheduling_advance
=
5
*
openair0_cfg
[
0
].
samples_per_packet
;
break
;
case
7680000
:
openair0_cfg
[
0
].
samples_per_packet
=
1024
;
openair0_cfg
[
0
].
tx_sample_advance
=
50
;
openair0_cfg
[
0
].
tx_bw
=
5e6
;
openair0_cfg
[
0
].
rx_bw
=
5e6
;
openair0_cfg
[
0
].
tx_scheduling_advance
=
5
*
openair0_cfg
[
0
].
samples_per_packet
;
break
;
case
1920000
:
openair0_cfg
[
0
].
samples_per_packet
=
256
;
openair0_cfg
[
0
].
tx_sample_advance
=
50
;
openair0_cfg
[
0
].
tx_bw
=
1.25e6
;
openair0_cfg
[
0
].
rx_bw
=
1.25e6
;
openair0_cfg
[
0
].
tx_scheduling_advance
=
8
*
openair0_cfg
[
0
].
samples_per_packet
;
break
;
default:
...
...
@@ -448,38 +495,54 @@ int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_
device
->
type
=
USRP_B200_IF
;
if
((
vers
==
3
)
&&
(
subvers
==
9
)
&&
(
subsubvers
>=
2
))
{
openair0_cfg
[
0
].
rx_gain_calib_table
=
calib_table_b210
;
bw_gain_adjust
=
0
;
}
else
{
openair0_cfg
[
0
].
rx_gain_calib_table
=
calib_table_b210_38
;
bw_gain_adjust
=
1
;
}
switch
((
int
)
openair0_cfg
[
0
].
sample_rate
)
{
case
30720000
:
s
->
usrp
->
set_master_clock_rate
(
30.72e6
);
// from usrp_time_offset
openair0_cfg
[
0
].
samples_per_packet
=
2048
;
openair0_cfg
[
0
].
tx_sample_advance
=
115
;
openair0_cfg
[
0
].
tx_bw
=
20e6
;
openair0_cfg
[
0
].
rx_bw
=
20e6
;
openair0_cfg
[
0
].
tx_scheduling_advance
=
11
*
openair0_cfg
[
0
].
samples_per_packet
;
break
;
case
23040000
:
s
->
usrp
->
set_master_clock_rate
(
46.08e6
);
openair0_cfg
[
0
].
samples_per_packet
=
2048
;
openair0_cfg
[
0
].
tx_sample_advance
=
113
;
openair0_cfg
[
0
].
tx_bw
=
20e6
;
openair0_cfg
[
0
].
rx_bw
=
20e6
;
openair0_cfg
[
0
].
tx_scheduling_advance
=
8
*
openair0_cfg
[
0
].
samples_per_packet
;
break
;
case
15360000
:
s
->
usrp
->
set_master_clock_rate
(
30.72e6
);
openair0_cfg
[
0
].
samples_per_packet
=
2048
;
openair0_cfg
[
0
].
tx_sample_advance
=
113
;
openair0_cfg
[
0
].
tx_bw
=
10e6
;
openair0_cfg
[
0
].
rx_bw
=
10e6
;
openair0_cfg
[
0
].
tx_scheduling_advance
=
5
*
openair0_cfg
[
0
].
samples_per_packet
;
break
;
case
7680000
:
s
->
usrp
->
set_master_clock_rate
(
30.72e6
);
openair0_cfg
[
0
].
samples_per_packet
=
1024
;
openair0_cfg
[
0
].
tx_sample_advance
=
70
;
//103;
openair0_cfg
[
0
].
tx_bw
=
5e6
;
openair0_cfg
[
0
].
rx_bw
=
5e6
;
openair0_cfg
[
0
].
tx_scheduling_advance
=
5
*
openair0_cfg
[
0
].
samples_per_packet
;
break
;
case
1920000
:
s
->
usrp
->
set_master_clock_rate
(
30.72e6
);
openair0_cfg
[
0
].
samples_per_packet
=
256
;
openair0_cfg
[
0
].
tx_sample_advance
=
40
;
openair0_cfg
[
0
].
tx_bw
=
1.25e6
;
openair0_cfg
[
0
].
rx_bw
=
1.25e6
;
openair0_cfg
[
0
].
tx_scheduling_advance
=
8
*
openair0_cfg
[
0
].
samples_per_packet
;
break
;
default:
...
...
@@ -495,7 +558,7 @@ int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_
s
->
usrp
->
set_rx_bandwidth
(
openair0_cfg
[
0
].
rx_bw
,
i
);
printf
(
"Setting rx freq/gain on channel %lu/%lu : BW %f (readback %f)
\n
"
,
i
,
s
->
usrp
->
get_rx_num_channels
(),
openair0_cfg
[
0
].
rx_bw
/
1e6
,
s
->
usrp
->
get_rx_bandwidth
(
i
)
/
1e6
);
s
->
usrp
->
set_rx_freq
(
openair0_cfg
[
0
].
rx_freq
[
i
],
i
);
set_rx_gain_offset
(
&
openair0_cfg
[
0
],
i
);
set_rx_gain_offset
(
&
openair0_cfg
[
0
],
i
,
bw_gain_adjust
);
::
uhd
::
gain_range_t
gain_range
=
s
->
usrp
->
get_rx_gain_range
(
i
);
// limit to maximum gain
...
...
targets/RT/USER/lte-softmodem.c
View file @
3007400b
...
...
@@ -2976,6 +2976,7 @@ int main( int argc, char **argv )
openair0_cfg
[
card
].
rx_gain
[
i
]
=
PHY_vars_UE_g
[
0
][
0
]
->
rx_total_gain_dB
;
// - USRP_GAIN_OFFSET; // calibrated for USRP B210 @ 2.6 GHz, 30.72 MS/s
}
#if 0 // UHD 3.8
switch(frame_parms[0]->N_RB_DL) {
case 6:
openair0_cfg[card].rx_gain[i] -= 12;
...
...
@@ -2996,7 +2997,7 @@ int main( int argc, char **argv )
default:
break;
}
#endif
}
...
...
targets/RT/USER/lte-ue.c
View file @
3007400b
...
...
@@ -279,7 +279,7 @@ static void *UE_thread_synch(void *arg)
#ifdef OAI_USRP
openair0_cfg
[
card
].
rx_gain
[
i
]
=
UE
->
rx_total_gain_dB
;
//-USRP_GAIN_OFFSET;
#if 0 // UHD 3.8
switch(UE->lte_frame_parms.N_RB_DL) {
case 6:
openair0_cfg[card].rx_gain[i] -= 12;
...
...
@@ -301,7 +301,7 @@ static void *UE_thread_synch(void *arg)
printf( "Unknown number of RBs %d\n", UE->lte_frame_parms.N_RB_DL );
break;
}
#endif
printf
(
"UE synch: setting RX gain (%d,%d) to %f
\n
"
,
card
,
i
,
openair0_cfg
[
card
].
rx_gain
[
i
]
);
#endif
}
...
...
@@ -358,6 +358,7 @@ static void *UE_thread_synch(void *arg)
#ifdef OAI_USRP
openair0_cfg
[
card
].
rx_gain
[
i
]
=
UE
->
rx_total_gain_dB
;
//-USRP_GAIN_OFFSET; // 65 calibrated for USRP B210 @ 2.6 GHz
#if 0 // UHD 3.8
switch(UE->lte_frame_parms.N_RB_DL) {
case 6:
openair0_cfg[card].rx_gain[i] -= 12;
...
...
@@ -379,7 +380,7 @@ static void *UE_thread_synch(void *arg)
printf("Unknown number of RBs %d\n",UE->lte_frame_parms.N_RB_DL);
break;
}
#endif
printf
(
"UE synch: setting RX gain (%d,%d) to %f
\n
"
,
card
,
i
,
openair0_cfg
[
card
].
rx_gain
[
i
]);
#endif
...
...
@@ -423,25 +424,25 @@ static void *UE_thread_synch(void *arg)
openair0_cfg
[
0
].
sample_rate
=
1.92e6
;
openair0_cfg
[
0
].
rx_bw
=
.96e6
;
openair0_cfg
[
0
].
tx_bw
=
.96e6
;
openair0_cfg
[
0
].
rx_gain
[
0
]
-=
12
;
//
openair0_cfg[0].rx_gain[0] -= 12;
break
;
case
25
:
openair0_cfg
[
0
].
sample_rate
=
7.68e6
;
openair0_cfg
[
0
].
rx_bw
=
2.5e6
;
openair0_cfg
[
0
].
tx_bw
=
2.5e6
;
openair0_cfg
[
0
].
rx_gain
[
0
]
-=
6
;
//
openair0_cfg[0].rx_gain[0] -= 6;
break
;
case
50
:
openair0_cfg
[
0
].
sample_rate
=
15.36e6
;
openair0_cfg
[
0
].
rx_bw
=
5.0e6
;
openair0_cfg
[
0
].
tx_bw
=
5.0e6
;
openair0_cfg
[
0
].
rx_gain
[
0
]
-=
3
;
//
openair0_cfg[0].rx_gain[0] -= 3;
break
;
case
100
:
openair0_cfg
[
0
].
sample_rate
=
30.72e6
;
openair0_cfg
[
0
].
rx_bw
=
10.0e6
;
openair0_cfg
[
0
].
tx_bw
=
10.0e6
;
openair0_cfg
[
0
].
rx_gain
[
0
]
-=
0
;
//
openair0_cfg[0].rx_gain[0] -= 0;
break
;
}
#ifndef EXMIMO
...
...
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