diff --git a/+adi/+AD4080/Rx.m b/+adi/+AD4080/Rx.m new file mode 100644 index 0000000..0b6f635 --- /dev/null +++ b/+adi/+AD4080/Rx.m @@ -0,0 +1,146 @@ +classdef Rx < adi.common.Rx & adi.common.RxTx & ... + matlabshared.libiio.base & adi.common.Attribute & ... + adi.common.RegisterReadWrite & adi.common.Channel + % 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. + % + % rx = adi.AD4080.Rx; + % rx = adi.AD4080.Rx('uri','192.168.2.1'); + % + % 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' + 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' + + end + + properties (Nontunable, Hidden) + channel_names = { ... + 'voltage0'} + end + + 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 + dataTypeStr = 'int32' + phyDevName = 'ad4080' + devName = 'ad4080' + end + + properties (Nontunable, Hidden, Constant) + Type = 'Rx' + ComplexData = false + end + + methods + + %% Constructor + function obj = Rx(varargin) + obj = obj@matlabshared.libiio.base(varargin{:}); + obj.enableExplicitPolling = false; + obj.EnabledChannels = 1; + obj.BufferTypeConversionEnable = true; + obj.uri = 'ip:analog.local'; + 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); + end + end + + % Check TestMode + function set.TestMode(obj, value) + obj.TestMode = value; + if obj.ConnectedToDevice + obj.setDeviceAttributeRAW('test_mode', value); + end + end + + end + + methods (Access = protected) + + function numOut = getNumOutputsImpl(~) + numOut = 2; + end + + end + + %% API Functions + methods (Hidden) + + function setupExtra(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 + % modification to nontunable variables at SetupImpl + + obj.setDeviceAttributeRAW('sampling_frequency', num2str(obj.SampleRate)); + obj.setAttributeRAW('voltage0', 'test_mode', obj.TestMode, false); + end + + 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 diff --git a/+adi/Contents.m b/+adi/Contents.m index c2d5536..a9c3a11 100644 --- a/+adi/Contents.m +++ b/+adi/Contents.m @@ -34,3 +34,4 @@ % AD5791 - DAC % AD7124_4 - ADC % AD7124_8 - ADC +% AD4080 - ADC diff --git a/CI/gen_doc/docs/_pages/index.md b/CI/gen_doc/docs/_pages/index.md index 84fdabf..17c366b 100644 --- a/CI/gen_doc/docs/_pages/index.md +++ b/CI/gen_doc/docs/_pages/index.md @@ -50,4 +50,5 @@ The following have device-specific implementations in MATLAB and Simulink. If a | AD4021 | Zedboard | Yes | No | ADI (2021b) | | AD4022 | Zedboard | Yes | No | ADI (2021b) | | AD7124-4 | Zedboard | Yes | No | ADI (2021b) | -| AD7124-8 | Zedboard | Yes | No | ADI (2021b) | \ No newline at end of file +| AD7124-8 | Zedboard | Yes | No | ADI (2021b) | +| AD4080 | Zedboard | Yes | No | ADI (2021b) | \ No newline at end of file diff --git a/CI/gen_doc/docs/gen_sysobj_doc.m b/CI/gen_doc/docs/gen_sysobj_doc.m index 1b0a6ff..8798475 100644 --- a/CI/gen_doc/docs/gen_sysobj_doc.m +++ b/CI/gen_doc/docs/gen_sysobj_doc.m @@ -36,6 +36,7 @@ , {'AD5791', {'Tx'}}... , {'AD7124_4', {'Rx'}}... , {'AD7124_8', {'Rx'}}... + , {'AD4080', {'Rx'}}... %{'QuadMxFE',{'Rx','Tx'}}... }; diff --git a/CI/gen_doc/docs/sysobjs.json b/CI/gen_doc/docs/sysobjs.json index 9423b46..ad8c3dd 100644 --- a/CI/gen_doc/docs/sysobjs.json +++ b/CI/gen_doc/docs/sysobjs.json @@ -1157,5 +1157,46 @@ "prop_description": "Hostname or IP address of remote libIIO deviceHelp for adi.AD7124_8.Rx/uri is inherited from superclass matlabshared.libiio.base" } ] + }, + { + "name": "adi.AD4080.Rx", + "dec": " 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.

rx = adi.AD4080.Rx;
rx = adi.AD4080.Rx('uri','192.168.2.1');

AD4080 Datasheet
Documentation for adi.AD4080.Rx
doc adi.AD4080.Rx
", + "props": [ + { + "prop_name": "EnabledChannels", + "prop_title": " EnabledChannels Enabled Channels", + "prop_description": "Indexs of channels to be enabled. Input should be a [1xN] vector with the indexes of channels to be enabled. Order is irrelevant" + }, + { + "prop_name": "SampleRate", + "prop_title": " SampleRate Sample Rate", + "prop_description": "Baseband sampling rate in Hz, specified as a scalar in samples per second. Options are: '256000','128000','64000','32000','16000','8000','4000', '2000','1000'" + }, + { + "prop_name": "SamplesPerFrame", + "prop_title": " SamplesPerFrame Samples Per Frame", + "prop_description": "The number of samples to be captured as part of one continuous buffer" + }, + { + "prop_name": "Scale", + "prop_title": " Scale Scale", + "prop_description": "Scale value to be used to convert the code to voltage" + }, + { + "prop_name": "TestMode", + "prop_title": " TestMode Test Mode", + "prop_description": "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'" + }, + { + "prop_name": "kernelBuffersCount", + "prop_title": " Kernel buffers count", + "prop_description": "The number of buffers allocated in the kernel for data transfersHelp for adi.AD4080.Rx/kernelBuffersCount is inherited from superclass matlabshared.libiio.base" + }, + { + "prop_name": "uri", + "prop_title": " URI - remote host URI", + "prop_description": "Hostname or IP address of remote libIIO deviceHelp for adi.AD4080.Rx/uri is inherited from superclass matlabshared.libiio.base" + } + ] } ] \ No newline at end of file diff --git a/examples/ad4080_DataCapture.m b/examples/ad4080_DataCapture.m new file mode 100644 index 0000000..f2c6ab7 --- /dev/null +++ b/examples/ad4080_DataCapture.m @@ -0,0 +1,25 @@ +%% Script for capturing and displaying a continuous set of samples from a +%% connected EVAL-AD4080-FMCZ 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'; + +% 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 + +% Delete the system object +release(rx);