Skip to content

Commit

Permalink
adi:ad559xr:Added Matlab Support
Browse files Browse the repository at this point in the history
Added Rx.m for ad5592r and ad5593r
Added example script for data capture

Signed-off-by: Disha D <[email protected]>
  • Loading branch information
D-Disha committed Feb 10, 2025
1 parent ac43606 commit 81ac92c
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 1 deletion.
26 changes: 26 additions & 0 deletions +adi/+AD5592r/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
classdef Rx < adi.common.Rx & adi.common.RxTx ...
& adi.AD559xr.Base
% AD5592r Precision ADC Class
% adi.AD5592r.Rx Receives data from the AD5592r ADC
% The adi.AD5592r.Rx System object is a signal source that can receive
% data from the AD5592r.
%
% rx = adi.AD5592r.Rx;
% rx = adi.AD5592r.Rx('uri','ip:192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad5592r.pdf"</a>

properties (Nontunable, Hidden)
channel_names = {'voltage0','voltage1','voltage2'...
'voltage3','voltage4','voltage5','voltage6','voltage7'};
end

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad5592r','ad5592r',varargin{:});
end
end

end

26 changes: 26 additions & 0 deletions +adi/+AD5593r/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
classdef Rx < adi.common.Rx & adi.common.RxTx ...
& adi.AD559xr.Base
% AD5593r Precision ADC Class
% adi.AD5593r.Rx Receives data from the AD5593r ADC
% The adi.AD5593r.Rx System object is a signal source that can receive
% data from the AD5593r.
%
% rx = adi.AD5593r.Rx;
% rx = adi.AD5593r.Rx('uri','ip:192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/AD5593r.pdf"</a>

properties (Nontunable, Hidden)
channel_names = {'voltage0','voltage1','voltage2'...
'voltage3','voltage4','voltage5','voltage6','voltage7'};
end

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected]('ad5593r','ad5593r',varargin{:});
end
end

end

84 changes: 84 additions & 0 deletions +adi/+AD559xr/Base.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
classdef Base < adi.common.Rx & adi.common.RxTx & ...
matlabshared.libiio.base & adi.common.Attribute & ...
adi.common.RegisterReadWrite & adi.common.Channel
% AD559xr Precision ADC Class
% AD5592r is a SPI Interface ADC
% AD5593r is an I2C Interface ADC

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 = 'int16'
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 = [email protected](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
[email protected](obj);
end

end

%% API Functions
methods (Hidden, Access = protected)
function setupInit(obj)
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 = 'AD559xr ADC';
end
end

end
2 changes: 2 additions & 0 deletions +adi/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@
% <a href="matlab:help adi.AD7124_4 ">AD7124_4</a> - ADC
% <a href="matlab:help adi.AD7124_8 ">AD7124_8</a> - ADC
% <a href="matlab:help adi.AD4080 ">AD4080</a> - ADC
% <a href="matlab:help adi.AD5592r ">AD5592r</a> - ADC
% <a href="matlab:help adi.AD5593r ">AD5593r</a> - ADC
2 changes: 2 additions & 0 deletions CI/gen_doc/docs/_pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ The following have device-specific implementations in MATLAB and Simulink. If a
| AD7124-4 | Zedboard | Yes | No | ADI (2021b) |
| AD7124-8 | Zedboard | Yes | No | ADI (2021b) |
| AD4080 | Zedboard | Yes | No | ADI (2021b) |
| AD5592r | Zedboard | Yes | No | ADI (2021b) |
| AD5593r | Zedboard | Yes | No | ADI (2021b) |
=======
2 changes: 2 additions & 0 deletions CI/gen_doc/docs/gen_sysobj_doc.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
, {'AD7124_4', {'Rx'}}...
, {'AD7124_8', {'Rx'}}...
, {'AD4080', {'Rx'}}...
, {'AD5592r', {'Rx'}}...
, {'AD5593r', {'Rx'}}...
%{'QuadMxFE',{'Rx','Tx'}}...
};

Expand Down
3 changes: 2 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ The following have device-specific implementations in MATLAB and Simulink. In ge
"AD7195", "SDP-K1", "Yes", "No", "ADI (2021b)"
"AD4170", "SDP-K1", "Yes", "No", "ADI (2021b)"
"AD4190", "SDP-K1", "Yes", "No", "ADI (2021b)"

"AD5592r", "SDP-K1", "Yes", "No", "ADI (2021b)"
"AD5593r", "SDP-K1", "Yes", "No", "ADI (2021b)"
26 changes: 26 additions & 0 deletions examples/ad559xr_DataCapture.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
%% Script for capturing and displaying a continuous set of samples from a
%% connected AD559xr board

% Instantiate the system object
rx = adi.AD5592r.Rx();
rx.uri = 'ip:analog.local';

% Samples Per Frame
rx.SamplesPerFrame = 400;

% Enable the channels that are selected as ADC in the firmware
rx.EnabledChannels = [1 2 3 4 5 6 7 8];

% 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);

0 comments on commit 81ac92c

Please sign in to comment.