-
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.
adi: ad3530r: Add support for ad3530r
1. Add driver for ad3530r 2. Add example script for data streaming. 3. Update index.rst and Contents.m files. Signed-off-by: SGudla <[email protected]>
- Loading branch information
1 parent
6bf0889
commit e59fee0
Showing
4 changed files
with
121 additions
and
0 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,84 @@ | ||
classdef Tx < adi.common.Tx & matlabshared.libiio.base & adi.common.Attribute | ||
% AD3530r Precision voltage output DAC Class | ||
% adi.AD3530r.Rx Transmits data to the AD3530r DAC | ||
% The adi.AD3530r.Tx System object is a signal sink that can transmit | ||
% data to the AD3530r. | ||
% | ||
% tx = adi.AD3530r.Tx; | ||
% tx = adi.AD3530r.Tx('uri','ip:192.168.2.1'); | ||
% | ||
% TODO: Add link to the data sheet | ||
|
||
properties | ||
% SampleRate Sample Rate | ||
% Baseband sampling rate in Hz, specified as a scalar | ||
% in samples per second. | ||
SampleRate | ||
end | ||
|
||
properties (Nontunable) | ||
SamplesPerFrame | ||
end | ||
|
||
properties (Nontunable, Hidden, Constant) | ||
Type = 'Tx' | ||
end | ||
|
||
% Channel names | ||
properties (Nontunable, Hidden) | ||
channel_names = {'voltage0', 'voltage1', 'voltage2', 'voltage3', ... | ||
'voltage4', 'voltage5', 'voltage6', 'voltage7'} | ||
end | ||
|
||
properties (Hidden, Nontunable, Access = protected) | ||
isOutput = true | ||
end | ||
|
||
properties (Nontunable, Hidden) | ||
Timeout = Inf | ||
kernelBuffersCount = 1 | ||
dataTypeStr = 'int16' | ||
phyDevName = 'ad3530r' | ||
devName = 'ad3530r' | ||
end | ||
|
||
properties (Hidden, Constant) | ||
ComplexData = false | ||
end | ||
|
||
methods | ||
|
||
%% Constructor | ||
function obj = Tx(varargin) | ||
obj = [email protected](varargin{:}); | ||
obj.enableExplicitPolling = false; | ||
obj.EnabledChannels = 1; | ||
obj.uri = 'ip:analog.local'; | ||
obj.DataSource = 'DMA'; | ||
end | ||
|
||
function set.SampleRate(obj, value) | ||
% Set device sampling rate | ||
obj.SampleRate = value; | ||
if obj.ConnectedToDevice | ||
obj.setDeviceAttributeRAW('sampling_frequency', num2str(value)); | ||
end | ||
end | ||
|
||
end | ||
|
||
%% API Functions | ||
methods (Hidden, Access = protected) | ||
|
||
function setupInit(obj) | ||
% Write all attributes to device once connected through set | ||
% methods | ||
% Do writes directly to hardware without using set methods. | ||
% This is required since Simulink support doesn't support | ||
% modification to nontunable variables at SetupImpl | ||
obj.setDeviceAttributeRAW('sampling_frequency',num2str(obj.SampleRate)) | ||
obj.setDeviceAttributeRAW('all_ch_operating_mode', 'normal_operation') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
%% Script for generating and transmitting a set of samples to a | ||
%% connected AD3530r board | ||
|
||
%% Generate data | ||
samplerate = 50000; | ||
amplitude = 2^15; | ||
frequency = 250; | ||
sine_wave = dsp.SineWave(amplitude, frequency); | ||
sine_wave.ComplexOutput = false; | ||
sine_wave.SamplesPerFrame = 200; | ||
sine_wave.SampleRate = samplerate; | ||
sine_wave.PhaseOffset = [0 pi/2 pi]; | ||
data = sine_wave(); | ||
|
||
% Add offset for unipolar DAC | ||
data = data+2^15; | ||
data = uint16(data); | ||
|
||
%% Tx set up | ||
% Instantiate the system object | ||
tx = adi.AD3530r.Tx; | ||
% Specify uri | ||
tx.uri = 'ip:analog.local'; | ||
tx.EnableCyclicBuffers = true; | ||
tx.SampleRate = samplerate; | ||
tx.EnabledChannels = [1 2 3]; | ||
|
||
% Stream data | ||
tx(data) | ||
|
||
%Pause the execution to see the ouput for 5 seconds | ||
pause(5); | ||
|
||
% Delete the system object | ||
tx.release(); |