Skip to content

Commit 3649d0e

Browse files
committed
adi: ad5710r: Add support for ad5710r
1. Add driver for ad5710r 2. Add example script for data streaming. 3. Update index.rst and Contents.m files. Signed-off-by: SGudla <Saikiran.Gudla@analog.com>
1 parent 87b2e9d commit 3649d0e

File tree

5 files changed

+152
-1
lines changed

5 files changed

+152
-1
lines changed

+adi/+AD5710r/Tx.m

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
classdef Tx < adi.common.Tx & matlabshared.libiio.base & adi.common.Attribute
2+
% AD5710r 16-bit Configurable IDAC/VDAC Class
3+
% adi.AD5710r.Rx Transmits data to the AD5710r DAC
4+
% The adi.AD5710r.Tx System object is a signal sink that can transmit
5+
% data to the AD5710r.
6+
%
7+
% tx = adi.AD5710r.Tx;
8+
% tx = adi.AD5710r.Tx('uri','ip:192.168.2.1');
9+
%
10+
% <a href="https://www.analog.com/en/products/ad5710r.html"</a>
11+
12+
properties
13+
% SampleRate Sample Rate
14+
% Baseband sampling rate in Hz, specified as a scalar
15+
% in samples per second.
16+
SampleRate = '50000'
17+
end
18+
19+
properties
20+
% ChMode Channel Mode
21+
% COnfigure the channel mode of the device channels.
22+
% Options are 'VMODE', 'IMODE'.
23+
ChMode = 'VMODE'
24+
end
25+
26+
properties (Nontunable)
27+
SamplesPerFrame
28+
end
29+
30+
properties (Nontunable, Hidden, Constant)
31+
Type = 'Tx'
32+
end
33+
34+
properties (Constant, Hidden)
35+
ChModeSet = matlab.system.StringSet([ ...
36+
"V_MODE", "I_MODE"]);
37+
end
38+
39+
% Channel names
40+
properties (Nontunable, Hidden)
41+
channel_names = {'voltage0', 'voltage1', 'voltage2', 'voltage3', ...
42+
'voltage4', 'voltage5', 'voltage6', 'voltage7'}
43+
end
44+
45+
properties (Hidden, Nontunable, Access = protected)
46+
isOutput = true
47+
end
48+
49+
properties (Nontunable, Hidden)
50+
Timeout = Inf
51+
kernelBuffersCount = 1
52+
dataTypeStr = 'int16'
53+
phyDevName = 'ad5710r'
54+
devName = 'ad5710r'
55+
end
56+
57+
properties (Hidden, Constant)
58+
ComplexData = false
59+
end
60+
61+
methods
62+
63+
%% Constructor
64+
function obj = Tx(varargin)
65+
obj = obj@matlabshared.libiio.base(varargin{:});
66+
obj.enableExplicitPolling = false;
67+
obj.EnabledChannels = 1;
68+
obj.uri = 'ip:analog.local';
69+
obj.DataSource = 'DMA';
70+
end
71+
72+
function set.SampleRate(obj, value)
73+
% Set device sampling rate
74+
obj.SampleRate = value;
75+
if obj.ConnectedToDevice
76+
obj.setDeviceAttributeRAW('sampling_frequency', num2str(value));
77+
end
78+
end
79+
80+
function set.ChMode(obj, value)
81+
% Set channel mode
82+
obj.ChMode = value;
83+
if obj.ConnectedToDevice
84+
for i=1:length(obj.channel_names)
85+
if (ismember(i, obj.EnabledChannels))
86+
obj.setAttributeRAW(obj.channel_names{i}, 'ch_mode', num2str(value), true);
87+
end
88+
end
89+
end
90+
end
91+
end
92+
93+
%% API Functions
94+
methods (Hidden, Access = protected)
95+
96+
function setupInit(obj)
97+
% Write all attributes to device once connected through set
98+
% methods
99+
% Do writes directly to hardware without using set methods.
100+
% This is required since Simulink support doesn't support
101+
% modification to nontunable variables at SetupImpl
102+
obj.setDeviceAttributeRAW('sampling_frequency',num2str(obj.SampleRate))
103+
obj.setDeviceAttributeRAW('all_ch_operating_mode', 'normal_operation')
104+
for i=1:length(obj.channel_names)
105+
if (ismember(i, obj.EnabledChannels))
106+
obj.setAttributeRAW(obj.channel_names{i}, 'ch_mode', num2str(obj.ChMode), true);
107+
end
108+
end
109+
end
110+
111+
end
112+
end

+adi/Contents.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@
7373
% <a href="matlab:help adi.AD7124_8 ">AD7124_8</a> - ADC
7474
% <a href="matlab:help adi.AD4080 ">AD4080</a> - ADC
7575
% <a href="matlab:help adi.AD5592r ">AD5592r</a> - ADC
76-
% <a href="matlab:help adi.AD5593r ">AD5593r</a> - ADC
76+
% <a href="matlab:help adi.AD5593r ">AD5593r</a> - ADC
77+
% <a href="matlab:help adi.AD5710r ">AD5710r</a> - DAC

CI/gen_doc/docs/gen_sysobj_doc.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
, {'AD4080', {'Rx'}}...
5151
, {'AD5592r', {'Rx'}}...
5252
, {'AD5593r', {'Rx'}}...
53+
, {'AD5710r', {'Rx'}}...
5354
%{'QuadMxFE',{'Rx','Tx'}}...
5455
};
5556

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@ The following have device-specific implementations in MATLAB and Simulink. In ge
8787
"AD4190", "SDP-K1", "Yes", "No", "ADI (2021b)"
8888
"AD5592r", "SDP-K1", "Yes", "No", "ADI (2021b)"
8989
"AD5593r", "SDP-K1", "Yes", "No", "ADI (2021b)"
90+
"AD5710rr", "SDP-K1", "Yes", "No", "ADI (2021b)"

examples/ad5710r_DataStreaming.m

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
%% Script for generating and transmitting a set of samples to a
2+
%% connected AD5710r board
3+
4+
%% Generate data
5+
samplerate = 50000;
6+
amplitude = 2^15;
7+
frequency = 250;
8+
sine_wave = dsp.SineWave(amplitude, frequency);
9+
sine_wave.ComplexOutput = false;
10+
sine_wave.SamplesPerFrame = 200;
11+
sine_wave.SampleRate = samplerate;
12+
sine_wave.PhaseOffset = [0 pi/2 pi];
13+
data = sine_wave();
14+
15+
% Add offset for unipolar DAC
16+
data = data+2^15;
17+
data = uint16(data);
18+
19+
%% Tx set up
20+
% Instantiate the system object
21+
tx = adi.AD5710r.Tx;
22+
% Specify uri
23+
tx.uri = 'serial:COM18,230400';
24+
tx.EnableCyclicBuffers = true;
25+
tx.SampleRate = samplerate;
26+
tx.ChMode = 'VMODE';
27+
tx.EnabledChannels = [1 2 3];
28+
29+
% Stream data
30+
tx(data)
31+
32+
% Pause the execution to see the ouput for 5 seconds
33+
pause(5);
34+
35+
% Delete the system object
36+
tx.release();

0 commit comments

Comments
 (0)