Skip to content

Commit 6a7f962

Browse files
committed
adi: ad5706r: Add support for ad5706r
1. Add driver for ad5706r 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 ea417db commit 6a7f962

File tree

6 files changed

+122
-3
lines changed

6 files changed

+122
-3
lines changed

+adi/+AD5706r/Tx.m

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
classdef Tx < adi.common.Tx & matlabshared.libiio.base & adi.common.Attribute
2+
% AD5706r Precision current output DAC Class
3+
% adi.AD5706r.Rx Transmits data to the AD5706r DAC
4+
% The adi.AD5706r.Tx System object is a signal sink that can transmit
5+
% data to the AD5706r.
6+
%
7+
% `tx = adi.AD5706.Tx;`
8+
% `tx = adi.AD5706.Tx('uri','ip:192.168.2.1');`
9+
%
10+
% TODO: Add link to the data sheet
11+
12+
properties
13+
% SampleRate Sample Rate
14+
% Baseband sampling rate in Hz, specified as a scalar
15+
% in samples per second.
16+
SampleRate
17+
end
18+
19+
properties (Nontunable)
20+
% Samples per frame
21+
SamplesPerFrame
22+
end
23+
24+
properties (Nontunable, Hidden, Constant)
25+
Type = 'Tx'
26+
end
27+
28+
% Channel names
29+
properties (Nontunable, Hidden)
30+
channel_names = {'current0'}
31+
end
32+
33+
properties (Hidden, Nontunable, Access = protected)
34+
isOutput = true
35+
end
36+
37+
properties (Nontunable, Hidden)
38+
Timeout = Inf
39+
kernelBuffersCount = 1
40+
dataTypeStr = 'int16'
41+
phyDevName = 'ad5706r'
42+
devName = 'ad5706r'
43+
end
44+
45+
properties (Hidden, Constant)
46+
ComplexData = false
47+
end
48+
49+
methods
50+
51+
%% Constructor
52+
function obj = Tx(varargin)
53+
obj = obj@matlabshared.libiio.base(varargin{:});
54+
obj.enableExplicitPolling = false;
55+
obj.EnabledChannels = 1;
56+
obj.uri = 'ip:analog.local';
57+
obj.DataSource = 'DMA';
58+
end
59+
60+
function set.SampleRate(obj, value)
61+
% Set device sampling rate
62+
obj.SampleRate = value;
63+
if obj.ConnectedToDevice
64+
obj.setDeviceAttributeRAW('sampling_frequency', num2str(value));
65+
end
66+
end
67+
68+
end
69+
70+
%% API Functions
71+
methods (Hidden, Access = protected)
72+
73+
function setupInit(obj)
74+
% Write all attributes to device once connected through set
75+
% methods
76+
% Do writes directly to hardware without using set methods.
77+
% This is required since Simulink support doesn't support
78+
% modification to nontunable variables at SetupImpl
79+
obj.setDeviceAttributeRAW('sampling_frequency',num2str(obj.SampleRate))
80+
end
81+
82+
end
83+
end

+adi/Contents.m

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

CI/gen_doc/docs/_pages/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,7 @@ The following have device-specific implementations in MATLAB and Simulink. If a
6161
| AD4190 | Zedboard | Yes | No | ADI (2021b) |
6262
| AD5592r | Zedboard | Yes | No | ADI (2021b) |
6363
| AD5593r | Zedboard | Yes | No | ADI (2021b) |
64+
| AD5710r | Zedboard | Yes | No | ADI (2021b) |
65+
| AD5706r | Zedboard | Yes | No | ADI (2021b) |
6466
| AD7124-4 | Zedboard | Yes | No | ADI (2021b) |
6567
| AD7124-8 | Zedboard | Yes | No | ADI (2021b) |

CI/gen_doc/docs/gen_sysobj_doc.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
, {'AD4080', {'Rx'}}...
5151
, {'AD5592r', {'Rx'}}...
5252
, {'AD5593r', {'Rx'}}...
53-
, {'AD5710r', {'Rx'}}...
53+
, {'AD5710r', {'Tx'}}...
54+
, {'AD5706r', {'Tx'}}...
5455
%{'QuadMxFE',{'Rx','Tx'}}...
5556
};
5657

docs/source/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ 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)"
90+
"AD5710r", "SDP-K1", "Yes", "No", "ADI (2021b)"
91+
"AD5706r", "SDP-K1", "Yes", "No", "ADI (2021b)"

examples/ad5706r_DataStreaming.m

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
%% Script for generating and transmitting a set of samples to a
2+
%% connected ad5706r 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 = 100;
11+
sine_wave.SampleRate = samplerate;
12+
data = sine_wave();
13+
data = uint16(data);
14+
15+
%% Tx set up
16+
% Instantiate the system object
17+
tx = adi.AD5706r.Tx;
18+
% Specify uri
19+
tx.uri = 'serial:COM39,230400';
20+
tx.EnableCyclicBuffers = true;
21+
tx.SampleRate = samplerate;
22+
tx.EnabledChannels = [1];
23+
24+
% Stream data
25+
tx(data)
26+
27+
% Pause the execution to see the ouput for 5 seconds
28+
pause(5);
29+
30+
% Delete the system object
31+
tx.release();

0 commit comments

Comments
 (0)