Skip to content

Commit

Permalink
AD400x: Add support for AD400x series
Browse files Browse the repository at this point in the history
- Add AD400x/Base.m class, refactor AD4020
- Add AD4021, AD4022
- Add AD4000, AD4004, AD4008
- Add AD4001, AD4005
- Add AD4002, AD4006, AD4010
- Add AD4003, AD4007, AD4011
- Update docs, metadata
- Update examples/ad4020DataCapture.m to remove incorrect
  rx.Voltage() call

Signed-off-by: Trevor Gamblin <[email protected]>
  • Loading branch information
threexc committed Feb 20, 2024
1 parent 7ea4c14 commit ff1f14b
Show file tree
Hide file tree
Showing 21 changed files with 452 additions and 92 deletions.
21 changes: 21 additions & 0 deletions +adi/+AD4000/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4000 Precision ADC Class
% adi.AD4000.Rx Receives data from the AD4000 ADC
% The adi.AD4000.Rx System object is a signal source that can receive
% data from the AD4000.
%
% rx = adi.AD4000.Rx;
% rx = adi.AD4000.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4000-4004-4008.pdf">AD4000 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4000', 'ad4000', 'int16', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
21 changes: 21 additions & 0 deletions +adi/+AD4001/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4001 Precision ADC Class
% adi.AD4001.Rx Receives data from the AD4001 ADC
% The adi.AD4001.Rx System object is a signal source that can receive
% data from the AD4001.
%
% rx = adi.AD4001.Rx;
% rx = adi.AD4001.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4001-4005.pdf">AD4001 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4001', 'ad4001', 'int16', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
21 changes: 21 additions & 0 deletions +adi/+AD4002/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4002 Precision ADC Class
% adi.AD4002.Rx Receives data from the AD4002 ADC
% The adi.AD4002.Rx System object is a signal source that can receive
% data from the AD4002.
%
% rx = adi.AD4002.Rx;
% rx = adi.AD4002.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4002-4006-4010.pdf">AD4002 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4002', 'ad4002', 'int32', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
21 changes: 21 additions & 0 deletions +adi/+AD4003/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4003 Precision ADC Class
% adi.AD4003.Rx Receives data from the AD4003 ADC
% The adi.AD4003.Rx System object is a signal source that can receive
% data from the AD4003.
%
% rx = adi.AD4003.Rx;
% rx = adi.AD4003.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4003-4007-4011.pdf">AD4003 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4003', 'ad4003', 'int32', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
21 changes: 21 additions & 0 deletions +adi/+AD4004/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4004 Precision ADC Class
% adi.AD4004.Rx Receives data from the AD4004 ADC
% The adi.AD4004.Rx System object is a signal source that can receive
% data from the AD4004.
%
% rx = adi.AD4004.Rx;
% rx = adi.AD4004.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4000-4004-4008.pdf">AD4004 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4004', 'ad4004', 'int16', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
21 changes: 21 additions & 0 deletions +adi/+AD4005/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4005 Precision ADC Class
% adi.AD4005.Rx Receives data from the AD4005 ADC
% The adi.AD4005.Rx System object is a signal source that can receive
% data from the AD4005.
%
% rx = adi.AD4005.Rx;
% rx = adi.AD4005.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4001-4005.pdf">AD4005 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4005', 'ad4005', 'int16', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
21 changes: 21 additions & 0 deletions +adi/+AD4006/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4006 Precision ADC Class
% adi.AD4006.Rx Receives data from the AD4006 ADC
% The adi.AD4006.Rx System object is a signal source that can receive
% data from the AD4006.
%
% rx = adi.AD4006.Rx;
% rx = adi.AD4006.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4002-4006-4010.pdf">AD4006 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4006', 'ad4006', 'int32', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
21 changes: 21 additions & 0 deletions +adi/+AD4007/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4007 Precision ADC Class
% adi.AD4007.Rx Receives data from the AD4007 ADC
% The adi.AD4007.Rx System object is a signal source that can receive
% data from the AD4007.
%
% rx = adi.AD4007.Rx;
% rx = adi.AD4007.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4003-4007-4011.pdf">AD4007 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4007', 'ad4007', 'int32', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
21 changes: 21 additions & 0 deletions +adi/+AD4008/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4008 Precision ADC Class
% adi.AD4008.Rx Receives data from the AD4008 ADC
% The adi.AD4008.Rx System object is a signal source that can receive
% data from the AD4008.
%
% rx = adi.AD4008.Rx;
% rx = adi.AD4008.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4000-4004-4008.pdf">AD4008 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4008', 'ad4008', 'int16', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
115 changes: 115 additions & 0 deletions +adi/+AD400x/Base.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
classdef Base < adi.common.Rx & matlabshared.libiio.base & adi.common.Attribute
% AD400X is a family of precision ADCs with sample rates between 500
% kSPS and 2 MSPS
%
% AD4000/AD4004/AD4008 are single-channel, 16-bit unsigned ADCs
% AD4001/AD4005 are single-channel, 16-bit signed ADCs
% AD4002/AD4006/AD4010 are single-channel, 18-bit unsigned ADCs
% AD4003/AD4007/AD4011 are single-channel, 18-bit signed ADCs

