Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support and doc for ad2s1210 #11

Merged
merged 6 commits into from
Oct 13, 2023
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
114 changes: 114 additions & 0 deletions +adi/+AD2S1210/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
classdef Rx < adi.common.Rx & matlabshared.libiio.base & adi.common.Attribute
% AD2S1210 Resolver-to-Digital Converter Class
% adi.AD2S1210.Rx Receives data from the AD2S1210 Resolver
% The adi.AD2S1210.Rx System object is a signal source that can receive
% data from the AD2S1210.
%
% rx = adi.AD2S1210.Rx;
% rx = adi.AD2S1210.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad2s1210.pdf">AD2S1210 Datasheet</a>

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

properties (Dependent)
% Angle
% Resolver angle in Degrees.
Angle

% AngleScale Angular Scale
% Resolver angle scale.
AngleScale

% Velocity Angular Velocity
% Resolver velocity in revolutions per second.
Velocity

% VelocityScale Velocity Angular Scale
% Resolver velocityscale.
VelocityScale
end

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

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

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

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

properties (Hidden, Constant)
ComplexData = false
end

methods
%% Constructor
function obj = Rx(varargin)
obj = [email protected](varargin{:});
obj.enableExplicitPolling = false;
obj.EnabledChannels = [1 2];
obj.BufferTypeConversionEnable = true;
end

