diff --git a/+adi/+AD4134/Rx.m b/+adi/+AD4134/Rx.m new file mode 100644 index 0000000..4c4bf3a --- /dev/null +++ b/+adi/+AD4134/Rx.m @@ -0,0 +1,25 @@ +classdef Rx < adi.common.Rx & adi.common.RxTx ... + & adi.AD7134.Base + % AD4134 Precision ADC Class + % + % adi.AD4134.Rx Receives data from the AD4134 ADC + % The adi.AD4134.Rx System object is a signal source that can receive + % data from the AD4134. + % + % rx = adi.AD4134.Rx; + % rx = adi.AD4134.Rx('uri','ip:192.168.2.1'); + % + % AD4134 Datasheet + + properties (Nontunable, Hidden) + channel_names = {'voltage0','voltage1','voltage2','voltage3'}; + end + + methods + %% Constructor + function obj = Rx(varargin) + obj = obj@adi.AD7134.Base('ad4134','ad4134',varargin{:}); + end + end + +end diff --git a/+adi/+AD7134/Base.m b/+adi/+AD7134/Base.m new file mode 100644 index 0000000..2cbbbd4 --- /dev/null +++ b/+adi/+AD7134/Base.m @@ -0,0 +1,93 @@ +classdef Base < adi.common.Rx & adi.common.RxTx & ... + matlabshared.libiio.base & adi.common.Attribute & ... + adi.common.RegisterReadWrite & adi.common.Channel + % AD7134 Precision ADC Base Class + % AD7134 is a 4-channel, 16-bit precision ADC + % AD4134 is a 4-channel, 16-bit precision ADC + + properties (Nontunable) + % SampleRate Sample Rate + % Baseband sampling rate in Hz, specified as a scalar + % in samples per second. + SampleRate = '500000' + + % SamplesPerFrame Samples Per Frame + % Number of samples per frame, specified as an even positive + % integer. + SamplesPerFrame = 400 + end + + % isOutput + properties (Hidden, Nontunable, Access = protected) + isOutput = false + end + + properties (Nontunable, Hidden, Constant) + Type = 'Rx' + end + + properties (Nontunable, Hidden) + Timeout = Inf + kernelBuffersCount = 1 + dataTypeStr = 'uint16' + phyDevName + devName + end + + properties (Hidden, Constant) + ComplexData = false + end + + methods + %% Constructor + function obj = Base(phydev,dev,varargin) + coder.allowpcode('plain'); + % Initialize the Rx object + obj = obj@matlabshared.libiio.base(varargin{:}); + obj.enableExplicitPolling = false; + obj.EnabledChannels = 1; + obj.BufferTypeConversionEnable = true; + obj.phyDevName = phydev; + obj.devName = dev; + obj.uri = 'ip:analog.local'; + end + + function flush(obj) + % Flush the buffer + flushBuffers(obj); + end + + function delete(obj) + % Destructor + delete@adi.common.RxTx(obj); + end + end + + %% API Functions + methods (Hidden, Access = protected) + 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 support doesn't support + % modification to nontunable variables at SetupImpl + 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 = 'AD7134 ADC'; + end + end + +end diff --git a/+adi/+AD7134/Rx.m b/+adi/+AD7134/Rx.m new file mode 100644 index 0000000..41408d0 --- /dev/null +++ b/+adi/+AD7134/Rx.m @@ -0,0 +1,25 @@ +classdef Rx < adi.common.Rx & adi.common.RxTx ... + & adi.AD7134.Base + % AD7134 Precision ADC Class + % + % adi.AD7134.Rx Receives data from the AD7134 ADC + % The adi.AD7134.Rx System object is a signal source that can receive + % data from the AD7134. + % + % rx = adi.AD7134.Rx; + % rx = adi.AD7134.Rx('uri','ip:192.168.2.1'); + % + % AD7134 Datasheet + + properties (Nontunable, Hidden) + channel_names = {'voltage0','voltage1','voltage2','voltage3'}; + end + + methods + %% Constructor + function obj = Rx(varargin) + obj = obj@adi.AD7134.Base('ad7134','ad7134',varargin{:}); + end + end + +end diff --git a/+adi/Contents.m b/+adi/Contents.m index e868387..5c4bf04 100644 --- a/+adi/Contents.m +++ b/+adi/Contents.m @@ -76,4 +76,6 @@ % AD5592r - ADC % AD5593r - ADC % AD5710r - DAC -% AD5706r - DAC \ No newline at end of file +% AD5706r - DAC +% AD4134 - ADC +% AD4134 - ADC \ No newline at end of file diff --git a/CI/gen_doc/docs/_pages/index.md b/CI/gen_doc/docs/_pages/index.md index 20b2888..74e1d47 100644 --- a/CI/gen_doc/docs/_pages/index.md +++ b/CI/gen_doc/docs/_pages/index.md @@ -66,3 +66,5 @@ The following have device-specific implementations in MATLAB and Simulink. If a | AD5706r | Zedboard | Yes | No | ADI (2021b) | | AD7124-4 | Zedboard | Yes | No | ADI (2021b) | | AD7124-8 | Zedboard | Yes | No | ADI (2021b) | +| AD7134 | Zedboard | Yes | No | ADI (2021b) | +| AD4134 | 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 f068e7b..758601f 100644 --- a/CI/gen_doc/docs/gen_sysobj_doc.m +++ b/CI/gen_doc/docs/gen_sysobj_doc.m @@ -53,6 +53,8 @@ , {'AD5593r', {'Rx'}}... , {'AD5710r', {'Tx'}}... , {'AD5706r', {'Tx'}}... + , {'AD7134', {'Rx'}}... + , {'AD4134', {'Rx'}}... %{'QuadMxFE',{'Rx','Tx'}}... }; diff --git a/docs/source/index.rst b/docs/source/index.rst index ff01caa..6bd4a96 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -89,4 +89,6 @@ The following have device-specific implementations in MATLAB and Simulink. In ge "AD5592r", "SDP-K1", "Yes", "No", "ADI (2021b)" "AD5593r", "SDP-K1", "Yes", "No", "ADI (2021b)" "AD5710r", "SDP-K1", "Yes", "No", "ADI (2021b)" - "AD5706r", "SDP-K1", "Yes", "No", "ADI (2021b)" \ No newline at end of file + "AD5706r", "SDP-K1", "Yes", "No", "ADI (2021b)", + "AD7134", "SDP-K1", "Yes", "No", "ADI (2021b)", + "AD4134", "SDP-K1", "Yes", "No", "ADI (2021b)" \ No newline at end of file diff --git a/examples/ad4134_DataCapture.m b/examples/ad4134_DataCapture.m new file mode 100644 index 0000000..1fba2aa --- /dev/null +++ b/examples/ad4134_DataCapture.m @@ -0,0 +1,34 @@ +%% Script for capturing and displaying a continuous set of samples from a +%% connected AD7134 or AD4134 board + +% Select the device (uncomment the desired device) +device = 'AD4134'; % 4-channel, 16-bit ADC +% device = 'AD7134'; % 4-channel, 16-bit ADC + +% Instantiate the system object +switch device + case 'AD7134' + rx = adi.AD7134.Rx(); + case 'AD4134' + rx = adi.AD4134.Rx(); +end + +rx.uri = 'ip:analog.local'; + +% Samples per frame cannot exceed 400 if all 4 channels need to be captured +rx.SamplesPerFrame = 400; +rx.EnabledChannels = [1 2 3 4]; + +% Capture data +data = rx(); + +enabledChannels = size(data,2); +figure(1); +for i = 1:enabledChannels + subplot(enabledChannels, 1, i); + plot(data(1:rx.SamplesPerFrame, i)); + title("Channel " + num2str(rx.EnabledChannels(i))); +end + +% Delete the system object +release(rx);