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

cleanup and stop acquisition only after measurement is done

parent 7b1c330b
%% alter path to your python (3.8 is tested) distribution here %% alter path to your python (3.8 is tested) distribution here
py_path = 'C:\Users\49151\AppData\Local\Programs\Python\Python37\python.exe'; py_path = 'C:\Users\Arthur-Vincent\AppData\Local\Programs\Python\Python38\python.exe';
broker_ip = '192.168.0.1'; broker_ip = '169.254.249.197';
%% Init components
%oscilloscope properties --> delivering mqtt string for RedPitaya Inputs
%mqtt stuff
addpath('../../lib'); addpath('../../lib');
addpath('../../lib/redpitaya'); addpath('../../lib/redpitaya');
myMqtt = mqtt_py_matlab(py_path); myMqtt = mqtt_py_matlab(py_path);
myMqtt.connect_mqtt(broker_ip); myMqtt.connect_mqtt(broker_ip);
%% Init components
for delay = -1e-3:5e-5:1e-3 %oscilloscope properties --> delivering mqtt string for RedPitaya Inputs
pointer = 1;
for delay = -1e-3:5e-5:1e-3 % loop over trigger delays
op = OscilloscopeProperties(); % get an object of the OscilloscopeProperties class 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(1.01e-4); % Set time per Oszilloscope-Div
%op.SampleRate = 15.6e6; % Set samplerate in MHz
op.TriggerDelay = delay; %Delay in samples (0 delay -> Start writing in the center of the buffer) op.TriggerDelay = delay; %Delay in samples (0 delay -> Start writing in the center of the buffer)
op.TriggerLevel = .5; % Trigger level in Volt
op.TriggerLevel = .2; % Trigger level in Volt Osc_proberty_message = op.get_mqtt_message(); % Get current OscilloscopeProperties as mqtt string
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';
% Subscription to RP1 with wildcard (#)
%myMqtt.sub_mqtt_topics(broker_ip, "RP1/#");
% Subscription without wildcard
%myMqtt.sub_mqtt_topics(broker_ip, "RP1/CONFIGURE/RECONFIG");
%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"));
fprintf('%s', test_message);
% get max length of x axis % get max length of x axis
x_axis = op.get_ordinate(); x_axis = op.get_ordinate();
%% Mqtt subscriptions
% Subscription to topic without wildcard
myMqtt.sub_mqtt_topics(broker_ip, "RP1/raw/CH1"); myMqtt.sub_mqtt_topics(broker_ip, "RP1/raw/CH1");
% Start oszilloscope
myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/START", test_message);
%% Mqtt publish
%% Signal aquisition
%while(1) % Publish Redpitaya API message
% Read input 1 myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/RECONFIG", "STOP");
arr = myMqtt.get_payload_float("RP1/raw/CH1");
y_mat = cell2mat(cell(arr));
% Plot input 1
%subplot (2,1,1)
plot(x_axis, y_mat);
grid on;
drawnow;
% Plot filtered input 1 % Read the last published message
%subplot (2,1,2) %fprintf('%s', myMqtt.get_payload_str("RP1/CONFIGURE/RECONFIG"));
%plot(x_axis, y_filt); fprintf('%s', Osc_proberty_message);
%grid on;
% Publish start oszilloscope
myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/START", Osc_proberty_message);
%% Signal aquisition
% Read input 1
arr = myMqtt.get_payload_float("RP1/raw/CH1");
y_mat = cell2mat(cell(arr));
y_mat_all(:,pointer) = y_mat;
pointer = pointer+1;
% Plot input 1
plot(x_axis, y_mat);
%ax.YTick = -1.5:0.5:1.5;
ylim([-1.5,1.5])
grid on;
drawnow;
%end
% Stop the aquisition
myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/RECONFIG", "STOP");
end end
% Stop the aquisition
myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/RECONFIG", "STOP");
\ No newline at end of file
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