Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adrv9002 interface gain fix #185

Merged
merged 8 commits into from
Oct 18, 2024
39 changes: 35 additions & 4 deletions +adi/+ADRV9002/Rx.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
% For narrowband applications higher levels of interface gain
% should be used (0:18) to allow signal level and analog noise to
% dominate. For wideband applications this gain should be reduced
% or disabled since quantization noise is minimal.
% or disabled since quantization noise is minimal. Note that the
% available options for this gain depend on the profile loaded
% and picking an option outside of those options generates an
% error.
InterfaceGainChannel0 = '0dB';
%InterfaceGainChannel1 Interface Gain Channel 1
% This is the final gain in the digital path with possible
Expand All @@ -37,7 +40,10 @@
% For narrowband applications higher levels of interface gain
% should be used (0:18) to allow signal level and analog noise to
% dominate. For wideband applications this gain should be reduced
% or disabled since quantization noise is minimal.
% or disabled since quantization noise is minimal. Note that the
% available options for this gain depend on the profile loaded
% and picking an option outside of those options generates an
% error.
InterfaceGainChannel1 = '0dB';

%DigitalGainControlModeChannel0 Digital Gain Control Mode Channel 0
Expand Down Expand Up @@ -200,7 +206,7 @@
% hardware
RSSIChannel1
end

properties(Constant, Hidden)
ENSMModeChannel0Set = matlab.system.StringSet({ ...
'calibrated','primed','rf_enabled'});
Expand All @@ -221,7 +227,7 @@
'automatic','spi'});
DigitalGainControlModeChannel1Set = matlab.system.StringSet({ ...
'automatic','spi'});

InterfaceGainChannel0Set = matlab.system.StringSet({...
'18dB', '12dB', '6dB', '0dB', '-6dB', '-12dB', '-18dB',...
'-24dB', '-30dB','-36dB'});
Expand All @@ -230,6 +236,11 @@
'-24dB', '-30dB','-36dB'});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

end

properties(Hidden)
InterfaceGainAvailableChannel0
InterfaceGainAvailableChannel1
end

properties (Hidden, Nontunable, Access = protected)
isOutput = false;
end
Expand Down Expand Up @@ -264,6 +275,22 @@
value = NaN;
end
end
function values = get.InterfaceGainAvailableChannel0(obj)
if obj.ConnectedToDevice
values = obj.getAttributeRAW('voltage0','interface_gain_available',false);
values = strsplit(values);
else
values = NaN;
end
end
function values = get.InterfaceGainAvailableChannel1(obj)
if obj.ConnectedToDevice
values = obj.getAttributeRAW('voltage0','interface_gain_available',false);
values = strsplit(values);
else
values = NaN;
end
end

% Check ENSMModeChannel0
function set.ENSMModeChannel0(obj, value)
Expand Down Expand Up @@ -354,6 +381,7 @@
function set.InterfaceGainChannel0(obj, value)
obj.InterfaceGainChannel0 = value;
if obj.ConnectedToDevice
mustBeMember(value,obj.InterfaceGainAvailableChannel0);
id = 'voltage0';
if strcmpi(obj.DigitalGainControlModeChannel0,'spi') &&...
strcmpi(obj.ENSMModeChannel0,'rf_enabled')
Expand All @@ -365,6 +393,7 @@
function set.InterfaceGainChannel1(obj, value)
obj.InterfaceGainChannel1 = value;
if obj.ConnectedToDevice
mustBeMember(value,obj.InterfaceGainAvailableChannel1);
id = 'voltage1';
if strcmpi(obj.DigitalGainControlModeChannel1,'spi') &&...
strcmpi(obj.ENSMModeChannel1,'rf_enabled')
Expand Down Expand Up @@ -567,10 +596,12 @@ function setupInit(obj)
end

if strcmpi(obj.DigitalGainControlModeChannel0,'spi') && strcmpi(obj.ENSMModeChannel0,'rf_enabled')
mustBeMember(obj.InterfaceGainChannel0,obj.InterfaceGainAvailableChannel0);
obj.setAttributeRAW('voltage0','interface_gain',obj.InterfaceGainChannel0,false);
end

if strcmpi(obj.DigitalGainControlModeChannel1,'spi') && strcmpi(obj.ENSMModeChannel1,'rf_enabled') && channelsAval == 2
mustBeMember(obj.InterfaceGainChannel1,obj.InterfaceGainAvailableChannel1);
obj.setAttributeRAW('voltage1','interface_gain',obj.InterfaceGainChannel1,false);
end

Expand Down
5 changes: 3 additions & 2 deletions test/ADRV9002Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function testADRV9002RxInterfaceGain(testCase,InterfaceGain)
[out, valid] = rx();
rx.release();
testCase.verifyTrue(valid);
testCase.verifyGreaterThan(sum(abs(double(out))),0);
testCase.verifyGreaterThanOrEqual(sum(abs(double(out))),0);
end

function testADRV9002RxTracking(testCase,Tracking)
Expand Down Expand Up @@ -335,8 +335,9 @@ function testADRV9002ManualGainControl(testCase)
rx.CustomStreamFileName = which('lte_5_cmos_api_68_0_6.stream');

rx.DigitalGainControlModeChannel0 = 'spi';
rx.InterfaceGainChannel0 = '6dB';
rx.InterfaceGainChannel0 = '0dB';
[~,valid] = rx();
rx.InterfaceGainChannel0 = rx.InterfaceGainAvailableChannel0{1};
testCase.assertTrue(valid);
end

Expand Down
Loading