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
87 changes: 15 additions & 72 deletions +adi/+AD3530r/Tx.m
Original file line number Diff line number Diff line change
@@ -1,84 +1,27 @@
classdef Tx < adi.common.Tx & matlabshared.libiio.base & adi.common.Attribute
% AD3530r Precision voltage output DAC Class
% adi.AD3530r.Rx Transmits data to the AD3530r DAC
% The adi.AD3530r.Tx System object is a signal sink that can transmit
% data to the AD3530r.
%
% tx = adi.AD3530r.Tx;
% tx = adi.AD3530r.Tx('uri','ip:192.168.2.1');
%
% TODO: Add link to the data sheet

properties
% SampleRate Sample Rate
% Baseband sampling rate in Hz, specified as a scalar
% in samples per second.
SampleRate
end

properties (Nontunable)
SamplesPerFrame
end

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

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

properties (Hidden, Nontunable, Access = protected)
isOutput = true
end

properties (Nontunable, Hidden)
Timeout = Inf
kernelBuffersCount = 1
dataTypeStr = 'int16'
phyDevName = 'ad3530r'
devName = 'ad3530r'
end

properties (Hidden, Constant)
ComplexData = false
end
classdef Tx < adi.AD353xr.Base & matlabshared.libiio.base & adi.common.Attribute
/* AD3530r Precision voltage output DAC Class
* adi.AD3530r.Tx Transmits data to the AD3530r DAC
* The adi.AD3530r.Tx System object is a signal sink that can transmit
* data to the AD3530r.
*
* tx = adi.AD3530r.Tx;
* tx = adi.AD3530r.Tx('uri','ip:192.168.2.1');
*
* AD3530r Datasheet <https://www.analog.com/en/products/ad3530r.html>
*/

methods

%% Constructor
function obj = Tx(varargin)
obj = obj@matlabshared.libiio.base(varargin{:});
channels = {'voltage0', 'voltage1', 'voltage2', 'voltage3', ...
'voltage4', 'voltage5', 'voltage6', 'voltage7'};
obj = obj@adi.AD353xr.Base('ad3530r', 'ad3530r', 'int16', channels, varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.uri = 'ip:analog.local';
obj.DataSource = 'DMA';
end

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

end
end
end
29 changes: 29 additions & 0 deletions +adi/+AD3532r/Tx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
classdef Tx < adi.AD353xr.Base & matlabshared.libiio.base & adi.common.Attribute
/* AD3532r Precision voltage output DAC Class
* adi.AD3532r.Tx Transmits data to the AD3532r DAC
* The adi.AD3532r.Tx System object is a signal sink that can transmit
* data to the AD3532r.
*
* tx = adi.AD3532r.Tx;
* tx = adi.AD3532r.Tx('uri','ip:192.168.2.1');
*
* AD3532r Datasheet <https://www.analog.com/en/products/ad3532r.html>
*/

methods

%% Constructor
function obj = Tx(varargin)
channels = {'voltage0', 'voltage1', 'voltage2', 'voltage3', ...
'voltage4', 'voltage5', 'voltage6', 'voltage7', ...
'voltage8', 'voltage9', 'voltage10', 'voltage11', ...
'voltage12', 'voltage13', 'voltage14', 'voltage15'};
obj = obj@adi.AD353xr.Base('ad3532r', 'ad3532r', 'int16', channels, varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = 1;
obj.uri = 'ip:analog.local';
obj.DataSource = 'DMA';
end

end
end
129 changes: 129 additions & 0 deletions +adi/+AD353xr/Base.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
classdef Base < adi.common.Tx & adi.common.RxTx & ...
matlabshared.libiio.base & adi.common.Attribute & ...
adi.common.RegisterReadWrite & adi.common.Channel
/* AD353xr is a family of precision voltage output DACs
* AD3530r is 8-channel 16-bit DAC
* AD3532r is 16-channel 16-bit DAC
*/

properties(Nontunable)
/* SamplesPerFrame Samples Per Frame
* Number of samples per frame, specified as an even positive
* integer.
*/
SamplesPerFrame = 400
end

properties
/* SamplingFrequency Sampling Frequency
* Baseband sampling rate in Hz, specified as a scalar
* in samples per second.
*/
SamplingFrequency = '1000000'

/* AllChOperatingMode All Channel Operating Mode
* Set operating mode for all channels
* Options: normal_operation, powerdown_1k, powerdown_100k, tristate
*/
AllChOperatingMode = 'normal_operation'
end

/* Channel names */
properties (Nontunable, Hidden)
channel_names
end

properties (Hidden, Nontunable, Access = protected)
isOutput = true
end

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

properties (Nontunable, Hidden)
Timeout = Inf
kernelBuffersCount = 1
dataTypeStr
phyDevName
devName
end

properties (Hidden, Constant)
ComplexData = false
end

properties (Constant, Hidden)
AllChOperatingModeSet = matlab.system.StringSet([ ...
"normal_operation", "1kohm_to_gnd", "7.7kohm_to_gnd", "32kohm_to_gnd"]);
end

methods

%% Constructor
function obj = Base(phydev, dev, dtype, channels, varargin)
coder.allowpcode('plain');
obj = obj@matlabshared.libiio.base(varargin{:});
obj.phyDevName = phydev;
obj.devName = dev;
obj.dataTypeStr = dtype;
obj.channel_names = channels;
end

function set.SamplingFrequency(obj, value)
/* Set device sampling frequency */
obj.SamplingFrequency = value;
if obj.ConnectedToDevice
obj.setDeviceAttributeRAW('sampling_frequency', num2str(value));
end
end

function set.AllChOperatingMode(obj, value)
/* Set all channel operating mode */
obj.AllChOperatingMode = value;
if obj.ConnectedToDevice
obj.setDeviceAttributeRAW('all_ch_operating_mode', num2str(value));
end
end

/* Destructor */
function delete(obj)
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 doesn't support
* modification to nontunable variables at SetupImpl
*/

obj.setDeviceAttributeRAW('sampling_frequency', num2str(obj.SamplingFrequency));
obj.setDeviceAttributeRAW('all_ch_operating_mode', num2str(obj.AllChOperatingMode));
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 = 'AD353xr DAC';
end

end
end
3 changes: 2 additions & 1 deletion +adi/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@
% <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
% <a href="matlab:help adi.AD5529r ">AD5529r</a> - DAC
% <a href="matlab:help adi.AD5529r ">AD5529r</a> - DAC
% <a href="matlab:help adi.AD3532r ">AD3532r</a> - DAC
4 changes: 3 additions & 1 deletion CI/gen_doc/docs/_pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,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) |
| AD7134 | Zedboard | Yes | No | ADI (2021b) |
| AD4134 | Zedboard | Yes | No | ADI (2021b) |
| AD4134 | Zedboard | Yes | No | ADI (2021b) |
| AD3530R | Zedboard | Yes | No | ADI (2021b) |
| AD3532R | 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 @@ -57,6 +57,8 @@
, {'AD7134', {'Rx'}}...
, {'AD4134', {'Rx'}}...
, {'AD5529r', {'Tx'}}...
, {'AD3530r', {'Tx'}}...
, {'AD3532r', {'Tx'}}...
%{'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 @@ -93,4 +93,5 @@ The following have device-specific implementations in MATLAB and Simulink. In ge
"AD5706r", "SDP-K1", "Yes", "No", "ADI (2021b)",
"AD7134", "SDP-K1", "Yes", "No", "ADI (2021b)",
"AD4134", "SDP-K1", "Yes", "No", "ADI (2021b)"
"AD5529r", "SDP-K1", "Yes", "No", "ADI (2021b)"
"AD5529r", "SDP-K1", "Yes", "No", "ADI (2021b)"
"AD3532r", "SDP-K1", "Yes", "No", "ADI (2021b)"
11 changes: 10 additions & 1 deletion examples/ad3530r_DataStreaming.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@
data = data+2^15;
data = uint16(data);

% Select the device (uncomment the desired device)
device = 'AD3530R'; % 8-channel, 16-bit DAC
% device = 'AD3532R'; % 16-channel, 16-bit DAC

%% Tx set up
% Instantiate the system object
tx = adi.AD3530r.Tx;
switch device
case 'AD3530R'
tx = adi.AD3530r.Tx();
case 'AD3532R'
tx = adi.AD3532r.Tx();
end
% Specify uri
tx.uri = 'ip:analog.local';
tx.EnableCyclicBuffers = true;
Expand Down
Loading