Skip to content

Commit

Permalink
Latest streaming fix
Browse files Browse the repository at this point in the history
  • Loading branch information
StancaPop committed Jul 11, 2023
1 parent d15d17f commit 550e7d5
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 19 deletions.
10 changes: 6 additions & 4 deletions +adi/+AD3552R/Base.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@
ComplexData = false;
end

properties (Nontunable)
properties
% InputSource
% Lists all the available input sources of the DAC.
% Options are: 'adc_input', 'dma_input', 'ramp_input'.
InputSource = 'adc_input';
% Example: InputSource = 'dma_input';
InputSource = 'dma_input';
end

properties (Nontunable)
properties
% OutputRange
% Lists all the available voltage ranges of the output signal.
% Options are: '0/2.5V', '0/5V', '0/10V', '-5/+5V', '-10/+10V'.
InputSource = '-10/+10V';
% Example: OutputRange = '-10/+10V';
OutputRange = '-10/+10V';
end

properties
Expand Down
3 changes: 2 additions & 1 deletion +adi/+AD3552R/Tx.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
channel_names = {'voltage0', 'voltage1'};
end

properties (Nontunable)
properties
% StreamStatus
% Describes the status of the data streaming.
% Options are: 'start_stream_synced', 'start_stream', 'stop_stream'.
% Example: StreamStatus = 'stop_stream';
StreamStatus = 'stop_stream';
end

Expand Down
74 changes: 74 additions & 0 deletions pcx_examples/streaming/cn0585_fmcz/CN0585_streaming.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
% CN0585 Streaming example

board_ip = 'local_board_ip';
uri = cat(2, 'ip:', board_ip);

% Describe the devices

cn0585_device_rx = adi.CN0585.Rx('uri',uri);
cn0585_device_tx0 = adi.CN0585.Tx0('uri',uri);
cn0585_device_tx1 = adi.CN0585.Tx1('uri',uri);

cn0585_device_tx0.EnableCyclicBuffers = true;
cn0585_device_tx1.EnableCyclicBuffers = true;

cn0585_device_rx.BufferTypeConversionEnable = true;

% Enable the channels to write data to (options are 1, 2 )

cn0585_device_tx0.EnabledChannels = [1, 2];
cn0585_device_tx1.EnabledChannels = [1, 2];

% Enable the channels to read data from (options are 1, 2, 3 ,4 )

cn0585_device_rx.EnabledChannels = [1, 2, 3, 4];

% Generate the sinewave signal

amplitude = 2 ^ 15;
sampFreq = cn0585_device_tx0.SamplingRate;
toneFreq = 1e3;
N = sampFreq / toneFreq;
x = linspace(-pi, pi, N).';
sine_wave = amplitude * sin(x);

% Continuously load data in the buffer and configure the GPIOs state
% (SetupInit Base file)
% DAC1 has to be updated and started first and then DAC0 in order to have syncronized data between devices

cn0585_device_tx1([sine_wave, sine_wave]);
cn0585_device_tx0([sine_wave, sine_wave]);

% Stream status available options: "start_stream_synced", "start_stream", "stop_stream"

cn0585_device_tx1.StreamStatus = 'start_stream';
cn0585_device_tx0.StreamStatus = 'start_stream';

% The data will be stored inside "data" variable

data = cn0585_device_rx();

title('ADAQ23876 Channels');
subplot(4, 1, 1);
plot(data(:, 1));
ylabel('Channel A');
subplot(4, 1, 2);
plot(data(:, 2));
ylabel('Channel B');
subplot(4, 1, 3);
plot(data(:, 3));
ylabel('Channel C');
subplot(4, 1, 4);
plot(data(:, 4));
ylabel('Channel D');
xlabel('Number of samples');

% Release the device

cn0585_device_tx1.StreamStatus = 'stop_stream';
cn0585_device_tx0.StreamStatus = 'stop_stream';

