diff --git a/+adi/+AD5706r/Tx.m b/+adi/+AD5706r/Tx.m new file mode 100644 index 00000000..32c2b305 --- /dev/null +++ b/+adi/+AD5706r/Tx.m @@ -0,0 +1,83 @@ +classdef Tx < adi.common.Tx & matlabshared.libiio.base & adi.common.Attribute + % AD5706r Precision current output DAC Class + % adi.AD5706r.Rx Transmits data to the AD5706r DAC + % The adi.AD5706r.Tx System object is a signal sink that can transmit + % data to the AD5706r. + % + % `tx = adi.AD5706.Tx;` + % `tx = adi.AD5706.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) + % Samples per frame + SamplesPerFrame + end + + properties (Nontunable, Hidden, Constant) + Type = 'Tx' + end + + % Channel names + properties (Nontunable, Hidden) + channel_names = {'current0'} + end + + properties (Hidden, Nontunable, Access = protected) + isOutput = true + end + + properties (Nontunable, Hidden) + Timeout = Inf + kernelBuffersCount = 1 + dataTypeStr = 'int16' + phyDevName = 'ad5706r' + devName = 'ad5706r' + end + + properties (Hidden, Constant) + ComplexData = false + end + + methods + + %% Constructor + function obj = Tx(varargin) + obj = obj@matlabshared.libiio.base(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)) + end + + end +end \ No newline at end of file diff --git a/+adi/Contents.m b/+adi/Contents.m index a6802f57..bcfa5070 100644 --- a/+adi/Contents.m +++ b/+adi/Contents.m @@ -74,4 +74,5 @@ % AD4080 - ADC % AD5592r - ADC % AD5593r - ADC -% AD5710r - DAC \ No newline at end of file +% AD5710r - DAC +% AD5706r - DAC \ No newline at end of file diff --git a/CI/gen_doc/docs/_pages/index.md b/CI/gen_doc/docs/_pages/index.md index 3bd82702..1b70335c 100644 --- a/CI/gen_doc/docs/_pages/index.md +++ b/CI/gen_doc/docs/_pages/index.md @@ -61,5 +61,7 @@ The following have device-specific implementations in MATLAB and Simulink. If a | AD4190 | Zedboard | Yes | No | ADI (2021b) | | AD5592r | Zedboard | Yes | No | ADI (2021b) | | AD5593r | Zedboard | Yes | No | ADI (2021b) | +| AD5710r | Zedboard | Yes | No | ADI (2021b) | +| AD5706r | Zedboard | Yes | No | ADI (2021b) | | AD7124-4 | Zedboard | Yes | No | ADI (2021b) | | AD7124-8 | Zedboard | Yes | No | ADI (2021b) | diff --git a/CI/gen_doc/docs/gen_sysobj_doc.m b/CI/gen_doc/docs/gen_sysobj_doc.m index afd00f47..85e13390 100644 --- a/CI/gen_doc/docs/gen_sysobj_doc.m +++ b/CI/gen_doc/docs/gen_sysobj_doc.m @@ -50,7 +50,8 @@ , {'AD4080', {'Rx'}}... , {'AD5592r', {'Rx'}}... , {'AD5593r', {'Rx'}}... - , {'AD5710r', {'Rx'}}... + , {'AD5710r', {'Tx'}}... + , {'AD5706r', {'Tx'}}... %{'QuadMxFE',{'Rx','Tx'}}... }; diff --git a/docs/source/index.rst b/docs/source/index.rst index e0b10b02..4aa7f17b 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -87,4 +87,5 @@ The following have device-specific implementations in MATLAB and Simulink. In ge "AD4190", "SDP-K1", "Yes", "No", "ADI (2021b)" "AD5592r", "SDP-K1", "Yes", "No", "ADI (2021b)" "AD5593r", "SDP-K1", "Yes", "No", "ADI (2021b)" - "AD5710rr", "SDP-K1", "Yes", "No", "ADI (2021b)" \ No newline at end of file + "AD5710r", "SDP-K1", "Yes", "No", "ADI (2021b)" + "AD5706r", "SDP-K1", "Yes", "No", "ADI (2021b)" \ No newline at end of file diff --git a/examples/ad5706r_DataStreaming.m b/examples/ad5706r_DataStreaming.m new file mode 100644 index 00000000..af71e1b2 --- /dev/null +++ b/examples/ad5706r_DataStreaming.m @@ -0,0 +1,31 @@ +%% Script for generating and transmitting a set of samples to a +%% connected ad5706r board + +%% Generate data +samplerate = 50000; +amplitude = 2^15; +frequency = 250; +sine_wave = dsp.SineWave(amplitude, frequency); +sine_wave.ComplexOutput = false; +sine_wave.SamplesPerFrame = 100; +sine_wave.SampleRate = samplerate; +data = sine_wave(); +data = uint16(data); + +%% Tx set up +% Instantiate the system object +tx = adi.AD5706r.Tx; +% Specify uri +tx.uri = 'serial:COM39,230400'; +tx.EnableCyclicBuffers = true; +tx.SampleRate = samplerate; +tx.EnabledChannels = [1]; + +% Stream data +tx(data) + +% Pause the execution to see the ouput for 5 seconds +pause(5); + +% Delete the system object +tx.release(); \ No newline at end of file