Error on connecting to 3204D

Post your MATLAB discussions here
Post Reply
kevinmca
Newbie
Posts: 0
Joined: Fri Sep 01, 2017 3:51 pm

Error on connecting to 3204D

Post by kevinmca »

I am trying to connect to a 3204D scope using the MATLAB drivers.

I have the Instrument Control Toolbox, the Picoscope Support Toolbox and the PS3000a MATLAB Instrument Driver. The files from the support toolbox and instrument driver are in a folder under my main installation, along with the ps3000a.dll and .h files, the ps3000aWrap.dll and .h files and the PicoStatus.h file.

When I run the example file

Code: Select all

PS3000A_ID_Block_Example.m
I get the following in the command line

Code: Select all

Copyright © 2014-2017 Pico Technology Ltd. All rights reserved.

PicoScope 3000 Series MATLAB Instrument Driver

Error using instrument/delete (line 82)
Operation failed: An error occurred while executing the driver disconnect code.
Reference to non-existent field 'unitHandle'.
If this error is not an instrument error, use MIDEDIT to inspect the driver.

Error in icdevice (line 308)
                delete(obj);

Error in PS3000A_ID_Block_Example (line 54)
ps3000aDeviceObj = icdevice('picotech_ps3000a_generic.mdd', '');
At this point the ICT seems to be attempting to run a section of code to assess the functionality of the scope:

Code: Select all

% This function is called after the object is created.
% OBJ is the device object.
% End of function definition - DO NOT EDIT

% Copyright © 2014 - 2017 Pico Technology Ltd. All rights reserved. 
% You may copy and distribute this file as long as it remains unmodified. 
% SB
    
    fprintf('\nCopyright © 2014-2017 Pico Technology Ltd. All rights reserved.\n');
    fprintf('\n');
    fprintf('PicoScope 3000 Series MATLAB Instrument Driver\n');
    fprintf('\n');

    % Only load library once 
    if (libisloaded('ps3000a'))
       
        % Do nothing
        
    else
       
        if (ispc)
            
            loadlibrary('ps3000a.dll', @ps3000aMFile);
            
        elseif (ismac)
            
                loadlibrary('libps3000a.dylib', @ps3000aMFile, 'alias', 'ps3000a');
            
        elseif (isunix)
                
                loadlibrary('libps3000a.so', @ps3000aMFile, 'alias', 'ps3000a');
            
        else
            
            % Do nothing
        
        end
        
    end

    % Only load library once 
    if (libisloaded('ps3000aWrap'))

        % Do nothing
        
    else
        
        if (ispc)
            
            loadlibrary('ps3000aWrap.dll', @ps3000aWrapMFile);
            
        elseif (ismac)
            
            loadlibrary('libps3000awrap.dylib', @ps3000aWrapMFile, 'alias', 'ps3000aWrap');
            
        elseif (isunix)   

            loadlibrary('libps3000aWrap.so', @ps3000aWrapMFile, 'alias', 'ps3000aWrap');
            
        else
            
            % Do nothing
           
        end
        
    end
    
    % Confirm data files have been loaded
    if (exist('PicoConstants.m', 'file') == 0)
    
        error('File PicoConstants.m not found - please ensure that the location of this file is added to the MATLAB Path.')
    
    end

    if (exist('PS3000aConstants.m', 'file') == 0)
    
        error('File ps3000aConstants.m not found - please ensure that the location of this file is added to the MATLAB Path.')
    
    end

    if (isstruct(evalin('base', 'ps3000aEnuminfo')) && isstruct(evalin('base', 'ps3000aStructs')))
    
        % Do nothing - structures have been loaded
    
    else

        error('Failed to load enumerations and/or structures from ps3000aMFile');
    
    end
    
    % Obtain flag to indicate if functions should output text to Command
    % Window
    % -------------------------------
    
    obj.DriverData.displayOutput = obj.displayOutput;
    
    % Enumerate units - only displayed if driver is being used via command
    % line
    
    count = int16(0);
    serials = blanks(100);
    serialLth = int16(100);
    
    [status, count, serials, serialLth] = calllib('ps3000a', ...
        'ps3000aEnumerateUnits',  count, serials, serialLth);
    
    if (status == PicoStatus.PICO_OK)
        
        fprintf('Number of units found: %d\n\nSerial number(s): %s\n\n', count, serials);
        
    elseif (status == PicoStatus.PICO_NOT_FOUND)
        
        error('No units found.');
        
    else
        
        error('Status code: %d\n', status);
        
    end
However, the code fails before any of this can be evaluated, as it seems the scope driver hasn't created a handle for the scope correctly. Evaluating the sections manually creates no issues until

Code: Select all

obj.DriverData.displayOutput = obj.displayOutput;
, where the error

Code: Select all

No appropriate method, property, or field 'displayOutput' for class 'icdevice'.
is returned. I assume this is because I am attempting to run it in an environment which is different to how it would be called by the

Code: Select all

instrgate
function in the

Code: Select all

icdevice
function.

Does anyone have any idea what the issue is here?

Thanks,

Kevin

Hitesh

Re: Error on connecting to 3204D

Post by Hitesh »

Hi Kevin,

This is possibly due to one or more components not being on the MATLAB path.

Which version of MATLAB are you using and did you use the Add-Ons Explorer in MATLAB to install the Instrument Driver files and PicoScope Support Toolbox?

If you have installed the PicoSDK driver package on your installer, then the PS3000aConfig.m script will add the path to the dll files to the MATLAB path as required when you run the example scripts, so it shouldn't be necessary to copy dll files (note that the ps3000a.dll does have a dependency on the picoipp.dll) unless they are required to be in a different location.

As we provide prototype files in sub-folders for the Instrument Drivers, the .h header files are not required.

Regards,

Post Reply