properties (Nontunable)
% SamplesPerFrame Samples Per Frame
% Number of samples per frame, specified as an even positive
% integer.
SamplesPerFrame = 4096

% SampleRate Sample Rate
% Baseband sampling rate in Hz, specified as a scalar
% in samples per second.
SampleRate = '500000'
end

properties (Dependent)
% Voltage
% ADC Voltage in mV
Voltage

% VoltageScale Voltage Scale
% ADC Voltage scale.
VoltageScale

% VoltageOffset Voltage Offset
% ADC Voltage offset.
VoltageOffset
end

% Channel names
properties (Nontunable, Hidden, Constant)
channel_names = {'voltage0'}
end

% isOutput
properties (Hidden, Nontunable, Access = protected)
isOutput = false
end

properties (Nontunable, Hidden)
Timeout = Inf
kernelBuffersCount = 1
dataTypeStr
phyDevName
devName
end

properties (Nontunable, Hidden, Constant)
Type = 'Rx'
end

properties (Hidden, Constant)
ComplexData = false
end

methods
%% Constructor
function obj = Base(phydev, dev, dtype, varargin)
obj = [email protected](varargin{:});
obj.phyDevName = phydev;
obj.devName = dev;
obj.dataTypeStr = dtype;
end

%% Set SampleRate
function set.SampleRate(obj, value)
% Set device sampling rate
obj.SampleRate = value;
if obj.ConnectedToDevice
obj.setDeviceAttributeRAW('sampling_frequency', num2str(value));
end
end

%% Check Voltage
function rValue = get.Voltage(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeRAW('voltage0', 'raw', obj.isOutput);
else
rValue = NaN;
end
end

%% Check Voltage Scale
function rValue = get.VoltageScale(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeDouble('voltage0', 'scale', obj.isOutput);
else
rValue = NaN;
end
end

%% Check Voltage Offset
function rValue = get.VoltageOffset(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeDouble('voltage0', 'offset', obj.isOutput);
else
rValue = NaN;
end
end
end

%% API Functions
methods (Hidden, Access = protected)
function setupInit(obj)
obj.setDeviceAttributeRAW('sampling_frequency', ...
num2str(obj.SampleRate));
end
end
end
21 changes: 21 additions & 0 deletions +adi/+AD4010/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4010 Precision ADC Class
% adi.AD4010.Rx Receives data from the AD4010 ADC
% The adi.AD4010.Rx System object is a signal source that can receive
% data from the AD4010.
%
% rx = adi.AD4010.Rx;
% rx = adi.AD4010.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4002-4006-4010.pdf">AD4010 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4010', 'ad4010', 'int32', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
21 changes: 21 additions & 0 deletions +adi/+AD4011/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classdef Rx < adi.AD400x.Base & matlabshared.libiio.base & adi.common.Attribute
% AD4011 Precision ADC Class
% adi.AD4011.Rx Receives data from the AD4011 ADC
% The adi.AD4011.Rx System object is a signal source that can receive
% data from the AD4011.
%
% rx = adi.AD4011.Rx;
% rx = adi.AD4011.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4003-4007-4011.pdf">AD4011 Datasheet</a>

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad4011', 'ad4011', 'int32', varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
end
end
end
Loading

0 comments on commit ff1f14b

Please sign in to comment.