aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Amsel <lars.amsel@ni.com>2021-06-15 15:17:39 +0200
committerAaron Rossetto <aaron.rossetto@ni.com>2021-06-23 13:57:15 -0500
commitabcaa3f6a983c832b2ff2873d30eebd3d35f3e9a (patch)
tree05d16fb41c4c4fa4c38719abd4b16b0a6ad908bc
parent067411a35264bd8f5645dc7585dcea8027bfa3bc (diff)
downloaduhd-abcaa3f6a983c832b2ff2873d30eebd3d35f3e9a.tar.gz
uhd-abcaa3f6a983c832b2ff2873d30eebd3d35f3e9a.tar.bz2
uhd-abcaa3f6a983c832b2ff2873d30eebd3d35f3e9a.zip
cal: ensure proper range handling
* frequency range adapts the lower limit to align with the step size the lower limit will be set to step size if it s smaller than the step size and not explicitly set. This prevents uneven measurment spots * aranges upper limit is always increased by step size to ensure the upper limit is part of the range * rearranged gain range calculation, create the range once and reverse it for RX
-rw-r--r--host/python/uhd/usrp/cal/usrp_calibrator.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/host/python/uhd/usrp/cal/usrp_calibrator.py b/host/python/uhd/usrp/cal/usrp_calibrator.py
index f409072d4..bb98e045a 100644
--- a/host/python/uhd/usrp/cal/usrp_calibrator.py
+++ b/host/python/uhd/usrp/cal/usrp_calibrator.py
@@ -42,9 +42,11 @@ def get_default_gains(direction, gain_range, gain_step):
Create a equidistant gain range for calibration
"""
assert direction in ('rx', 'tx')
- if direction == 'tx':
- return numpy.arange(0, gain_range.stop(), gain_step)
- return numpy.arange(gain_range.stop(), 0, -gain_step)
+ result = numpy.arange(0, gain_range.stop() + gain_step, gain_step)
+ # reverse measurement points in RX so we can break cal loop once signal is too low
+ if direction == 'rx':
+ result = numpy.flip(result)
+ return result
def get_usrp_power(streamer, num_samps=NUM_SAMPS_PER_EST, chan=0):
"""
@@ -159,9 +161,12 @@ class USRPCalibratorBase:
If a particular device needs to check specific frequencies, then
override this.
"""
+ step = step_hint or DEFAULT_FREQ_STEP
start_min = self.min_freq or \
getattr(self._usrp, 'get_{}_freq_range'.format(self._dir))(
self._chan).start()
+ if not start_hint and (start_min < step):
+ start_min = step
start_hint = start_hint or start_min
start = max(start_hint, start_min)
stop_max = self.max_freq or \
@@ -169,8 +174,7 @@ class USRPCalibratorBase:
self._chan).stop()
stop_hint = stop_hint or stop_max
stop = min(stop_hint, stop_max)
- step = step_hint or DEFAULT_FREQ_STEP
- return numpy.arange(start, stop + 1.0, step)
+ return numpy.arange(start, stop + step, step)
def init_frequencies(self, start_hint, stop_hint, step_hint):
"""