diff --git a/+adi/+AD4080/Rx.m b/+adi/+AD4080/Rx.m
index 0b6f635d..7bcd2fb6 100644
--- a/+adi/+AD4080/Rx.m
+++ b/+adi/+AD4080/Rx.m
@@ -1,64 +1,40 @@
-classdef Rx < adi.common.Rx & adi.common.RxTx & ...
- matlabshared.libiio.base & adi.common.Attribute & ...
- adi.common.RegisterReadWrite & adi.common.Channel
+classdef Rx < adi.common.Rx & matlabshared.libiio.base & adi.common.Attribute
% AD4080 Precision ADC Class
+ %
% adi.AD4080.Rx Receives data from the AD4080 ADC
- % The adi.AD4080.Rx System object is a signal source that can receive
- % data from the AD4080.
+ % The adi.AD4080.Rx System object is a signal source that can receive
+ % data from the AD4080.
%
- % rx = adi.AD4080.Rx;
- % rx = adi.AD4080.Rx('uri','192.168.2.1');
+ % `rx = adi.AD4080.Rx;`
+ % `rx = adi.AD4080.Rx('serial:COM19,230400');`
%
- % AD4080 Datasheet
+ % `AD4080 Datasheet `_
properties (Nontunable)
% SampleRate Sample Rate
% Baseband sampling rate in Hz, specified as a scalar
- % in samples per second. Options are:
- % '256000','128000','64000','32000','16000','8000','4000',
- % '2000','1000'
+ % in samples per second.
SampleRate = '40000000'
-
- % SamplesPerFrame Samples Per Frame
- % The number of samples to be captured as part of one continuous buffer
- SamplesPerFrame = 4096
-
- % Scale Scale
- % Scale value to be used to convert the code to voltage
- Scale = 0.005722
-
- % TestMode Test Mode
- % Test Mode for AD4080. Options are:
- % 'off', 'midscale_short', 'pos_fullscale',
- % 'neg_fullscale', 'checkerboard', 'pn_long', 'on_short', 'one_zero_toggle',
- % 'user', 'bit_toggle', 'sync', 'one_bit_high', 'mixed_bit_frequency'
- TestMode = 'off'
+ % SamplesPerFrame Samples Per Frame
+ % Number of samples per frame, specified as an even positive
+ % integer.
+ SamplesPerFrame = 400
end
- properties (Nontunable, Hidden)
- channel_names = { ...
- 'voltage0'}
+ % Channel names
+ properties (Nontunable, Hidden, Constant)
+ channel_names = {'voltage0'}
end
+ % isOutput
properties (Hidden, Nontunable, Access = protected)
isOutput = false
end
- properties (Constant, Hidden)
- SampleRateSet = matlab.system.StringSet({ ...
- '40000000', '256000', '128000', '64000', ...
- '32000', '16000', '8000', '4000', ...
- '2000', '1000'})
-
- TestModeSet = matlab.system.StringSet({'off', 'midscale_short', 'pos_fullscale', ...
- 'neg_fullscale', 'checkerboard', 'pn_long', 'on_short', 'one_zero_toggle', ...
- 'user', 'bit_toggle', 'sync', 'one_bit_high', 'mixed_bit_frequency'})
-
- end
-
properties (Nontunable, Hidden)
Timeout = Inf
+ kernelBuffersCount = 1
dataTypeStr = 'int32'
phyDevName = 'ad4080'
devName = 'ad4080'
@@ -66,6 +42,9 @@
properties (Nontunable, Hidden, Constant)
Type = 'Rx'
+ end
+
+ properties (Hidden, Constant)
ComplexData = false
end
@@ -73,74 +52,39 @@
%% Constructor
function obj = Rx(varargin)
+ % Initialize the Rx object
obj = obj@matlabshared.libiio.base(varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.BufferTypeConversionEnable = true;
- obj.uri = 'ip:analog.local';
+ obj.uri = 'serial:COM19,230400';
end
- function flush(obj)
- flushBuffers(obj);
- end
-
- % Check SamplingRate
function set.SampleRate(obj, value)
- obj.SampleRate = value;
- if obj.ConnectedToDevice
- obj.setDeviceAttributeRAW('sampling_frequency', value);
+ % Set device sampling rate
+ if value ~= 40000000 && value ~= 20000000 && value ~= 10000000
+ error('SampleRate must be 40000000, 20000000, or 10000000.');
end
- end
-
- % Check TestMode
- function set.TestMode(obj, value)
- obj.TestMode = value;
+ obj.SampleRate = value;
if obj.ConnectedToDevice
- obj.setDeviceAttributeRAW('test_mode', value);
+ obj.setDeviceAttributeRAW('select_conversion_rate', num2str(value));
end
end
end
- methods (Access = protected)
-
- function numOut = getNumOutputsImpl(~)
- numOut = 2;
- end
-
- end
-
%% API Functions
- methods (Hidden)
+ methods (Hidden, Access = protected)
- function setupExtra(obj)
+ function setupInit(obj)
% Write all attributes to device once connected through set
% methods
% Do writes directly to hardware without using set methods.
- % This is required since Simulink doesn't support
+ % This is required since Simulink support doesn't support
% modification to nontunable variables at SetupImpl
- obj.setDeviceAttributeRAW('sampling_frequency', num2str(obj.SampleRate));
- obj.setAttributeRAW('voltage0', 'test_mode', obj.TestMode, false);
- end
+ obj.setDeviceAttributeRAW('select_conversion_rate', num2str(obj.SampleRate));
- end
-
- %% External Dependency Methods
- methods (Hidden, Static)
-
- function tf = isSupportedContext(bldCfg)
- tf = matlabshared.libiio.ExternalDependency.isSupportedContext(bldCfg);
- end
-
- function updateBuildInfo(buildInfo, bldCfg)
- % Call the matlabshared.libiio.method first
- matlabshared.libiio.ExternalDependency.updateBuildInfo(buildInfo, bldCfg);
- end
-
- function bName = getDescriptiveName(~)
- bName = 'AD4080 Precision ADC';
end
-
end
-end
+end
\ No newline at end of file
diff --git a/examples/ad4080_DataCapture.m b/examples/ad4080_DataCapture.m
index f2c6ab73..6d14f296 100644
--- a/examples/ad4080_DataCapture.m
+++ b/examples/ad4080_DataCapture.m
@@ -1,25 +1,20 @@
-%% Script for capturing and displaying a continuous set of samples from a
-%% connected EVAL-AD4080-FMCZ board
+%% Script for capturing and displaying a continuous set of samples from a
+%% connected AD4080 board
% Instantiate the system object
-rx = adi.AD4080.Rx;
-% Specify uri
-rx.uri = 'ip:analog.local';
-
-rx.SamplesPerFrame = 4096;
-rx.EnabledChannels = [1];
-rx.TestMode = 'midscale_short';
+rx = adi.AD4080.Rx();
+rx.uri = 'serial:COM19,230400,8n1n';
+rx.SamplesPerFrame = 400;
+rx.SampleRate = 40000000; % Only sampling rates of 40 MHz, 20 MHz, and 10 MHz are valid
% Capture data
data = rx();
enabledChannels = size(data, 2);
figure(1);
-for i = 1:enabledChannels
- subplot(enabledChannels, 1, i);
- plot(data(1:rx.FrameCount * rx.SamplesPerFrame, i));
- title("Channel " + num2str(rx.EnabledChannels(i)));
-end
+subplot(enabledChannels, 1, 1);
+plot(data(1:rx.SamplesPerFrame, 1));
+title("Channel 0");
% Delete the system object
-release(rx);
+release(rx);
\ No newline at end of file