cn0585_device_tx1.release();
cn0585_device_tx0.release();

cn0585_device_rx.release();
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
%CN0585 Streaming example
% CN0585 Streaming example for AXI4 Lite register read/write

board_ip = 'local_board_ip';
uri = cat(2, 'ip:', board_ip);

% Describe the devices

cn0585_device_rx = adi.CN0585.Rx('uri', cat(2, 'ip:', board_ip));
cn0585_device_tx0 = adi.CN0585.Tx0('uri', cat(2, 'ip:', board_ip));
cn0585_device_tx1 = adi.CN0585.Tx1('uri', cat(2, 'ip:', board_ip));
cn0585_device_rx = adi.CN0585.Rx('uri',uri);
cn0585_device_tx0 = adi.CN0585.Tx0('uri',uri);
cn0585_device_tx1 = adi.CN0585.Tx1('uri',uri);

cn0585_device_tx0.EnableCyclicBuffers = true;
cn0585_device_tx1.EnableCyclicBuffers = true;

cn0585_device_rx.BufferTypeConversionEnable = true;

% enable the channels we want to write data to (options are 1, 2 )
% Enable the channels to write data to (options are 1, 2)

cn0585_device_tx0.EnabledChannels = [1, 2];
cn0585_device_tx1.EnabledChannels = [1, 2];

% enable the channels we want to read data from (options are 1, 2, 3 ,4 )
% Enable the channels to read data from (options are 1, 2, 3 ,4)

cn0585_device_rx.EnabledChannels = [1, 2, 3, 4];

write_reg = soc.libiio.aximm.WriteHost(devName = 'mwipcore0:mmwr-channel0', IPAddress = board_ip); % MathWorks IP Core Write channel
read_reg = soc.libiio.aximm.WriteHost(devName = 'mwipcore0:mmrd-channel1', IPAddress = board_ip); % MathWorks IP Core Read channel

% available options:'adc_input', 'dma_input', 'ramp_input'
% Input source available options: 'adc_input', 'dma_input', 'ramp_input'

cn0585_device_tx0.InputSource = 'dma_input';
cn0585_device_tx1.InputSource = 'dma_input';

% available options: '0/2.5V', '0/5V', '0/10V', '-5/+5V', '-10/+10V'
% Output range available options: '0/2.5V', '0/5V', '0/10V', '-5/+5V', '-10/+10V'

cn0585_device_tx0.OutputRange = '-10/+10V';
cn0585_device_tx1.OutputRange = '-10/+10V';


% generate the sine wave signal
% Generate the sinewave signal

amplitude = 2 ^ 15;
sampFreq = cn0585_device_tx0.SamplingRate;
Expand All @@ -45,19 +45,19 @@
x = linspace(-pi, pi, N).';
sine_wave = amplitude * sin(x);

% continuously load data in the buffer and configure the GPIOs state
% Continuously load data in the buffer and configure the GPIOs state
% (SetupInit Base file)
% DAC1 has to be updated and started first and then DAC0 in order to have syncronized data between devices

cn0585_device_tx1([sine_wave, sine_wave]);
cn0585_device_tx0([sine_wave, sine_wave]);

% available options: "start_stream_synced", "start_stream", "stop_stream"
% Stream status available options: "start_stream_synced", "start_stream", "stop_stream"

cn0585_device_tx1.StreamStatus = 'start_stream';
cn0585_device_tx0.StreamStatus = 'start_stream';

% the data will be contained inside "data" variable
% The data will be stored inside "data" variable

data = cn0585_device_rx();

Expand Down Expand Up @@ -85,7 +85,7 @@
ylabel('Channel D');
xlabel('Number of samples');

% release the device
% Release the device

cn0585_device_tx1.StreamStatus = 'stop_stream';
cn0585_device_tx0.StreamStatus = 'stop_stream';
Expand Down

0 comments on commit 550e7d5

Please sign in to comment.