diff --git a/+adi/+AD4692/Rx.m b/+adi/+AD4692/Rx.m new file mode 100644 index 0000000..c1a9a7a --- /dev/null +++ b/+adi/+AD4692/Rx.m @@ -0,0 +1,94 @@ +classdef Rx < adi.common.Rx & matlabshared.libiio.base & adi.common.Attribute + % AD4692 Precision ADC Class + % adi.AD4692.Rx Receives data from the AD4692 ADC + % The adi.AD4692.Rx System object is a signal source that can receive + % data from the AD4692. + % + % rx = adi.AD4692.Rx; + % rx = adi.AD4692.Rx('uri','192.168.2.1'); + % + + properties (Nontunable) + % SampleRate Sample Rate + % Baseband sampling rate in Hz, specified as a scalar + % in samples per second. + SampleRate = '500000' + + % SamplesPerFrame Samples Per Frame + % Number of samples per frame, specified as an even positive + % integer. + SamplesPerFrame = 1024 + end + + properties (Hidden) + % Number of frames or buffers of data to capture + FrameCount = 1 + 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 = 2 + dataTypeStr = 'int32' + phyDevName = 'ad4692' + devName = 'ad4692' + end + + properties (Nontunable, Hidden, Constant) + Type = 'Rx' + end + + properties (Hidden, Constant) + ComplexData = false + end + + methods + + %% Constructor + function obj = Rx(varargin) + % Initialize the Rx object + obj = obj@matlabshared.libiio.base(varargin{:}); + obj.enableExplicitPolling = false; + obj.EnabledChannels = 1; + obj.BufferTypeConversionEnable = true; + obj.uri = 'ip:analog.local'; + end + + function flush(obj) + % Flush the buffer + flushBuffers(obj); + end + + function set.SampleRate(obj, value) + % Set device sampling rate + obj.SampleRate = value; + if obj.ConnectedToDevice + obj.setDeviceAttributeRAW('sampling_frequency', 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 diff --git a/+adi/Contents.m b/+adi/Contents.m index bcfa507..e868387 100644 --- a/+adi/Contents.m +++ b/+adi/Contents.m @@ -26,6 +26,7 @@ % AD4062 - ADC % AD4630-16 - ADC % AD4630-24 - ADC +% AD4692 - ADC % AD4170 - ADC % AD4190 - ADC % ADAQ4224 - ADAQ diff --git a/CI/gen_doc/docs/_pages/index.md b/CI/gen_doc/docs/_pages/index.md index 1b70335..20b2888 100644 --- a/CI/gen_doc/docs/_pages/index.md +++ b/CI/gen_doc/docs/_pages/index.md @@ -59,6 +59,7 @@ The following have device-specific implementations in MATLAB and Simulink. If a | AD4080 | Zedboard | Yes | No | ADI (2021b) | | AD4170 | Zedboard | Yes | No | ADI (2021b) | | AD4190 | Zedboard | Yes | No | ADI (2021b) | +| AD4692 | Zedboard | Yes | No | ADI (2021b) | | AD5592r | Zedboard | Yes | No | ADI (2021b) | | AD5593r | Zedboard | Yes | No | ADI (2021b) | | AD5710r | 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 85e1339..f068e7b 100644 --- a/CI/gen_doc/docs/gen_sysobj_doc.m +++ b/CI/gen_doc/docs/gen_sysobj_doc.m @@ -40,6 +40,7 @@ , {'AD4062', {'Rx'}}... , {'AD4170', {'Rx'}}... , {'AD4190', {'Rx'}}... + , {'AD4692', {'Rx'}}... , {'AD5760', {'Tx'}}... , {'AD5780', {'Tx'}}... , {'AD5781', {'Tx'}}... diff --git a/docs/source/index.rst b/docs/source/index.rst index 4aa7f17..ff01caa 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -65,6 +65,7 @@ The following have device-specific implementations in MATLAB and Simulink. In ge "AD4020", "Zedboard", "Yes", "No", "ADI (2021b)" "AD4021", "Zedboard", "Yes", "No", "ADI (2021b)" "AD4022", "Zedboard", "Yes", "No", "ADI (2021b)" + "AD4692", "Zedboard", "Yes", "No", "ADI (2021b)" "AD5760", "Zedboard", "Yes", "No", "ADI (2021b)" "AD5780", "Zedboard", "Yes", "No", "ADI (2021b)" "AD5781", "Zedboard", "Yes", "No", "ADI (2021b)" diff --git a/examples/ad4692_DataCapture.m b/examples/ad4692_DataCapture.m new file mode 100644 index 0000000..730e823 --- /dev/null +++ b/examples/ad4692_DataCapture.m @@ -0,0 +1,29 @@ +%% Script for capturing and displaying a continuous set of samples from a +%% connected AD4692 board + +% Instantiate the system object +rx = adi.AD4692.Rx; + +% Specify uri +rx.uri = 'serial:COM4,230400'; +rx.SamplesPerFrame = 400; % Using values less than 3660 can yield poor + +% performance, generally +rx.EnabledChannels = [1]; + +% Set the sampling rate +rx.SampleRate = 500000; + +% Capture data +data = rx(); + +enabledChannels = size(data, 2); +figure(1); +for i = 1:enabledChannels + subplot(enabledChannels, 1, i); + plot(data(1:rx.FrameCount * rx.SamplesPerFrame, i)); + title("Channel " + num2str(rx.EnabledChannels(i))); +end + +% Delete the system object +release(rx);