Skip to content

Commit

Permalink
Added example script for PROFIBUS decoding using waveform files
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericdepuydt committed Oct 13, 2020
1 parent d415bbe commit 48fea92
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 0 deletions.
66 changes: 66 additions & 0 deletions examples/PROFIBUS/DPO4054B.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
%% LIBRARIES
% Manually add libraries to path
% Preferrably using Git or by downloading a released version
%
% Author: Frederic Depuydt <frederic.depuydt@outlook.com>
% Url: https://github.com/fredericdepuydt/matlab-libraries/releases
% Command: git clone https://github.com/fredericdepuydt/matlab-libraries.git libraries

%% CLEAN WORKSPACE AND FIGURES
clear all;
close all;

%% CREATING SCOPE OBJECTS FROM WAVEFORM FILE

% For the DPO4054B a waveform file of type .isf is required
% using scope class -> isfread function -> file and verbosity as parameters
% file = "tek0000CH1.isf"
% verbose = -1 -> Full depth verbosity (Output everything to CLI)
objDPO4054B = scope.isfread("DPO4054B/tek0000CH1.isf", -1);

% Both functions return an object of class scope

%% PLOTTING SCOPE OBJECT
CH1 = objDPO4054B.channels(1);
X = objDPO4054B.time;
Y = objDPO4054B.values(CH1);

figure(1);
plt(X,Y);

%% CREATING PROFIBUS (Currently UART Class) object
objUART = uart.decode(objDPO4054B, 1, 1500000, -1);

%% PLOT UART OBJECT
figure();
objUART.plot(0,0,1)
axis([objUART(1).time objUART(end).time_end -3 3]);

%% TABLE WITH PACKETS
figure();
objUART.table()

%% EXPORT TO PROFITRACE
objUART.ptdwrite("test.ptd",-1);

%% IMPORT FROM PROFITRACE
newUART = uart.ptdread("test.ptd",-1);

%% FILTERING PROFIBUS PACKETS
SD1 = objUART.filter('SD1');
SD2 = objUART.filter('SD2');
SD3 = objUART.filter('SD3');
SD4 = objUART.filter('SD4');
SC = objUART.filter('SC');


SD2or4 = objUART.filter('SD2 OR SD4');

Master = objUART.filter('SA = 74');

Retries = objUART.filter('FC = 6D');





1 change: 1 addition & 0 deletions examples/PROFIBUS/DPO4054B/.~lock.tek0000RS2.csv#
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Frederic Depuydt,PC-FREDERIC/fdepu,,09.10.2020 14:07,file:///C:/Users/fdepu/AppData/Roaming/LibreOffice/4;
Binary file added examples/PROFIBUS/DPO4054B/tek00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/PROFIBUS/DPO4054B/tek00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/PROFIBUS/DPO4054B/tek0000CH1.isf
Binary file not shown.
43 changes: 43 additions & 0 deletions examples/PROFIBUS/MSO5045B.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
%% LIBRARIES
% Manually add libraries to path
% Preferrably using Git or by downloading a released version
%
% Author: Frederic Depuydt <frederic.depuydt@outlook.com>
% Url: https://github.com/fredericdepuydt/matlab-libraries/releases
% Command: git clone https://github.com/fredericdepuydt/matlab-libraries.git libraries

%% CLEAN WORKSPACE AND FIGURES
clear all;
close all;

%% CREATING SCOPE OBJECTS FROM WAVEFORM FILE

% For the MSO5054B a waveform file of type .wfm is required
% using scope class -> wfmread function -> file and verbosity as parameters
% file = "waveform_CH1.wfm"
% verbose = -1 -> Full depth verbosity (Output everything to CLI)
objMSO5045B = scope.wfmread('MSO5045B/waveform_CH1.wfm',-1);

% Both functions return an object of class scope

%% PLOTTING SCOPE OBJECT
CH1 = objMSO5045B.channels(1);
X = objMSO5045B.time;
Y = objMSO5045B.values(CH1);

figure(1);
plt(X,Y);

%% CREATING PROFIBUS (Currently UART Class) object
objUART = uart.decode(objMSO5045B, 1, 1500000, -1);

%% PLOT UART OBJECT
figure();
objUART.plot(0,0,1)
axis([objUART(1).time objUART(end).time_end -3 3]);

%% TABLE WITH PACKETS
figure();
objUART.table()


Binary file added examples/PROFIBUS/MSO5045B/201009_053146.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/PROFIBUS/MSO5045B/201009_054303.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/PROFIBUS/MSO5045B/201009_054515.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/PROFIBUS/MSO5045B/waveform_CH1.wfm
Binary file not shown.

0 comments on commit 48fea92

Please sign in to comment.