Skip to content

Commit

Permalink
adi: adaq4224: Add support for adaq4224_DataCapture.m
Browse files Browse the repository at this point in the history
1. Add driver for adaq4224.
2. Add example script for data capture.
3. Update index.rst and Contents.m files.

Signed-off-by: SGudla <[email protected]>
  • Loading branch information
SaikiranGudla committed Oct 3, 2024
1 parent c3f7e5d commit 9df1085
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
77 changes: 77 additions & 0 deletions +adi/+ADAQ4224/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
classdef Rx <adi.common.Rx & adi.common.RxTx & ...
adi.AD463x.Base
% ADAQ4224 Precision Data Acquisition (DAQ) Class
%
% adi.ADAQ4224.Rx Receives data from the ADAQ4224
% The adi.ADAQ4224.Rx System object is a signal source that can receive
% data from the AD4002.
%
% `rx = adi.ADAQ4224.Rx;`
% `rx = adi.ADAQ4224.Rx('uri','ip:192.168.2.1');`
%
% ADAQ4224 Datasheet <https://www.analog.com/media/en/technical-documentation/data-sheets/adaq4224.pdf>`_

properties
% Scale Channel Scale Value
Scale = 0.001464843
end

properties (Nontunable, Hidden, Constant)
Type = 'Rx'
end

properties (Hidden)
% Number of frames or buffers of data to capture
FrameCount = 1
end

properties (Nontunable, Hidden)

% Channels present with default register settings -
channel_names = {'voltage0'}
end

properties (Hidden)
Timeout = Inf
kernelBuffersCount = 4
dataTypeStr = 'int64'
phyDevName = 'adaq4224'
devName = 'adaq4224'
end

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

function set.Scale(obj, value)
obj.Scale = value;
if obj.ConnectedToDevice
id = 'voltage0';
obj.setAttributeRAW(id, 'scale', num2str(value), false);
end
end

function value = get.Scale(obj)
value = obj.Scale;
if obj.ConnectedToDevice
value = obj.getAttributeRAW('voltage0', 'scale', false);
end
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
obj.setAttributeRAW('voltage0', 'scale', num2str(obj.Scale), false);
end
end

end
1 change: 1 addition & 0 deletions +adi/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
% <a href="matlab:help adi.AD4030 ">AD4030-24</a> - ADC
% <a href="matlab:help adi.AD4630_16 ">AD4630-16</a> - ADC
% <a href="matlab:help adi.AD4630_24 ">AD4630-24</a> - ADC
% <a href="matlab:help adi.ADAQ4224 ">ADAQ4224</a> - ADAQ
% <a href="matlab:help adi.AD4858 ">AD4858</a> - ADC
% <a href="matlab:help adi.AD7380 ">AD7380</a> - ADC
% <a href="matlab:help adi.AD7768 ">AD7768</a> - ADC
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The following have device-specific implementations in MATLAB and Simulink. In ge
"AD4030-24", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD4630-16", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD4630-24", "Zedboard", "Yes", "No", "ADI (2021b)"
"ADAQ4224", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD4858", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD2S1210", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD4000", "Zedboard", "Yes", "No", "ADI (2021b)"
Expand Down
54 changes: 54 additions & 0 deletions examples/adaq4224_DataCapture.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
%% Script for capturing and displaying data from a connected ADAQ4224 board


% Instantiate the ADAQ4224 Rx system object, and specify the uri in this
% manner
%ip:analog.local
rx = adi.ADAQ4224.Rx('uri','ip:10.32.22.194');

rx.SamplesPerFrame = 4096; % Using values less than 3660 can yield poor
% performance, generally
rx.SampleRate = '2000000';
rx.SampleAveragingLength = '16';

% The parameter below specifies the number of frames or buffers to capture.
% Refer to the Streaming section in the documentation if discontinuities
% are observed in the acquired data.
rx.FrameCount = 1;

% Only a select few channel groupings yield sensible outputs. Refer to the
% Limitations section in the documentation for more details
rx.EnabledChannels = [1];

% Set channel scale value
rx.Scale = 0.001464843;
fprintf("Sampling with gain set to %s\n", num2str(rx.Scale));

% Capture data
data = rx();

enabledChannels = size(data, 2);
figure(1);
for i = 1:enabledChannels
subplot(enabledChannels, 1, i);
plot(data(1:rx.SamplesPerFrame * rx.FrameCount, i));
title("Channel " + num2str(rx.EnabledChannels(i)));
end

% Set channel scale value
rx.Scale = 0.000219726;
fprintf("Sampling with gain set to %s\n", num2str(rx.Scale))

% Capture data
data = rx();

enabledChannels = size(data, 2);
figure(2);
for i = 1:enabledChannels
subplot(enabledChannels, 1, i);
plot(data(1:rx.SamplesPerFrame * rx.FrameCount, i));
title("Channel " + num2str(rx.EnabledChannels(i)));
end

% Delete the system object
release(rx);

0 comments on commit 9df1085

Please sign in to comment.