-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adi: adaq4224: Add support for adaq4224_DataCapture.m
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
1 parent
c3f7e5d
commit 1baf75e
Showing
4 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
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 ADAQ4224. | ||
% | ||
% `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) | ||
% Set channel scale value | ||
obj.Scale = value; | ||
if obj.ConnectedToDevice | ||
id = 'voltage0'; | ||
obj.setAttributeRAW(id, 'scale', num2str(value), false); | ||
end | ||
end | ||
|
||
function value = get.Scale(obj) | ||
% Get channel scale value | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
%% Script for capturing and displaying a continuous set of samples from a | ||
%% connected ADAQ4224 board | ||
|
||
% Instantiate the ADAQ4224 Rx system object, and specify the uri in this | ||
% manner | ||
rx = adi.ADAQ4224.Rx('uri','ip:analog.local'); | ||
|
||
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; | ||
|
||
% 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); |