Skip to content

Commit

Permalink
pcx: Rename cn0585 folders
Browse files Browse the repository at this point in the history
  • Loading branch information
StancaPop committed Jul 18, 2024
1 parent 191b36e commit f766896
Show file tree
Hide file tree
Showing 21 changed files with 1,299 additions and 0 deletions.
74 changes: 74 additions & 0 deletions pcx_examples/streaming/cn0585/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
@@ -0,0 +1,96 @@
% 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',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];

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

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

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

% 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 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();

if cn0585_device_tx0.CheckMathWorksCore()

write_reg.writeReg(hex2dec('100'), 85);
write_reg.writeReg(hex2dec('104'), 22);

fprintf('Read value from the 0x108 register is: %d \n', read_reg.readReg(hex2dec('108')));
fprintf('Read value from the 0x10c register is: %d \n', read_reg.readReg(hex2dec('10c')));
end

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();
Binary file not shown.
Loading

0 comments on commit f766896

Please sign in to comment.