Skip to content
Open
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
25 changes: 25 additions & 0 deletions +adi/+AD4134/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
classdef Rx < adi.common.Rx & adi.common.RxTx ...
& adi.AD7134.Base
% AD4134 Precision ADC Class
%
% adi.AD4134.Rx Receives data from the AD4134 ADC
% The adi.AD4134.Rx System object is a signal source that can receive
% data from the AD4134.
%
% rx = adi.AD4134.Rx;
% rx = adi.AD4134.Rx('uri','ip:192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4134.pdf">AD4134 Datasheet</a>

properties (Nontunable, Hidden)
channel_names = {'voltage0','voltage1','voltage2','voltage3'};
end

methods
%% Constructor
function obj = Rx(varargin)
obj = obj@adi.AD7134.Base('ad4134','ad4134',varargin{:});
end
end

end
93 changes: 93 additions & 0 deletions +adi/+AD7134/Base.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
classdef Base < adi.common.Rx & adi.common.RxTx & ...
matlabshared.libiio.base & adi.common.Attribute & ...
adi.common.RegisterReadWrite & adi.common.Channel
% AD7134 Precision ADC Base Class
% AD7134 is a 4-channel, 16-bit precision ADC
% AD4134 is a 4-channel, 16-bit precision ADC

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 = 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 = 'uint16'
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 = obj@matlabshared.libiio.base(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
delete@adi.common.RxTx(obj);
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

%% 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 = 'AD7134 ADC';
end
end

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

properties (Nontunable, Hidden)
channel_names = {'voltage0','voltage1','voltage2','voltage3'};
end

methods
%% Constructor
function obj = Rx(varargin)
obj = obj@adi.AD7134.Base('ad7134','ad7134',varargin{:});
end
end

end
4 changes: 3 additions & 1 deletion +adi/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@
% <a href="matlab:help adi.AD5592r ">AD5592r</a> - ADC
% <a href="matlab:help adi.AD5593r ">AD5593r</a> - ADC
% <a href="matlab:help adi.AD5710r ">AD5710r</a> - DAC
% <a href="matlab:help adi.AD5706r ">AD5706r</a> - DAC
% <a href="matlab:help adi.AD5706r ">AD5706r</a> - DAC
% <a href="matlab:help adi.AD4134 ">AD4134</a> - ADC
% <a href="matlab:help adi.AD7134 ">AD4134</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 @@ -66,3 +66,5 @@ The following have device-specific implementations in MATLAB and Simulink. If a
| AD5706r | Zedboard | Yes | No | ADI (2021b) |
| AD7124-4 | Zedboard | Yes | No | ADI (2021b) |
| AD7124-8 | Zedboard | Yes | No | ADI (2021b) |
| AD7134 | Zedboard | Yes | No | ADI (2021b) |
| AD4134 | 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 @@ -53,6 +53,8 @@
, {'AD5593r', {'Rx'}}...
, {'AD5710r', {'Tx'}}...
, {'AD5706r', {'Tx'}}...
, {'AD7134', {'Rx'}}...
, {'AD4134', {'Rx'}}...
%{'QuadMxFE',{'Rx','Tx'}}...
};

Expand Down
4 changes: 3 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,6 @@ The following have device-specific implementations in MATLAB and Simulink. In ge
"AD5592r", "SDP-K1", "Yes", "No", "ADI (2021b)"
"AD5593r", "SDP-K1", "Yes", "No", "ADI (2021b)"
"AD5710r", "SDP-K1", "Yes", "No", "ADI (2021b)"
"AD5706r", "SDP-K1", "Yes", "No", "ADI (2021b)"
"AD5706r", "SDP-K1", "Yes", "No", "ADI (2021b)",
"AD7134", "SDP-K1", "Yes", "No", "ADI (2021b)",
"AD4134", "SDP-K1", "Yes", "No", "ADI (2021b)"
34 changes: 34 additions & 0 deletions examples/ad4134_DataCapture.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
%% Script for capturing and displaying a continuous set of samples from a
%% connected AD7134 or AD4134 board

% Select the device (uncomment the desired device)
device = 'AD4134'; % 4-channel, 16-bit ADC
% device = 'AD7134'; % 4-channel, 16-bit ADC

% Instantiate the system object
switch device
case 'AD7134'
rx = adi.AD7134.Rx();
case 'AD4134'
rx = adi.AD4134.Rx();
end

rx.uri = 'ip:analog.local';

% Samples per frame cannot exceed 400 if all 4 channels need to be captured
rx.SamplesPerFrame = 400;
rx.EnabledChannels = [1 2 3 4];

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