-
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 initial support and doc for ad2s1210
This adds initial support for AD2S1210 Resolver-to-Digital Converter. Signed-off-by: Apelete Seketeli <[email protected]>
- Loading branch information
Showing
7 changed files
with
148 additions
and
2 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,124 @@ | ||
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 | ||
% Angle | ||
% Resolver angle in Degrees. | ||
Angle = 0 | ||
|
||
% AngleScale Angular Scale | ||
% Resolver angle scale. | ||
AngleScale = 0 | ||
|
||
% Velocity Angular Velocity | ||
% Resolver velocity in revolutions per second. | ||
Velocity = 0 | ||
|
||
% VelocityScale Velocity Angular Scale | ||
% Resolver velocityscale. | ||
VelocityScale = 0 | ||
|
||
% ExcitationFrequency Excitation Frequency | ||
% Resolver excitation frequency in Hertz. | ||
ExcitationFrequency = 0 | ||
end | ||
|
||
properties (Hidden) | ||
% Number of frames or buffers of data to capture | ||
FrameCount = 1 | ||
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 | ||
|
||
%% Flush the buffer | ||
function flush(obj) | ||
flushBuffers(obj); | ||
end | ||
|
||
%% Check Angle | ||
function getAngle(obj) | ||
if obj.ConnectedToDevice | ||
obj.Angle = obj.getAttributeRAW('angl0', 'raw', obj.isOutput); | ||
end | ||
end | ||
|
||
%% Check Angular Scale | ||
function getAngleScale(obj) | ||
if obj.ConnectedToDevice | ||
obj.AngleScale = obj.getAttributeDouble('angl0', 'scale', obj.isOutput); | ||
end | ||
end | ||
|
||
%% Check Velocity | ||
function getVelocity(obj) | ||
if obj.ConnectedToDevice | ||
obj.Velocity = obj.getAttributeRAW('anglvel0','raw', obj.isOutput); | ||
end | ||
end | ||
|
||
%% Check Velocity Scale | ||
function getVelocityScale(obj) | ||
if obj.ConnectedToDevice | ||
obj.VelocityScale = obj.getAttributeDouble('anglvel0', 'scale', obj.isOutput); | ||
end | ||
end | ||
end | ||
|
||
%% API Functions | ||
methods (Hidden, Access = protected) | ||
|
||
function setupInit(obj) | ||
% Read excitation frequency attribute from device once connected. | ||
|
||
obj.ExcitationFrequency = obj.getDeviceAttributeLongLong('excitation_frequency'); | ||
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
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
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
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
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
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,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 and angular velocity | ||
rx.getAngle(); | ||
rx.getAngleScale(); | ||
rx.getVelocity(); | ||
rx.getVelocityScale(); | ||
|
||
% Print system object properties | ||
rx | ||
|
||
% Delete the system object | ||
release(rx); |