From c6c91960cdc8f703f52a9fcccd57bd7c6eff43d2 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 27 Sep 2024 10:29:25 +0200 Subject: [PATCH] adi:AD7606x:Add support for AD7606x family of parts This change adds support for AD7605-4, AD7606-4, AD7606-6, AD7606-8, AD7606B, AD7606C-16 and AD7606C-18 parts. All these parts are in the same family of precision ADCs. Signed-off-by: Alexandru Ardelean --- +adi/+AD7605_4/Rx.m | 25 ++++++++++ +adi/+AD7606B/Rx.m | 25 ++++++++++ +adi/+AD7606C_16/Rx.m | 25 ++++++++++ +adi/+AD7606C_18/Rx.m | 25 ++++++++++ +adi/+AD7606_4/Rx.m | 25 ++++++++++ +adi/+AD7606_6/Rx.m | 25 ++++++++++ +adi/+AD7606_8/Rx.m | 26 ++++++++++ +adi/+AD7606x/Base.m | 88 ++++++++++++++++++++++++++++++++++ +adi/Contents.m | 7 +++ examples/ad7606B_DataCapture.m | 27 +++++++++++ 10 files changed, 298 insertions(+) create mode 100644 +adi/+AD7605_4/Rx.m create mode 100644 +adi/+AD7606B/Rx.m create mode 100644 +adi/+AD7606C_16/Rx.m create mode 100644 +adi/+AD7606C_18/Rx.m create mode 100644 +adi/+AD7606_4/Rx.m create mode 100644 +adi/+AD7606_6/Rx.m create mode 100644 +adi/+AD7606_8/Rx.m create mode 100644 +adi/+AD7606x/Base.m create mode 100644 examples/ad7606B_DataCapture.m diff --git a/+adi/+AD7605_4/Rx.m b/+adi/+AD7605_4/Rx.m new file mode 100644 index 0000000..b262a05 --- /dev/null +++ b/+adi/+AD7605_4/Rx.m @@ -0,0 +1,25 @@ +classdef Rx < adi.common.Rx & adi.common.RxTx ... + & adi.AD7606x.Base + % AD7605-4 Precision ADC Class + % + % adi.AD7605_4.Rx Receives data from the AD7605 ADC + % The adi.AD7605_4.Rx System object is a signal source that can receive + % data from the AD7605-4. + % + % `rx = adi.AD7605_4.Rx;` + % `rx = adi.AD7605_4.Rx('uri','ip:192.168.2.1');` + % + % `AD7605-4 Datasheet `_ + + properties (Nontunable, Hidden) + channel_names = {'voltage0','voltage1','voltage2','voltage3'}; + end + + methods + %% Constructor + function obj = Rx(varargin) + obj = obj@adi.AD7606x.Base('ad7605-4','ad7605-4','int16',varargin{:}); + end + end + + end diff --git a/+adi/+AD7606B/Rx.m b/+adi/+AD7606B/Rx.m new file mode 100644 index 0000000..14736e8 --- /dev/null +++ b/+adi/+AD7606B/Rx.m @@ -0,0 +1,25 @@ +classdef Rx < adi.common.Rx & adi.common.RxTx ... + & adi.AD7606x.Base + % AD7606B Precision ADC Class + % + % adi.AD7606B.Rx Receives data from the AD7606B ADC + % The adi.AD7606B.Rx System object is a signal source that can receive + % data from the AD7606B. + % + % `rx = adi.AD7606B.Rx;` + % `rx = adi.AD7606B.Rx('uri','ip:192.168.2.1');` + % + % `AD7606 Datasheet `_ + + properties (Nontunable, Hidden) + channel_names = {'voltage0','voltage1','voltage2','voltage3','voltage4','voltage5','voltage6','voltage7'}; + end + + methods + %% Constructor + function obj = Rx(varargin) + obj = obj@adi.AD7606x.Base('ad7606b','ad7606b','int16',varargin{:}); + end + end + + end diff --git a/+adi/+AD7606C_16/Rx.m b/+adi/+AD7606C_16/Rx.m new file mode 100644 index 0000000..9d961e6 --- /dev/null +++ b/+adi/+AD7606C_16/Rx.m @@ -0,0 +1,25 @@ +classdef Rx < adi.common.Rx & adi.common.RxTx ... + & adi.AD7606x.Base + % AD7606C-16 Precision ADC Class + % + % adi.AD7606C_16.Rx Receives data from the AD7606C-16 ADC + % The adi.AD7606C_16.Rx System object is a signal source that can receive + % data from the AD7606C-16. + % + % `rx = adi.AD7606C_16.Rx;` + % `rx = adi.AD7606C_16.Rx('uri','ip:192.168.2.1');` + % + % `AD7606 Datasheet `_ + + properties (Nontunable, Hidden) + channel_names = {'voltage0','voltage1','voltage2','voltage3','voltage4','voltage5','voltage6','voltage7'}; + end + + methods + %% Constructor + function obj = Rx(varargin) + obj = obj@adi.AD7606x.Base('ad7606c-16','ad7606c-16','int16',varargin{:}); + end + end + + end diff --git a/+adi/+AD7606C_18/Rx.m b/+adi/+AD7606C_18/Rx.m new file mode 100644 index 0000000..51ba17a --- /dev/null +++ b/+adi/+AD7606C_18/Rx.m @@ -0,0 +1,25 @@ +classdef Rx < adi.common.Rx & adi.common.RxTx ... + & adi.AD7606x.Base + % AD7606C-18 Precision ADC Class + % + % adi.AD7606C_18.Rx Receives data from the AD7606C-18 ADC + % The adi.AD7606C_18.Rx System object is a signal source that can receive + % data from the AD7606C-18. + % + % `rx = adi.AD7606C_18.Rx;` + % `rx = adi.AD7606C_18.Rx('uri','ip:192.168.2.1');` + % + % `AD7606 Datasheet `_ + + properties (Nontunable, Hidden) + channel_names = {'voltage0','voltage1','voltage2','voltage3','voltage4','voltage5','voltage6','voltage7'}; + end + + methods + %% Constructor + function obj = Rx(varargin) + obj = obj@adi.AD7606x.Base('ad7606c-18','ad7606c-18','int32',varargin{:}); + end + end + + end diff --git a/+adi/+AD7606_4/Rx.m b/+adi/+AD7606_4/Rx.m new file mode 100644 index 0000000..bbb6cf2 --- /dev/null +++ b/+adi/+AD7606_4/Rx.m @@ -0,0 +1,25 @@ +classdef Rx < adi.common.Rx & adi.common.RxTx ... + & adi.AD7606x.Base + % AD7606-4 Precision ADC Class + % + % adi.AD7606_4.Rx Receives data from the AD7606-4 ADC + % The adi.AD7606-4.Rx System object is a signal source that can receive + % data from the AD7606-4. + % + % `rx = adi.AD7606_4.Rx;` + % `rx = adi.AD7606_4.Rx('uri','ip:192.168.2.1');` + % + % `AD7606-4 Datasheet `_ + + properties (Nontunable, Hidden) + channel_names = {'voltage0','voltage1','voltage2','voltage3'}; + end + + methods + %% Constructor + function obj = Rx(varargin) + obj = obj@adi.AD7606x.Base('ad7606-4','ad7606-4','int16',varargin{:}); + end + end + + end diff --git a/+adi/+AD7606_6/Rx.m b/+adi/+AD7606_6/Rx.m new file mode 100644 index 0000000..de779ad --- /dev/null +++ b/+adi/+AD7606_6/Rx.m @@ -0,0 +1,25 @@ +classdef Rx < adi.common.Rx & adi.common.RxTx ... + & adi.AD7606x.Base + % AD7606-6 Precision ADC Class + % + % adi.AD7606_6.Rx Receives data from the AD7606-6 ADC + % The adi.AD7606-6.Rx System object is a signal source that can receive + % data from the AD7606-6. + % + % `rx = adi.AD7606_4.Rx;` + % `rx = adi.AD7606_4.Rx('uri','ip:192.168.2.1');` + % + % `AD7606-6 Datasheet `_ + + properties (Nontunable, Hidden) + channel_names = {'voltage0','voltage1','voltage2','voltage3','voltage4','voltage5'}; + end + + methods + %% Constructor + function obj = Rx(varargin) + obj = obj@adi.AD7606x.Base('ad7606-6','ad7606-6','int16',varargin{:}); + end + end + + end diff --git a/+adi/+AD7606_8/Rx.m b/+adi/+AD7606_8/Rx.m new file mode 100644 index 0000000..124c36b --- /dev/null +++ b/+adi/+AD7606_8/Rx.m @@ -0,0 +1,26 @@ +classdef Rx < adi.common.Rx & adi.common.RxTx ... + & adi.AD7606x.Base + % AD7606-8 Precision ADC Class + % + % adi.AD7606_8.Rx Receives data from the AD7606-8 ADC + % The adi.AD7606_8.Rx System object is a signal source that can receive + % data from the AD7606-8. + % In the datasheet, this is referred to as 'AD7606'. + % + % `rx = adi.AD7606_8.Rx;` + % `rx = adi.AD7606_8.Rx('uri','ip:192.168.2.1');` + % + % `AD7606 Datasheet `_ + + properties (Nontunable, Hidden) + channel_names = {'voltage0','voltage1','voltage2','voltage3','voltage4','voltage5','voltage6','voltage7'}; + end + + methods + %% Constructor + function obj = Rx(varargin) + obj = obj@adi.AD7606x.Base('ad7606-8','ad7606-8','int16',varargin{:}); + end + end + + end diff --git a/+adi/+AD7606x/Base.m b/+adi/+AD7606x/Base.m new file mode 100644 index 0000000..00793f7 --- /dev/null +++ b/+adi/+AD7606x/Base.m @@ -0,0 +1,88 @@ +classdef Base < adi.common.Rx & adi.common.RxTx & ... + matlabshared.libiio.base & adi.common.Attribute & ... + adi.common.RegisterReadWrite & adi.common.Channel + % AD7606x Precision ADC Class + + properties (Nontunable) + % 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 + phyDevName + devName + end + + properties (Hidden, Constant) + ComplexData = false + end + + methods + %% Constructor + function obj = Base(phydev,dev,dataTypeStr,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.dataTypeStr = dataTypeStr; + 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 = 'AD7606x ADC'; + end + end + +end diff --git a/+adi/Contents.m b/+adi/Contents.m index c2d5536..ea100b8 100644 --- a/+adi/Contents.m +++ b/+adi/Contents.m @@ -24,6 +24,13 @@ % AD4630-24 - ADC % AD4858 - ADC % AD7380 - ADC +% AD7605_4 - ADC +% AD7606_4 - ADC +% AD7606_6 - ADC +% AD7606_8 - ADC +% AD7606B - ADC +% AD7606C_16 - ADC +% AD7606C_18 - ADC % AD7768 - ADC % AD7768-1 - ADC % AD2S1210 - Resolver-to-Digital Converter diff --git a/examples/ad7606B_DataCapture.m b/examples/ad7606B_DataCapture.m new file mode 100644 index 0000000..b74e746 --- /dev/null +++ b/examples/ad7606B_DataCapture.m @@ -0,0 +1,27 @@ +%% Script for capturing and displaying a continuous set of samples from a +%% connected AD7606B board + +%% Trigger setup needs to be performed before this example script can be run +%% Refer to the Limitations section in the documentation for details + +% Instantiate the system object +rx = adi.AD7606B.Rx; +% Specify uri +rx.uri = 'ip:analog.local'; +rx.SamplesPerFrame = 4096; % Using values less than 3660 can yield poor +% performance, generally +rx.EnabledChannels = [1 2]; + +% 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);