From 2201cf7e06c2d7b02787376804719edf539335bb Mon Sep 17 00:00:00 2001 From: Anush Shetty Date: Fri, 17 Apr 2026 16:34:09 +0530 Subject: [PATCH] adi: ad4113: Add support for ad4113 1. Add driver for ad4113 2. Add example script for data streaming. 3. Update index.rst and Contents.m files. Signed-off-by: Anush Shetty --- +adi/+AD4113/Rx.m | 74 ++++++++++++++++++++++++++++++++ +adi/Contents.m | 1 + CI/gen_doc/docs/_pages/index.md | 1 + CI/gen_doc/docs/gen_sysobj_doc.m | 1 + docs/source/index.rst | 1 + examples/ad4113_DataCapture.m | 22 ++++++++++ 6 files changed, 100 insertions(+) create mode 100644 +adi/+AD4113/Rx.m create mode 100644 examples/ad4113_DataCapture.m diff --git a/+adi/+AD4113/Rx.m b/+adi/+AD4113/Rx.m new file mode 100644 index 0000000..ddc8a34 --- /dev/null +++ b/+adi/+AD4113/Rx.m @@ -0,0 +1,74 @@ +classdef Rx < adi.common.Rx & matlabshared.libiio.base & adi.common.Attribute + % AD4113 Precision ADC Class + % + % adi.AD4113.Rx Receives data from the AD4113 ADC + % The adi.AD4113.Rx System object is a signal source that can receive + % data from the AD4113. + % + % `rx = adi.AD4113.Rx;` + % `rx = adi.AD4113.Rx('serial:COM59,230400');` + % + % `AD4113 Datasheet `_ + + properties (Nontunable) + % SamplesPerFrame Samples Per Frame + % Number of samples per frame, specified as an even positive + % integer. + SamplesPerFrame = 400 + end + +% Channel names + properties (Nontunable, Hidden, Constant) + channel_names = { ... + 'voltage0', 'voltage1', 'voltage2', 'voltage3', ... + 'voltage4', 'voltage5', 'voltage6', 'voltage7', ... + 'voltage8', 'voltage9', 'voltage10', 'voltage11', ... + 'voltage12', 'voltage13', 'voltage14', 'voltage15'} + end + + % isOutput + properties (Hidden, Nontunable, Access = protected) + isOutput = false + end + + properties (Nontunable, Hidden) + Timeout = Inf + kernelBuffersCount = 1 + dataTypeStr = 'int32' + phyDevName = 'ad4113' + devName = 'ad4113' + end + + properties (Nontunable, Hidden, Constant) + Type = 'Rx' + end + + properties (Hidden, Constant) + ComplexData = false + end + + methods + + %% Constructor + function obj = Rx(varargin) + % Initialize the Rx object + obj = obj@matlabshared.libiio.base(varargin{:}); + obj.enableExplicitPolling = false; + obj.EnabledChannels = 1; + obj.BufferTypeConversionEnable = true; + 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 +end diff --git a/+adi/Contents.m b/+adi/Contents.m index e868387..afc897f 100644 --- a/+adi/Contents.m +++ b/+adi/Contents.m @@ -24,6 +24,7 @@ % AD4052 - ADC % AD4060 - ADC % AD4062 - ADC +% AD4113 - ADC % AD4630-16 - ADC % AD4630-24 - ADC % AD4692 - ADC diff --git a/CI/gen_doc/docs/_pages/index.md b/CI/gen_doc/docs/_pages/index.md index 20b2888..b7f0bda 100644 --- a/CI/gen_doc/docs/_pages/index.md +++ b/CI/gen_doc/docs/_pages/index.md @@ -57,6 +57,7 @@ The following have device-specific implementations in MATLAB and Simulink. If a | AD4021 | Zedboard | Yes | No | ADI (2021b) | | AD4022 | Zedboard | Yes | No | ADI (2021b) | | AD4080 | Zedboard | Yes | No | ADI (2021b) | +| AD4113 | Zedboard | Yes | No | ADI (2021b) | | AD4170 | Zedboard | Yes | No | ADI (2021b) | | AD4190 | Zedboard | Yes | No | ADI (2021b) | | AD4692 | Zedboard | Yes | No | ADI (2021b) | diff --git a/CI/gen_doc/docs/gen_sysobj_doc.m b/CI/gen_doc/docs/gen_sysobj_doc.m index f068e7b..4632e74 100644 --- a/CI/gen_doc/docs/gen_sysobj_doc.m +++ b/CI/gen_doc/docs/gen_sysobj_doc.m @@ -38,6 +38,7 @@ , {'AD4022', {'Rx'}}... , {'AD4060', {'Rx'}}... , {'AD4062', {'Rx'}}... + , {'AD4113', {'Rx'}}... , {'AD4170', {'Rx'}}... , {'AD4190', {'Rx'}}... , {'AD4692', {'Rx'}}... diff --git a/docs/source/index.rst b/docs/source/index.rst index ff01caa..544f8b2 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -78,6 +78,7 @@ The following have device-specific implementations in MATLAB and Simulink. In ge "AD4052", "SDP-K1", "Yes", "No", "ADI (2021b)" "AD4060", "SDP-K1", "Yes", "No", "ADI (2021b)" "AD4062", "SDP-K1", "Yes", "No", "ADI (2021b)" + "AD4113", "SDP-K1", "Yes", "No", "ADI (2021b)" "AD4170", "SDP-K1", "Yes", "No", "ADI (2021b)" "AD7190", "SDP-K1", "Yes", "No", "ADI (2021b)" "AD7192", "SDP-K1", "Yes", "No", "ADI (2021b)" diff --git a/examples/ad4113_DataCapture.m b/examples/ad4113_DataCapture.m new file mode 100644 index 0000000..8523884 --- /dev/null +++ b/examples/ad4113_DataCapture.m @@ -0,0 +1,22 @@ +%% Script for capturing and displaying a continuous set of samples from a +%% connected AD4113 board + +% Instantiate the system object +rx = adi.AD4113.Rx(); +rx.uri = 'serial:COM35,230400,8n1n'; +rx.SamplesPerFrame = 400; +rx.EnabledChannels = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]; + +% 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); \ No newline at end of file