Matlab freezes after trying to disconnect two scopes

Post your MATLAB discussions here
Post Reply
furuian
Newbie
Posts: 0
Joined: Wed May 11, 2016 2:02 pm

Matlab freezes after trying to disconnect two scopes

Post by furuian » Wed May 11, 2016 2:17 pm

Hello,

I have two Picoscopes connect to the same PC. One is a 5444B and the other one a 5444A.

I was trying to read blocks from both of them (which worked well) but I find that whenever I disconnect the first scope, Matlab freezes. I was able to reduce the issue to the following bare bones code:

WORKS (only one scope):

Code: Select all

PS5000aConfig;

ps5000aDeviceObj = icdevice('picotech_ps5000a_generic.mdd','CS960/135'); 

connect(ps5000aDeviceObj);

pause(1)

disconnect(ps5000aDeviceObj); 
Matlab returns:

Code: Select all

Close unit status: 0
Unit closed successfully.
Libraries unloaded successfully.
DOESNT WORK (both scopes):

Code: Select all

PS5000aConfig;

ps5000aDeviceObj = icdevice('picotech_ps5000a_generic.mdd','CS960/135'); 
ps5000aDeviceObj2 = icdevice('picotech_ps5000a_generic.mdd','CZ435/015'); 

connect(ps5000aDeviceObj);
connect(ps5000aDeviceObj2);

pause(1)

disconnect(ps5000aDeviceObj);
disconnect(ps5000aDeviceObj2);
Matlab returns:

Code: Select all

Close unit status: 0
and freezes, already during the first disconnect call.

Any help is much appreciated. Thank you.
Last edited by furuian on Wed May 11, 2016 2:53 pm, edited 1 time in total.

Hitesh
Site Admin
Site Admin
Posts: 2829
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Matlab freezes after trying to disconnect two scopes

Post by Hitesh » Wed May 11, 2016 2:41 pm

Hi furuian,

The Instrument Driver does not currently fully support multiple oscilloscopes, partly the Disconnect code unloads the ps5000a and ps5000aWrap libraries after closing the connection to the unit. This means that once the first device has been disconnected, the lockup occurs because the libraries are no longer loaded in the MATLAB environment.

There is a potential workaround which involves calling the shared library API function to close the connection directly instead of using disconnect():

Code: Select all

[status.closeUnit] = calllib('ps5000a', 'ps5000aCloseUnit', ps5000aDeviceObj.unitHandle);
[status.closeUnit2] = calllib('ps5000a', 'ps5000aCloseUnit', ps5000aDeviceObj2.unitHandle);

unloadlibrary('ps5000a');
unloadlibrary('ps5000aWrap');
We will look to see if we can provide a fix to this in a future release.

Please note that multiple device support using this Instrument Driver for streaming mode data collection is not possible at this moment in time.

Regards,
Hitesh

Technical Support Engineer

furuian
Newbie
Posts: 0
Joined: Wed May 11, 2016 2:02 pm

Re: Matlab freezes after trying to disconnect two scopes

Post by furuian » Wed May 11, 2016 2:51 pm

Thank you for your quick reply, Hitesh.

The workaround appears to be working in my first tests.

Hitesh
Site Admin
Site Admin
Posts: 2829
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: Matlab freezes after trying to disconnect two scopes

Post by Hitesh » Thu May 12, 2016 8:59 am

Hi furuian,

Thanks for confirming that.

If you do encounter any issues please post back here.

Regards,
Hitesh

Technical Support Engineer

Post Reply