-
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.
Add precision toolbox support for AD5760, AD5780, AD5781, AD5790, AD5791 DACs Signed-off-by: SGudla <[email protected]>
- Loading branch information
1 parent
366160e
commit 21108f8
Showing
9 changed files
with
765 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,133 @@ | ||
classdef Tx < adi.AD579x.Base & matlabshared.libiio.base & adi.common.Attribute | ||
% AD5760 Voltage output DAC Class | ||
% adi.AD5760.Tx Transmits data to the AD5760 DAC | ||
% The adi.AD5760.Tx System object is a signal sink that can transmit | ||
% data to the AD5760. | ||
% | ||
% tx = adi.AD5760.Tx; | ||
% tx = adi.AD5760.Tx('uri','ip:192.168.2.1'); | ||
% | ||
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad5760.pdf">AD5760 Datasheet</a> | ||
|
||
properties | ||
SampleRate | ||
CodeSelect | ||
PowerDown | ||
Raw | ||
end | ||
|
||
% Channel names | ||
properties (Nontunable, Hidden) | ||
channel_names = {'voltage0'} | ||
end | ||
|
||
properties (Hidden, Nontunable, Access = protected) | ||
isOutput = true | ||
end | ||
|
||
properties (Nontunable, Hidden, Constant) | ||
Type = 'Tx' | ||
end | ||
|
||
properties (Nontunable, Hidden) | ||
Timeout = Inf | ||
kernelBuffersCount = 1 | ||
dataTypeStr = 'int16' | ||
phyDevName = 'ad5760' | ||
devName = 'ad5760' | ||
end | ||
|
||
properties (Constant, Hidden) | ||
CodeSelectSet = matlab.system.StringSet([ ... | ||
"2s_complement", "binary_offset"]); | ||
end | ||
|
||
methods | ||
|
||
%% Constructor | ||
function obj = Tx(varargin) | ||
obj = [email protected](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 | ||
|
||
function set.CodeSelect(obj, value) | ||
% Set code select option | ||
obj.CodeSelect = value; | ||
if obj.ConnectedToDevice | ||
id = 'voltage0'; | ||
obj.setDeviceAttributeRAW(id, 'code_select', num2str(value), true) | ||
end | ||
end | ||
|
||
function set.PowerDown(obj, value) | ||
options = [0,1]; | ||
if ~any(value==options) | ||
error(['PowerDown must be one of ',num2str(options)]); | ||
end | ||
% Set channel power down value | ||
obj.PowerDown = value; | ||
if obj.ConnectedToDevice | ||
id = 'voltage0'; | ||
obj.setAttributeRAW(id, 'powerdown', num2str(value), true) | ||
end | ||
end | ||
|
||
function set.Raw(obj, value) | ||
% Set channel raw value | ||
obj.Raw = value; | ||
if obj.ConnectedToDevice | ||
id = 'voltage0'; | ||
obj.setAttributeRAW(id, 'raw', num2str(value), true) | ||
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 doesn't support | ||
% modification to nontunable variables at SetupImpl | ||
|
||
id = 'voltage0'; | ||
|
||
obj.setDeviceAttributeRAW('sampling_frequency', num2str(obj.SampleRate)); | ||
obj.setDeviceAttributeRAW('code_select', num2str(obj.CodeSelect)); | ||
obj.setAttributeRAW(id, 'powerdown', num2str(obj.PowerDown), true); | ||
obj.setAttributeRAW(id, 'raw', num2str(obj.Raw), true); | ||
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 = 'AD5760 DAC'; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
classdef Tx < adi.AD579x.Base & matlabshared.libiio.base & adi.common.Attribute | ||
% AD5780 Voltage output DAC Class | ||
% adi.AD5780.Tx Transmits data to the AD5780 DAC | ||
% The adi.AD5780.Tx System object is a signal sink that can transmit | ||
% data to the AD5780. | ||
% | ||
% tx = adi.AD5780.Tx; | ||
% tx = adi.AD5780.Tx('uri','ip:192.168.2.1'); | ||
% | ||
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad5780.pdf">AD5780 Datasheet</a> | ||
|
||
properties | ||
SampleRate | ||
CodeSelect | ||
PowerDown | ||
Raw | ||
end | ||
|
||
% Channel names | ||
properties (Nontunable, Hidden) | ||
channel_names = {'voltage0'} | ||
end | ||
|
||
properties (Hidden, Nontunable, Access = protected) | ||
isOutput = true | ||
end | ||
|
||
properties (Nontunable, Hidden, Constant) | ||
Type = 'Tx' | ||
end | ||
|
||
properties (Nontunable, Hidden) | ||
Timeout = Inf | ||
kernelBuffersCount = 1 | ||
dataTypeStr = 'int32' | ||
phyDevName = 'ad5780' | ||
devName = 'ad5780' | ||
end | ||
|
||
properties (Constant, Hidden) | ||
CodeSelectSet = matlab.system.StringSet([ ... | ||
"2s_complement", "binary_offset"]); | ||
end | ||
|
||
methods | ||
|
||
%% Constructor | ||
function obj = Tx(varargin) | ||
obj = [email protected](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 | ||
|
||
function set.CodeSelect(obj, value) | ||
% Set code select option | ||
obj.CodeSelect = value; | ||
if obj.ConnectedToDevice | ||
id = 'voltage0'; | ||
obj.setDeviceAttributeRAW(id, 'code_select', num2str(value), true) | ||
end | ||
end | ||
|
||
function set.PowerDown(obj, value) | ||
options = [0,1]; | ||
if ~any(value==options) | ||
error(['PowerDown must be one of ',num2str(options)]); | ||
end | ||
% Set channel power down value | ||
obj.PowerDown = value; | ||
if obj.ConnectedToDevice | ||
id = 'voltage0'; | ||
obj.setAttributeRAW(id, 'powerdown', num2str(value), true) | ||
end | ||
end | ||
|
||
function set.Raw(obj, value) | ||
% Set channel raw value | ||
obj.Raw = value; | ||
if obj.ConnectedToDevice | ||
id = 'voltage0'; | ||
obj.setAttributeRAW(id, 'raw', num2str(value), true) | ||
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 doesn't support | ||
% modification to nontunable variables at SetupImpl | ||
|
||
id = 'voltage0'; | ||
|
||
obj.setDeviceAttributeRAW('sampling_frequency', num2str(obj.SampleRate)); | ||
obj.setDeviceAttributeRAW('code_select', num2str(obj.CodeSelect)); | ||
obj.setAttributeRAW(id, 'powerdown', num2str(obj.PowerDown), true); | ||
obj.setAttributeRAW(id, 'raw', num2str(obj.Raw), true); | ||
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 = 'AD5780 DAC'; | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.