-
Notifications
You must be signed in to change notification settings - Fork 2
/
PS3000Config.m
186 lines (124 loc) · 7.16 KB
/
PS3000Config.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
%% PS3000Config Configure path information
% Configures paths according to platforms and loads information from
% prototype files for PicoScope 3000 Series Oscilloscopes. The folder
% that this file is located in must be added to the MATLAB path.
%
% Platform Specific Information:-
%
% Microsoft Windows: Download the Software Development Kit installer from
% the <a href="matlab: web('https://www.picotech.com/downloads')">Pico Technology Download software and manuals for oscilloscopes and data loggers</a> page.
%
% Linux: Follow the instructions to install the libps5000 and libpswrappers
% packages from the <a href="matlab:
% web('https://www.picotech.com/downloads/linux')">Pico Technology Linux Software & Drivers for Oscilloscopes and Data Loggers</a> page.
%
% Apple Mac OS X: Follow the instructions to install the PicoScope 6
% application from the <a href="matlab: web('https://www.picotech.com/downloads')">Pico Technology Download software and manuals for oscilloscopes and data loggers</a> page.
% Optionally, create a 'maci64' folder in the same directory as this file
% and copy the following files into it:
%
% * libps3000.dylib and any other libps3000 library files
% * libps3000Wrap.dylib and any other libps3000Wrap library files
% * libpicoipp.dylib and any other libpicoipp library files
% * libiomp5.dylib
%
% Contact our Technical Support team via the <a href="matlab: web('https://www.picotech.com/tech-support/')">Technical Enquiries form</a> for further assistance.
%
% Run this script in the MATLAB environment prior to connecting to the
% device.
%
% This file can be edited to suit application requirements.
%% Set Path to Shared Libraries
% Set paths to shared library files according to the operating system and
% architecture.
% Identify working directory
ps3000ConfigInfo.workingDir = pwd;
% Find file name
ps3000ConfigInfo.configFileName = mfilename('fullpath');
% Only require the path to the config file
[ps3000ConfigInfo.pathStr] = fileparts(ps3000ConfigInfo.configFileName);
% Identify architecture e.g. 'win64'
ps3000ConfigInfo.archStr = computer('arch');
try
addpath(fullfile(ps3000ConfigInfo.pathStr, ps3000ConfigInfo.archStr));
catch err
error('PS3000Config:OperatingSystemNotSupported', 'Operating system not supported - please contact [email protected]');
end
% Set the path according to operating system.
if(ismac())
% Libraries (including wrapper libraries) are stored in the PicoScope
% 6 App folder. Add locations of library files to environment variable.
setenv('DYLD_LIBRARY_PATH', '/Applications/PicoScope6.app/Contents/Resources/lib');
if(strfind(getenv('DYLD_LIBRARY_PATH'), '/Applications/PicoScope6.app/Contents/Resources/lib'))
addpath('/Applications/PicoScope6.app/Contents/Resources/lib');
else
warning('PS3000Config:LibraryPathNotFound','Locations of libraries not found in DYLD_LIBRARY_PATH');
end
elseif(isunix())
% Edit to specify location of .so files or place .so files in same directory
addpath('/opt/picoscope/lib/');
elseif(ispc())
% Microsoft Windows operating systems
% Set path to dll files if the Pico Technology SDK Installer has been
% used or place dll files in the folder corresponding to the
% architecture. Detect if 32-bit version of MATLAB on 64-bit Microsoft
% Windows.
ps3000ConfigInfo.winSDKInstallPath = '';
if(strcmp(ps3000ConfigInfo.archStr, 'win32') && exist('C:\Program Files (x86)\', 'dir') == 7)
try
addpath('C:\Program Files (x86)\Pico Technology\SDK\lib\');
ps3000ConfigInfo.winSDKInstallPath = 'C:\Program Files (x86)\Pico Technology\SDK';
catch err
warning('PS3000Config:DirectoryNotFound', ['Folder C:\Program Files (x86)\Pico Technology\SDK\lib\ not found. '...
'Please ensure that the location of the library files are on the MATLAB path.']);
end
else
% 32-bit MATLAB on 32-bit Windows or 64-bit MATLAB on 64-bit
% Windows operating systems
try
addpath('C:\Program Files\Pico Technology\SDK\lib\');
ps3000ConfigInfo.winSDKInstallPath = 'C:\Program Files\Pico Technology\SDK';
catch err
warning('PS3000Config:DirectoryNotFound', ['Folder C:\Program Files\Pico Technology\SDK\lib\ not found. '...
'Please ensure that the location of the library files are on the MATLAB path.']);
end
end
else
error('PS3000Config:OperatingSystemNotSupported', 'Operating system not supported - please contact [email protected]');
end
%% Set Path for PicoScope Support Toolbox Files if Not Installed
% Set MATLAB Path to include location of PicoScope Support Toolbox
% Functions and Classes if the Toolbox has not been installed. Installation
% of the toolbox is only supported in MATLAB 2014b and later versions.
% Check if PicoScope Support Toolbox is installed - using code based on
% <http://stackoverflow.com/questions/6926021/how-to-check-if-matlab-toolbox-installed-in-matlab How to check if matlab toolbox installed in matlab>
ps3000ConfigInfo.psTbxName = 'PicoScope Support Toolbox';
ps3000ConfigInfo.v = ver; % Find installed toolbox information
if(~any(strcmp(ps3000ConfigInfo.psTbxName, {ps3000ConfigInfo.v.Name})))
warning('PS3000Config:PSTbxNotFound', 'PicoScope Support Toolbox not found, searching for folder.');
% If the PicoScope Support Toolbox has not been installed, check to see
% if the folder is on the MATLAB path, having been downloaded via zip
% file or copied from the Microsoft Windows Pico SDK installer
% directory.
ps3000ConfigInfo.psTbxFound = strfind(path, ps3000ConfigInfo.psTbxName);
if(isempty(ps3000ConfigInfo.psTbxFound) && ispc())
% Check if the folder is present in the relevant SDK installation
% directory on Windows platforms (if the SDK installer has been
% used).
% Obtain the folder name
ps3000ConfigInfo.psTbxFolderName = fullfile(ps3000ConfigInfo.winSDKInstallPath, 'MATLAB' , ps3000ConfigInfo.psTbxName);
% If it is present in the SDK directory, add the PicoScope Support
% Toolbox folder and sub-folders to the MATLAB path.
if(exist(ps3000ConfigInfo.psTbxFolderName, 'dir') == 7)
addpath(genpath(ps3000ConfigInfo.psTbxFolderName));
end
else
warning('PS3000Config:PSTbxDirNotFound', 'PicoScope Support Toolbox directory not found.');
end
end
% Change back to the folder where the script was called from.
cd(ps3000ConfigInfo.workingDir);
%% Load Enumerations and Structure Information
% Enumerations and structures are used by certain shared library API functions.
% Find prototype file names based on architecture
[~, ps3000Structs, ps3000Enuminfo, ~] = ps3000MFile;