Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions +adi/+AD4692/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
classdef Rx < adi.common.Rx & matlabshared.libiio.base & adi.common.Attribute
% AD4692 Precision ADC Class
% adi.AD4692.Rx Receives data from the AD4692 ADC
% The adi.AD4692.Rx System object is a signal source that can receive
% data from the AD4692.
%
% rx = adi.AD4692.Rx;
% rx = adi.AD4692.Rx('uri','192.168.2.1');
%

properties (Nontunable)
% SampleRate Sample Rate
% Baseband sampling rate in Hz, specified as a scalar
% in samples per second.
SampleRate = '500000'

% SamplesPerFrame Samples Per Frame
% Number of samples per frame, specified as an even positive
% integer.
SamplesPerFrame = 1024
end

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

% Channel names
properties (Nontunable, Hidden, Constant)
channel_names = {'voltage0'}
end

% isOutput
properties (Hidden, Nontunable, Access = protected)
isOutput = false
end

properties (Nontunable, Hidden)
Timeout = Inf
kernelBuffersCount = 2
dataTypeStr = 'int32'
phyDevName = 'ad4692'
devName = 'ad4692'
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;
obj.uri = 'ip:analog.local';
end

function flush(obj)
% Flush the buffer
flushBuffers(obj);
end

function set.SampleRate(obj, value)
% Set device sampling rate
obj.SampleRate = value;
if obj.ConnectedToDevice
obj.setDeviceAttributeRAW('sampling_frequency', value);
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.setDeviceAttributeRAW('sampling_frequency',num2str(obj.SampleRate));
end

end
end
1 change: 1 addition & 0 deletions +adi/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
% <a href="matlab:help adi.AD4062 ">AD4062</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.AD4692 ">AD4692</a> - ADC
% <a href="matlab:help adi.AD4170 ">AD4170</a> - ADC
% <a href="matlab:help adi.AD4190 ">AD4190</a> - ADC
% <a href="matlab:help adi.ADAQ4224 ">ADAQ4224</a> - ADAQ
Expand Down
1 change: 1 addition & 0 deletions CI/gen_doc/docs/_pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The following have device-specific implementations in MATLAB and Simulink. If a
| AD4080 | Zedboard | Yes | No | ADI (2021b) |
| AD4170 | Zedboard | Yes | No | ADI (2021b) |
| AD4190 | Zedboard | Yes | No | ADI (2021b) |
| AD4692 | Zedboard | Yes | No | ADI (2021b) |
| AD5592r | Zedboard | Yes | No | ADI (2021b) |
| AD5593r | Zedboard | Yes | No | ADI (2021b) |
| AD5710r | Zedboard | Yes | No | ADI (2021b) |
Expand Down
1 change: 1 addition & 0 deletions CI/gen_doc/docs/gen_sysobj_doc.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
, {'AD4062', {'Rx'}}...
, {'AD4170', {'Rx'}}...
, {'AD4190', {'Rx'}}...
, {'AD4692', {'Rx'}}...
, {'AD5760', {'Tx'}}...
, {'AD5780', {'Tx'}}...
, {'AD5781', {'Tx'}}...
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The following have device-specific implementations in MATLAB and Simulink. In ge
"AD4020", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD4021", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD4022", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD4692", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD5760", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD5780", "Zedboard", "Yes", "No", "ADI (2021b)"
"AD5781", "Zedboard", "Yes", "No", "ADI (2021b)"
Expand Down
29 changes: 29 additions & 0 deletions examples/ad4692_DataCapture.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
%% Script for capturing and displaying a continuous set of samples from a
%% connected AD4692 board

% Instantiate the system object
rx = adi.AD4692.Rx;

% Specify uri
rx.uri = 'serial:COM4,230400';
rx.SamplesPerFrame = 400; % Using values less than 3660 can yield poor

% performance, generally
rx.EnabledChannels = [1];

% Set the sampling rate
rx.SampleRate = 500000;

% Capture data
data = rx();

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

% Delete the system object
release(rx);
Loading