Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
John, Fabian
cosa-tools-matlab
Commits
4c6246d6
Commit
4c6246d6
authored
Jun 18, 2021
by
John, Fabian
Browse files
fixed issues and modiefied program for varying delays.
parent
f0eb6151
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/redpitaya/Oscilloscope_example.m
View file @
4c6246d6
%% alter path to your python (3.8 is tested) distribution here
py_path
=
'C:\Users\
Arthur-Vincent
\AppData\Local\Programs\Python\Python3
8
\python.exe'
;
broker_ip
=
'1
27.0
.0.1'
;
py_path
=
'C:\Users\
49151
\AppData\Local\Programs\Python\Python3
7
\python.exe'
;
broker_ip
=
'1
92.168
.0.1'
;
%% Init components
%oscilloscope properties --> delivering mqtt string for RedPitaya Inputs
%mqtt stuff
addpath
(
'../../lib'
);
addpath
(
'../../lib/redpitaya'
);
addpath
(
'../../lib/redpitaya'
);
myMqtt
=
mqtt_py_matlab
(
py_path
);
myMqtt
.
connect_mqtt
(
broker_ip
);
for
delay
=
-
1e-3
:
5e-5
:
1e-3
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.SampleRate = 15.6e6; % Set samplerate in MHz
% Two options to set sample rate
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
.
Trigger
Delay
=+
8192
;
%Delay in samples (0 delay -> Start writing in the center of the buffer)
op
.
Trigger
Level
=
.
2
;
% Trigger level in Volt
op
.
TriggerLevel
=
.
001
;
% 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';
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
to RP1
with wildcard
(#)
myMqtt
.
sub_mqtt_topics
(
broker_ip
,
"RP1/
#
"
);
% Subscription with
out
wildcard
%
myMqtt.sub_mqtt_topics(broker_ip, "RP1/
CONFIGURE/RECONFIG
");
% Subscription without wildcard
myMqtt
.
sub_mqtt_topics
(
broker_ip
,
"RP1/CONFIGURE/RECONFIG"
);
%pause(2);
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
);
% 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
);
% 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
(
);
% get max length of x axis
x_axis
=
op
.
get_ordinate
();
myMqtt
.
sub_mqtt_topics
(
broker_ip
,
"RP1/raw/CH1"
);
% Start oszilloscope
myMqtt
.
pub_mqtt
(
broker_ip
,
"RP1/CONFIGURE/START"
,
test_message
);
pause
(
2
);
%% Signal aquisition
% Start oszilloscope
myMqtt
.
pub_mqtt
(
broker_ip
,
"RP1/CONFIGURE/START"
,
test_message
);
%% Filter
%while(1)
% Read input 1
arr
=
myMqtt
.
get_payload_float
(
"RP1/raw/CH1"
);
y_mat
=
cell2mat
(
cell
(
arr
));
Hd
=
fir_highpass2k
;
% Plot input 1
%subplot (2,1,1)
plot
(
x_axis
,
y_mat
);
grid
on
;
drawnow
;
%% Signal aquisition
% Plot filtered input 1
%subplot (2,1,2)
%plot(x_axis, y_filt);
%grid on;
%while(1)
% Read input 1
arr
=
myMqtt
.
get_payload_float
(
"RP1/raw/CH1"
);
y_mat
=
cell2mat
(
cell
(
arr
));
%filter input 1
y_filt
=
filter
(
Hd
,
y_mat
);
% Plot input 1
subplot
(
2
,
1
,
1
)
plot
(
x_axis
,
y_mat
);
grid
on
;
% Plot filtered input 1
subplot
(
2
,
1
,
2
)
plot
(
x_axis
,
y_filt
);
grid
on
;
%end
% Stop the aquisition
myMqtt
.
pub_mqtt
(
broker_ip
,
"RP1/CONFIGURE/RECONFIG"
,
"STOP"
);
%
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment