|
2 | 2 | <MATLABInstrumentDriver> |
3 | 3 | <FileVersion>2.42</FileVersion> |
4 | 4 | <DriverName>C:\Users\neil.hamilton\Documents\MATLAB\picosdk-ps6000a-matlab-instrument-driver\picotech_ps6000a_generic.mdd</DriverName> |
5 | | - <DriverType>MATLAB interface object</DriverType> |
| 5 | + <DriverType>MATLAB generic</DriverType> |
6 | 6 | <InstrumentType>Oscilloscope</InstrumentType> |
7 | | - <InstrumentManufacturer>Pico Technology Ltd</InstrumentManufacturer> |
| 7 | + <InstrumentManufacturer>Pico Technology Ltd.</InstrumentManufacturer> |
8 | 8 | <InstrumentModel>PicoScope 6000E Series</InstrumentModel> |
9 | 9 | <InstrumentVersion>1.0</InstrumentVersion> |
10 | 10 | <Identify/> |
|
32 | 32 | % Only load library once |
33 | 33 |
|
34 | 34 | if (libisloaded('ps6000a')) |
| 35 | + |
35 | 36 | % do nothing |
| 37 | + |
36 | 38 | else |
| 39 | + |
37 | 40 | if (ismac()) |
| 41 | + |
38 | 42 | [ps6000aNotFound, ps6000aWarnings] = loadlibrary('libps6000a.dylib', @ps6000aMFile, 'alias', 'ps6000a'); |
| 43 | + |
39 | 44 | elseif (isunix()) |
| 45 | + |
40 | 46 | [ps6000aNotFound, ps6000aWarnings] = loadlibrary('libps6000a.so', @ps6000aMFile, 'alias', 'ps6000a'); |
| 47 | + |
41 | 48 | elseif (ispc()) |
| 49 | + |
42 | 50 | [ps6000aNotFound, ps6000aWarnings] = loadlibrary('ps6000a.dll', @ps6000aMFile); |
| 51 | + |
43 | 52 | else |
| 53 | + |
44 | 54 | % do nothing |
| 55 | + |
45 | 56 | end |
46 | | - end</Code> |
| 57 | + |
| 58 | + end |
| 59 | + |
| 60 | + % Load in enums and structures |
| 61 | + |
| 62 | + [~, obj.DriverData.structs, obj.DriverData.enums, ~] = ps6000aMFile();</Code> |
47 | 63 | </CreateInitCode> |
48 | 64 | <ConnectInitCode> |
49 | 65 | <Type>MCode</Type> |
50 | 66 | <Code>function init(obj) |
51 | 67 | % This function is called after the object is connected. |
52 | 68 | % OBJ is the device object. |
53 | 69 | % End of function definition - DO NOT EDIT |
| 70 | + |
| 71 | +% Copyright © 2020 Pico Technology Ltd. All rights reserved. |
| 72 | +% You may copy and distribute this file as long as it remains unmodified. |
| 73 | +% SB |
| 74 | + |
| 75 | + disp('Opening PicoScope 6000 Series (A API) device'); |
| 76 | + |
| 77 | + % Structure to hold satus values while connectin. |
| 78 | + connectStatus = []; |
| 79 | + |
| 80 | + % Temporary variable to store handle value |
| 81 | + unitHandle = 0; |
| 82 | + |
| 83 | + picoOK = PicoStatus.PICO_OK; |
| 84 | + |
| 85 | + % Obtain serial number input |
| 86 | + serialNum = get(obj, 'RsrcName'); |
| 87 | + |
| 88 | + % determine if serial number given |
| 89 | + if length(serialNum) > 0 |
| 90 | + |
| 91 | + unitSerial = serialNum; |
| 92 | + |
| 93 | + else |
| 94 | + |
| 95 | + unitSerial = []; |
| 96 | + |
| 97 | + end |
| 98 | + |
| 99 | + % Open with 8 bit resolution |
| 100 | + resolution8bit = obj.DriverData.enums.enPicoDeviceResolution.PICO_DR_8BIT; |
| 101 | + obj.DriverData.resolution = 8; |
| 102 | + |
| 103 | + [connectStatus.openUnit, obj.DriverData.unitHandle, ~] = ... |
| 104 | + calllib('ps6000a','ps6000aOpenUnit',unitHandle, unitSerial,resolution8bit); |
| 105 | + |
| 106 | + % Validate handle |
| 107 | + if (obj.DriverData.unitHandle > 0) |
| 108 | + |
| 109 | + unithandle = obj.DriverData.unitHandle; |
| 110 | +% |
| 111 | + % Set serial |
| 112 | + infoLine = blanks(40); |
| 113 | + reqSize = length(infoLine); |
| 114 | + |
| 115 | +% [connectStatus.unitSerial, obj.DriverData.unitSerial, reSize] = ... |
| 116 | +% calllib('ps6000a','ps6000aGetUnitInfo',unitHandle,infoLine, ... |
| 117 | +% length(infoLine),reqSize,PicoStatus.PICO_BATCH_AND_SERIAL); |
| 118 | +% |
| 119 | +% % Set variant |
| 120 | + infoLineV = blanks(15); |
| 121 | + reqSizeV = 15; |
| 122 | +% |
| 123 | +% [connectStatus.unitVariant, variant, ~] = calllib('ps6000a', ... |
| 124 | +% 'ps6000aGetUnitInfo', unitHandle, infoLineV, length(infoLineV),... |
| 125 | +% reqSizeV, PicoStatus.PICO_VARIANT_INFO); |
| 126 | +% |
| 127 | +% set(obj, 'InstrumentModel', variant); |
| 128 | +% |
| 129 | +% % Set channel count |
| 130 | +% obj.DriverData.channelCount = str2num(obj.InstrumentModel(2)); |
| 131 | +% |
| 132 | + elseif (connectStatus.openUnit == PicoStatus.PICO_NOT_FOUND) |
| 133 | + |
| 134 | + error('No unit found, please check connections.'); |
| 135 | + |
| 136 | + else |
| 137 | + |
| 138 | + error('Status code: %d\n', connectStatus.openUnit); |
| 139 | + |
| 140 | + end |
54 | 141 | </Code> |
55 | 142 | </ConnectInitCode> |
56 | 143 | <CleanupCode> |
|
59 | 146 | % This function is called before the object is disconnected. |
60 | 147 | % OBJ is the device object. |
61 | 148 | % End of function definition - DO NOT EDIT |
62 | | -</Code> |
| 149 | + |
| 150 | + if (isfield(obj.DriverData, 'unitHandle')) |
| 151 | + |
| 152 | + unitHandle = obj.DriverData.unitHandle; |
| 153 | + |
| 154 | + if (isempty(unitHandle)) |
| 155 | + return; |
| 156 | + end |
| 157 | + |
| 158 | + if (~libisloaded('ps6000a')) |
| 159 | + |
| 160 | + return |
| 161 | + |
| 162 | + end |
| 163 | + |
| 164 | + % Close scope |
| 165 | + |
| 166 | + disconnectStatus = calllib('ps6000a','ps6000aCloseUnit', unitHandle); |
| 167 | + |
| 168 | + if (disconnectStatus == PicoStatus.PICO_OK) |
| 169 | + |
| 170 | + fprintf(['PicoScope closed successfully.\n']); |
| 171 | + |
| 172 | + elseif (disconnectStatus == PicoStatus.PICO_INVALID_HANDLE) |
| 173 | + |
| 174 | + return |
| 175 | + |
| 176 | + else |
| 177 | + |
| 178 | +% if (isfield(obj.DriverData, 'unitSerial')) |
| 179 | +% |
| 180 | +% error('Disconnect: ConnectionNotClosed',... |
| 181 | +% ['Connection to PicoScope not closed. Status code %d\n']... |
| 182 | +% ,disconnectStatus); |
| 183 | +% |
| 184 | +% end |
| 185 | + |
| 186 | + end |
| 187 | + |
| 188 | +% % unload libraries if no other scopes are connected |
| 189 | +% |
| 190 | +% firestHandle = 0; |
| 191 | +% |
| 192 | +% if (ispc()) |
| 193 | +% |
| 194 | +% firstHandle = 16384; % Windows PC |
| 195 | +% |
| 196 | +% else |
| 197 | + |
| 198 | + else |
| 199 | + warning('Disconnect:NoDevicesFound', 'Disconnect: No devices found.'); |
| 200 | + end |
| 201 | +% |
| 202 | +% firstHandle = 1; % Mac and Linux |
| 203 | +% |
| 204 | +% end |
| 205 | +% |
| 206 | +% % test connection to other handles |
| 207 | +% lastHandle = firstHandle + 63 % obj.DriverData.constants.PICO_MAX_UNITS</Code> |
63 | 208 | </CleanupCode> |
64 | 209 | <GroupInfo> |
65 | 210 | <Group> |
|
70 | 215 | <Mappings> |
71 | 216 | <ChannelMap Command="parent1" Index="1"/> |
72 | 217 | </Mappings> |
73 | | - <PropertyInfo/> |
| 218 | + <PropertyInfo> |
| 219 | + <Property> |
| 220 | + <Name>channelCount</Name> |
| 221 | + <Location>parent</Location> |
| 222 | + <CapabilityGroup>Base</CapabilityGroup> |
| 223 | + <Type>MCode</Type> |
| 224 | + <Code> |
| 225 | + <GetMCode>function propertyValue = getProperty(obj, propertyName) |
| 226 | +% Return a property value. |
| 227 | +% This function is called to return the device or group object property |
| 228 | +% value. If the property is a group property, OBJ is the group object. If |
| 229 | +% the property is a base device property, OBJ is the device object. |
| 230 | +</GetMCode> |
| 231 | + <SetMCode>function set(obj, propertyName, propertyValue) |
| 232 | +% Set a property value. |
| 233 | +% This function is called to set the device or group object property |
| 234 | +% value. If the property is a group property, OBJ is the group object. If |
| 235 | +% the property is a base device property, OBJ is the device object. |
| 236 | +</SetMCode> |
| 237 | + </Code> |
| 238 | + <PermissibleType> |
| 239 | + <Type>Double</Type> |
| 240 | + <Constraint>none</Constraint> |
| 241 | + </PermissibleType> |
| 242 | + <DefaultValue>0</DefaultValue> |
| 243 | + <ReadOnly>never</ReadOnly> |
| 244 | + <Description/> |
| 245 | + </Property> |
| 246 | + <Property> |
| 247 | + <Name>resolution</Name> |
| 248 | + <Location>parent</Location> |
| 249 | + <CapabilityGroup>Base</CapabilityGroup> |
| 250 | + <Type>MCode</Type> |
| 251 | + <Code> |
| 252 | + <GetMCode>function propertyValue = getProperty(obj, propertyName) |
| 253 | +% Return a property value. |
| 254 | +% This function is called to return the device or group object property |
| 255 | +% value. If the property is a group property, OBJ is the group object. If |
| 256 | +% the property is a base device property, OBJ is the device object. |
| 257 | +</GetMCode> |
| 258 | + <SetMCode>function set(obj, propertyName, propertyValue) |
| 259 | +% Set a property value. |
| 260 | +% This function is called to set the device or group object property |
| 261 | +% value. If the property is a group property, OBJ is the group object. If |
| 262 | +% the property is a base device property, OBJ is the device object. |
| 263 | +</SetMCode> |
| 264 | + </Code> |
| 265 | + <PermissibleType> |
| 266 | + <Type>Double</Type> |
| 267 | + <Constraint>none</Constraint> |
| 268 | + </PermissibleType> |
| 269 | + <DefaultValue>0</DefaultValue> |
| 270 | + <ReadOnly>never</ReadOnly> |
| 271 | + <Description/> |
| 272 | + </Property> |
| 273 | + <Property> |
| 274 | + <Name>unitHandle</Name> |
| 275 | + <Location>parent</Location> |
| 276 | + <CapabilityGroup>Base</CapabilityGroup> |
| 277 | + <Type>MCode</Type> |
| 278 | + <Code> |
| 279 | + <GetMCode>function propertyValue = getProperty(obj, propertyName) |
| 280 | +% Return a property value. |
| 281 | +% This function is called to return the device or group object property |
| 282 | +% value. If the property is a group property, OBJ is the group object. If |
| 283 | +% the property is a base device property, OBJ is the device object. |
| 284 | +</GetMCode> |
| 285 | + <SetMCode>function set(obj, propertyName, propertyValue) |
| 286 | +% Set a property value. |
| 287 | +% This function is called to set the device or group object property |
| 288 | +% value. If the property is a group property, OBJ is the group object. If |
| 289 | +% the property is a base device property, OBJ is the device object. |
| 290 | +</SetMCode> |
| 291 | + </Code> |
| 292 | + <PermissibleType> |
| 293 | + <Type>Double</Type> |
| 294 | + <Constraint>none</Constraint> |
| 295 | + </PermissibleType> |
| 296 | + <DefaultValue>0</DefaultValue> |
| 297 | + <ReadOnly>never</ReadOnly> |
| 298 | + <Description/> |
| 299 | + </Property> |
| 300 | + <Property> |
| 301 | + <Name>unitSerial</Name> |
| 302 | + <Location>parent</Location> |
| 303 | + <CapabilityGroup>Base</CapabilityGroup> |
| 304 | + <Type>MCode</Type> |
| 305 | + <Code> |
| 306 | + <GetMCode>function propertyValue = getProperty(obj, propertyName) |
| 307 | +% Return a property value. |
| 308 | +% This function is called to return the device or group object property |
| 309 | +% value. If the property is a group property, OBJ is the group object. If |
| 310 | +% the property is a base device property, OBJ is the device object. |
| 311 | +</GetMCode> |
| 312 | + <SetMCode>function set(obj, propertyName, propertyValue) |
| 313 | +% Set a property value. |
| 314 | +% This function is called to set the device or group object property |
| 315 | +% value. If the property is a group property, OBJ is the group object. If |
| 316 | +% the property is a base device property, OBJ is the device object. |
| 317 | +</SetMCode> |
| 318 | + </Code> |
| 319 | + <PermissibleType> |
| 320 | + <Type>Double</Type> |
| 321 | + <Constraint>none</Constraint> |
| 322 | + </PermissibleType> |
| 323 | + <DefaultValue>0</DefaultValue> |
| 324 | + <ReadOnly>never</ReadOnly> |
| 325 | + <Description/> |
| 326 | + </Property> |
| 327 | + </PropertyInfo> |
74 | 328 | <MethodInfo/> |
75 | 329 | </Group> |
76 | 330 | </GroupInfo> |
|
0 commit comments