%% Check Angle
function rValue = get.Angle(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeRAW('angl0', 'raw', obj.isOutput);
else
rValue = NaN;
end
end

%% Check Angular Scale
function rValue = get.AngleScale(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeDouble('angl0', 'scale', obj.isOutput);
else
rValue = NaN;
end
end

%% Check Velocity
function rValue = get.Velocity(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeRAW('anglvel0','raw', obj.isOutput);
else
rValue = NaN;
end
end

%% Check Velocity Scale
function rValue = get.VelocityScale(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeDouble('anglvel0', 'scale', obj.isOutput);
else
rValue = NaN;
end
end
end

%% API Functions
methods (Hidden, Access = protected)
function setupInit(~)
end
end
end
1 change: 1 addition & 0 deletions +adi/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
% <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.AD4858 ">AD4858</a> - ADC
% <a href="matlab:help adi.AD2S1210 ">AD2S1210</a> - Resolver-to-Digital Converter
2 changes: 1 addition & 1 deletion CI/doc/SysObjsProps.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
% * AD463x <AD463x_Rx.html Rx>
% * AD7768 <AD7768_Rx.html Rx>
% * AD7768 <AD4858_Rx.html Rx>

% * AD2S1210 <AD2S1210_Rx.html Rx>
2 changes: 1 addition & 1 deletion CI/doc/genhtml.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mfiledir = '..\..\+adi\';
docdir = '..\..\doc\';
parts = {'AD4630','AD4030','AD463x','AD7768','AD4858'};
parts = {'AD4630','AD4030','AD463x','AD7768','AD4858','AD2S1210'};
trx_files = {'Rx','Base','Tx'};
for ii = 1:numel(parts)
for jj = 1:numel(trx_files)
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 @@ -34,3 +34,4 @@ The following have device-specific implementations in MATLAB and Simulink. If a
| AD4630-16 | Zedboard | Yes | No | ADI (2021b) |
| AD4630-24 | Zedboard | Yes | No | ADI (2021b) |
| AD4858 | Zedboard | Yes | No | ADI (2021b) |
| AD2S1210 | Zedboard | Yes | No | ADI (2021b) |
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 @@ -14,6 +14,7 @@
, {'AD4630_16', {'Rx'}}...
, {'AD4630_24', {'Rx'}}...
, {'AD4858', {'Rx'}}...
, {'AD2S1210', {'Rx'}}...
%{'QuadMxFE',{'Rx','Tx'}}...
};

Expand Down
74 changes: 55 additions & 19 deletions CI/gen_doc/docs/sysobjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,18 @@
},
{
"prop_name": "SampleAveragingLength",
"prop_title": " SampleAveragingLength",
"prop_description": "Block length of samples to be averaged. Applied in the Averaging Mode register only when OUT_DATA_MD is set to 30-bit averaged differential modeHelp for adi.AD4030.Rx/SampleAveragingLength is inherited from superclass adi.AD463x.Base"
"prop_title": "SampleAveragingLength",
"prop_description": "Block length of samples to be averaged. Applied in the Averaging Mode register only when OUT_DATA_MD is set to 30-bit averaged differential mode"
},
{
"prop_name": "SampleRate",
"prop_title": " SampleRate Sample Rate",
"prop_description": "Baseband sampling rate in Hz, specified as a scalar in samples per second.Help for adi.AD4030.Rx/SampleRate is inherited from superclass adi.AD463x.Base"
"prop_title": "SampleRate - Sample Rate",
"prop_description": "Baseband sampling rate in Hz, specified as a scalar in samples per second."
},
{
"prop_name": "SamplesPerFrame",
"prop_title": " SamplesPerFrame Samples Per Frame",
"prop_description": "Number of samples per frame, specified as an even positive integer.Help for adi.AD4030.Rx/SamplesPerFrame is inherited from superclass adi.AD463x.Base"
"prop_title": " Frame size",
"prop_description": "Size of the frame in samplesHelp for adi.AD4030.Rx/SamplesPerFrame is inherited from superclass matlabshared.libiio.base"
},
{
"prop_name": "uri",
Expand All @@ -124,18 +124,18 @@
},
{
"prop_name": "SampleAveragingLength",
"prop_title": " SampleAveragingLength",
"prop_description": "Block length of samples to be averaged. Applied in the Averaging Mode register only when OUT_DATA_MD is set to 30-bit averaged differential modeHelp for adi.AD4630_16.Rx/SampleAveragingLength is inherited from superclass adi.AD463x.Base"
"prop_title": "SampleAveragingLength",
"prop_description": "Block length of samples to be averaged. Applied in the Averaging Mode register only when OUT_DATA_MD is set to 30-bit averaged differential mode"
},
{
"prop_name": "SampleRate",
"prop_title": " SampleRate Sample Rate",
"prop_description": "Baseband sampling rate in Hz, specified as a scalar in samples per second.Help for adi.AD4630_16.Rx/SampleRate is inherited from superclass adi.AD463x.Base"
"prop_title": "SampleRate - Sample Rate",
"prop_description": "Baseband sampling rate in Hz, specified as a scalar in samples per second."
},
{
"prop_name": "SamplesPerFrame",
"prop_title": " SamplesPerFrame Samples Per Frame",
"prop_description": "Number of samples per frame, specified as an even positive integer.Help for adi.AD4630_16.Rx/SamplesPerFrame is inherited from superclass adi.AD463x.Base"
"prop_title": " Frame size",
"prop_description": "Size of the frame in samplesHelp for adi.AD4630_16.Rx/SamplesPerFrame is inherited from superclass matlabshared.libiio.base"
},
{
"prop_name": "uri",
Expand All @@ -155,18 +155,18 @@
},
{
"prop_name": "SampleAveragingLength",
"prop_title": " SampleAveragingLength",
"prop_description": "Block length of samples to be averaged. Applied in the Averaging Mode register only when OUT_DATA_MD is set to 30-bit averaged differential modeHelp for adi.AD4630_24.Rx/SampleAveragingLength is inherited from superclass adi.AD463x.Base"
"prop_title": "SampleAveragingLength",
"prop_description": "Block length of samples to be averaged. Applied in the Averaging Mode register only when OUT_DATA_MD is set to 30-bit averaged differential mode"
},
{
"prop_name": "SampleRate",
"prop_title": " SampleRate Sample Rate",
"prop_description": "Baseband sampling rate in Hz, specified as a scalar in samples per second.Help for adi.AD4630_24.Rx/SampleRate is inherited from superclass adi.AD463x.Base"
"prop_title": "SampleRate - Sample Rate",
"prop_description": "Baseband sampling rate in Hz, specified as a scalar in samples per second."
},
{
"prop_name": "SamplesPerFrame",
"prop_title": " SamplesPerFrame Samples Per Frame",
"prop_description": "Number of samples per frame, specified as an even positive integer.Help for adi.AD4630_24.Rx/SamplesPerFrame is inherited from superclass adi.AD463x.Base"
"prop_title": " Frame size",
"prop_description": "Size of the frame in samplesHelp for adi.AD4630_24.Rx/SamplesPerFrame is inherited from superclass matlabshared.libiio.base"
},
{
"prop_name": "uri",
Expand Down Expand Up @@ -200,5 +200,41 @@
"prop_description": "Hostname or IP address of remote libIIO deviceHelp for adi.AD4858.Rx/uri is inherited from superclass matlabshared.libiio.base"
}
]
},
{
"name": "adi.AD2S1210.Rx",
"dec": " adi.AD2S1210.Rx Receives data from the AD2S1210 Resolver<br> The adi.AD2S1210.Rx System object is a signal source that can receive<br> data from the AD2S1210.<br> <br> rx = adi.AD2S1210.Rx;<br> rx = adi.AD2S1210.Rx('uri','192.168.2.1');<br> <br> <a href=\"https://www.analog.com/media/en/technical-documentation/data-sheets/ad2s1210.pdf\">AD2S1210 Datasheet</a><br> Documentation for adi.AD2S1210.Rx<br> doc adi.AD2S1210.Rx<br>",
"props": [
{
"prop_name": "Angle",
"prop_title": " Angle",
"prop_description": "Resolver angle in Degrees."
},
{
"prop_name": "EnabledChannels",
"prop_title": " EnabledChannels Enabled Channels",
"prop_description": "Indexs of channels to be enabled. Input should be a [1xN] vector with the indexes of channels to be enabled. Order is irrelevant"
},
{
"prop_name": "Resolution",
"prop_title": " Resolution",
"prop_description": "Resolver resolution in bits."
},
{
"prop_name": "SamplesPerFrame",
"prop_title": " SamplesPerFrame Samples Per Frame",
"prop_description": "Number of samples per frame, specified as an even positive integer."
},
{
"prop_name": "Velocity",
"prop_title": " Velocity Angular Velocity",
"prop_description": "Resolver velocity in revolutions per second."
},
{
"prop_name": "uri",
"prop_title": " URI - remote host URI",
"prop_description": "Hostname or IP address of remote libIIO deviceHelp for adi.AD2S1210.Rx/uri is inherited from superclass matlabshared.libiio.base"
}
]
}
]
]
19 changes: 19 additions & 0 deletions examples/ad2s1210_DataCapture.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%% Script for capturing data from a connected AD2S1210 board

% Instantiate the system object
rx = adi.AD2S1210.Rx('uri','ip:analog.local');

% Connect to device and initialize data
rx();

% Retrieve resolver angle, velocity and associated scales
rx.Angle();
rx.AngleScale();
rx.Velocity();
rx.VelocityScale();

% Print system object properties
rx

% Delete the system object
release(rx);
Loading