Commit 7370c067 authored by Lindenberg, Arthur-Vincent's avatar Lindenberg, Arthur-Vincent
Browse files

Continus adc reading

parent 0a0aa4a2
......@@ -3,6 +3,11 @@ py_path = 'C:\Users\Arthur-Vincent\AppData\Local\Programs\Python\Python38\python
broker_ip = '127.0.0.1';
%% Oscilloscope plot config
osci_div =1.00e-4; % Oscilloscope grid (2kHz => 0.5ms)
osci_mag = 0.2; % Magnitude in Volt
%% Init components
%oscilloscope properties --> delivering mqtt string for RedPitaya Inputs
%mqtt stuff
......@@ -12,12 +17,22 @@ addpath('../../lib/redpitaya');
op = OscilloscopeProperties(); % get an object of the OscilloscopeProperties class
% Two options to set sample rate
op = op.set_sample_rate_by_div(1.01e-4); % Set time per Oszilloscope-Div
op = op.set_sample_rate_by_div(osci_div); % Set time per Oszilloscope-Div
%op.SampleRate = 15.6e6; % Set samplerate in MHz
op.TriggerDelay =+8192; %Delay in samples (0 delay -> Start writing in the center of the buffer)
% get sample rate of rp
rp_sample_rate = op.get_sample_rate_rp()
% get trigger delay of rp
trg_del_rp = op.get_trigger_delay_rp()
% get max length of x axis
x_axis = op.get_ordinate();
%op.TriggerDelay =8192; %Delay in samples (0 delay -> Start writing in the center of the buffer)
op.TriggerLevel = .001; % Trigger level in Volt
op.TriggerLevel = .00; % Trigger level in Volt
test_message = op.get_mqtt_message();
%test_message = '[OSC]\ntrigger_delay=100\ndecimation=1\ntrigger_level=0.2\ntrigger_ch=CH_1\ntrigger_src=CH_1_PE';
......@@ -40,16 +55,13 @@ myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/RECONFIG", test_message);
% Read the last published message
fprintf('%s', myMqtt.get_payload_str("RP1/CONFIGURE/RECONFIG"));
% get max length of x axis
x_axis = op.get_ordinate();
pause(2);
% Start oszilloscope
myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/START", test_message);
%% Filter
Hd = fir_highpass2k;
%Hd = fir_highpass2k;
%% Signal aquisition
......@@ -58,17 +70,27 @@ Hd = fir_highpass2k;
arr = myMqtt.get_payload_float("RP1/raw/CH1");
y_mat = cell2mat(cell(arr));
y_mat_shift = circshift(y_mat,8192+65);
%filter input 1
y_filt = filter(Hd,y_mat);
% y_filt = filter(Hd,y_mat);
% Plot input 1
subplot (2,1,1)
plot(x_axis, y_mat);
grid on;
ax = gca;
ax.XGrid = 'on';
%ax.XTick = 0:osci_div:osci_div*10;
ax.XTick = -osci_div*5:osci_div:osci_div*5;
ax.YGrid = 'on';
ax.YTick = -2*osci_mag:osci_mag:2*osci_mag;
% Plot filtered input 1
subplot (2,1,2)
plot(x_axis, y_filt);
plot(y_mat_shift);
grid on;
% Stop the aquisition
......
clear all
%% alter path to your python (3.8 is tested) distribution here
py_path = 'C:\Users\Arthur-Vincent\AppData\Local\Programs\Python\Python38\python.exe';
broker_ip = '127.0.0.1';
%% Oscilloscope plot config
osci_div =1.00e-4; % Oscilloscope grid (2kHz => 0.5ms)
osci_mag = 0.2; % Magnitude in Volt
%% Init components
%oscilloscope properties --> delivering mqtt string for RedPitaya Inputs
%mqtt stuff
addpath('../../lib');
addpath('../../lib/redpitaya');
op = OscilloscopeProperties(); % get an object of the OscilloscopeProperties class
% Two options to set sample rate
op = op.set_sample_rate_by_div(osci_div); % Set time per Oszilloscope-Div
%op.SampleRate = 15.6e6; % Set samplerate in MHz
op.TriggerDelay = 8192;
op.TriggerLevel = .75;
% get sample rate of rp
rp_sample_rate = op.get_sample_rate_rp()
% get trigger delay of rp
trg_del_rp = op.get_trigger_delay_rp()
% get max length of x axis
x_axis = op.get_ordinate();
%op.TriggerDelay =8192; %Delay in samples (0 delay -> Start writing in the center of the buffer)
%op.TriggerLevel = .00; % Trigger level in Volt
test_message = op.get_mqtt_message();
%test_message = '[OSC]\ntrigger_delay=100\ndecimation=1\ntrigger_level=0.2\ntrigger_ch=CH_1\ntrigger_src=CH_1_PE';
myMqtt = mqtt_py_matlab(py_path);
myMqtt.connect_mqtt(broker_ip);
% Subscription to RP1 with wildcard (#)
myMqtt.sub_mqtt_topics(broker_ip, "RP1/#");
% Subscription without wildcard
myMqtt.sub_mqtt_topics(broker_ip, "RP1/CONFIGURE/RECONFIG");
myMqtt.sub_mqtt_topics(broker_ip, "RP1/raw/CH1");
pause(2);
% Publish Redpitaya API message
myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/RECONFIG", test_message);
% Read the last published message
fprintf('%s', myMqtt.get_payload_str("RP1/CONFIGURE/RECONFIG"));
pause(2);
% Start oszilloscope
myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/START", test_message);
%% Filter
%Hd = fir_highpass2k;
%% Signal aquisition
xxx =1;
while(xxx <50)
myMqtt.sub_mqtt_topics(broker_ip, "RP1/raw/CH1"); % renew subcription
pause(1);
% Read input 1
arr = myMqtt.get_payload_float("RP1/raw/CH1");
y_mat = cell2mat(cell(arr));
% y_mat_shift = circshift(y_mat,8192+65+47);
%arr_payload(xxx)= y_mat;
% Plot input 1
% subplot (2,1,1)
plot(x_axis, y_mat);
% ax = gca;
% ax.XGrid = 'on';
% %ax.XTick = 0:osci_div:osci_div*10;
% %ax.XTick = -osci_div*5:osci_div:osci_div*5;
% ax.YGrid = 'on';
% ax.YTick = -2*osci_mag:osci_mag:2*osci_mag;
%
% % Plot input 1
% subplot (2,1,2)
% plot(y_mat_shift);
grid on;
xxx = xxx+1;
end
% Stop the aquisition
myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/RECONFIG", "STOP");
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment