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 ad4020 #12

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
101 changes: 101 additions & 0 deletions +adi/+AD4020/Rx.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
classdef Rx < adi.common.Rx & matlabshared.libiio.base & adi.common.Attribute
% AD4020 Precision ADC Class
% adi.AD4020.Rx Receives data from the AD4020 ADC
% The adi.AD4020.Rx System object is a signal source that can receive
% data from the AD4020.
%
% rx = adi.AD4020.Rx;
% rx = adi.AD4020.Rx('uri','192.168.2.1');
%
% <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ad4020-4021-4022.pdf">AD4020 Datasheet</a>

properties (Nontunable)
apelete marked this conversation as resolved.
Show resolved Hide resolved
% SamplesPerFrame Samples Per Frame
% Number of samples per frame, specified as an even positive
% integer.
SamplesPerFrame = 4096
end

properties (Dependent)
% Voltage
% ADC Voltage in mV
Voltage

% VoltageScale Voltage Scale
% ADC Voltage scale.
VoltageScale

% VoltageOffset Voltage Offset
% ADC Voltage offset.
VoltageOffset
end

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

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

properties (Nontunable, Hidden)
Timeout = Inf
kernelBuffersCount = 1
dataTypeStr = 'int32'
phyDevName = 'ad4020'
devName = 'ad4020'
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;
obj.BufferTypeConversionEnable = true;
end

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

%% Check Voltage Scale
function rValue = get.VoltageScale(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeDouble('voltage0', 'scale', obj.isOutput);
else
rValue = NaN;
end
end

%% Check Voltage Offset
function rValue = get.VoltageOffset(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeDouble('voltage0', 'offset', 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 @@ -13,3 +13,4 @@
% <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
% <a href="matlab:help adi.AD4020 ">AD4020</a> - ADC
1 change: 1 addition & 0 deletions CI/doc/SysObjsProps.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
% * AD7768 <AD7768_Rx.html Rx>
% * AD7768 <AD4858_Rx.html Rx>
% * AD2S1210 <AD2S1210_Rx.html Rx>
% * AD4020 <AD4020_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','AD2S1210'};
parts = {'AD4630','AD4030','AD463x','AD7768','AD4858','AD2S1210','AD4020'};
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 @@ -35,3 +35,4 @@ The following have device-specific implementations in MATLAB and Simulink. If a
| AD4630-24 | Zedboard | Yes | No | ADI (2021b) |
| AD4858 | Zedboard | Yes | No | ADI (2021b) |
| AD2S1210 | Zedboard | Yes | No | ADI (2021b) |
| AD4020 | 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 @@ -15,6 +15,7 @@
, {'AD4630_24', {'Rx'}}...
, {'AD4858', {'Rx'}}...
, {'AD2S1210', {'Rx'}}...
, {'AD4020', {'Rx'}}...
%{'QuadMxFE',{'Rx','Tx'}}...
};

Expand Down
41 changes: 41 additions & 0 deletions CI/gen_doc/docs/sysobjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,46 @@
"prop_description": "Hostname or IP address of remote libIIO deviceHelp for adi.AD2S1210.Rx/uri is inherited from superclass matlabshared.libiio.base"
}
]
},
{
"name": "adi.AD4020.Rx",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike ad2s120, properties didn't get filled out for AD4020. So documentation wouldn't get generated.

Just to confirm did you run the gen_sysobj_doc.m with the most recent driver version checked out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed the difference with ad2s1210 but can't figure out why properties are not filled out for ad4020 : I'm running gen_sysobj_doc.m with the same Matlab version, just checking out the relevant branch for each device in my git workspace.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to replicate the behavior locally. I cloned the repo, switched to this branch, and executed gen_sysobj_doc - I could see the properties appear correctly in sysobjs.json.
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there another clone (perhaps with the early version of the driver or something) on the MATLAB path, that's taking precedence? That could explain why the properties don't show up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the same on my side : cloned the repo in another directory and executed gen_sysobj_doc in that new directory with the same result and I still cannot see the properties in sysobjs.json for AD4020.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ribdp Would you please consider pushing your sysobjs.json changes with the properties updated since this appears to be a setup issue on my side ?
I can't figure out why the properties do not show after executing gen_sysobj_doc.m in this case, even looking at MATLAB path for a probable cause.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apelete Sure thing. I've pushed the changes now

"dec": " adi.AD4020.Rx Receives data from the AD4020 ADC<br> The adi.AD4020.Rx System object is a signal source that can receive<br> data from the AD4020.<br> <br> rx = adi.AD4020.Rx;<br> rx = adi.AD4020.Rx('uri','192.168.2.1');<br> <br> <a href=\"https://www.analog.com/media/en/technical-documentation/data-sheets/ad4020-4021-4022.pdf\">AD4020 Datasheet</a><br> Documentation for adi.AD4020.Rx<br> doc adi.AD4020.Rx<br>",
"props": [
{
"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": "SamplesPerFrame",
"prop_title": " Frame size",
"prop_description": "Size of the frame in samplesHelp for adi.AD4020.Rx/SamplesPerFrame is inherited from superclass matlabshared.libiio.base"
},
{
"prop_name": "SamplingFrequency",
"prop_title": " SamplingFrequency",
"prop_description": "Sampling Frequency in Hertz."
},
{
"prop_name": "Voltage",
"prop_title": " Voltage",
"prop_description": "ADC Voltage in mV"
},
{
"prop_name": "VoltageOffset",
"prop_title": " VoltageOffset Voltage Offset",
"prop_description": "ADC Voltage offset."
},
{
"prop_name": "VoltageScale",
"prop_title": " VoltageScale Voltage Scale",
"prop_description": "ADC Voltage scale."
},
{
"prop_name": "uri",
"prop_title": " URI - remote host URI",
"prop_description": "Hostname or IP address of remote libIIO deviceHelp for adi.AD4020.Rx/uri is inherited from superclass matlabshared.libiio.base"
}
]
}
]
18 changes: 18 additions & 0 deletions examples/ad4020_DataCapture.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%% Script for capturing data from a connected AD4020 board

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

% Connect to device and initialize data
rx();

% Retrieve ADC voltage, scale and offset
rx.Voltage();
rx.VoltageScale();
rx.VoltageOffset();

% Print system object properties
rx

% Delete the system object
release(rx)
Loading