Code covered by the BSD License  

Highlights from
MATLAB Support Package for Velleman K8055/VM110 Experiment Board

MATLAB Support Package for Velleman K8055/VM110 Experiment Board

by

 

MATLAB library for communicating with a Velleman K8055/VM110 USB Experiment Interface Board

vellboard.setup
function setup
% Setup script for Velleman K8055 package
%
% Determines the location of the K8055 DLL required for device
% communication. Also adds package's parent folder to the MATLAB search
% path so the package is accessable from anywhere for all future sessions.

%   Copyright 2011 The MathWorks, Inc.

%% Check version compatibility
if ~strcmp(computer,'PCWIN')
    msgbox('This package is only compatible with 32-bit MATLAB on a Windows system.',...
        'MATLAB version error','error');
    return;
end

%% Set the DLL install location
uiwait(msgbox({'Please install the K8055 SDK before continuing.'...
    'Detailed instructions can be found in README.pdf.'}));

while(1)
    % get directory and try to find K8055D.dll
    dlldir = uigetdir('','Please select the SDK directory:');
    oldpath = path;
    path(oldpath,genpath(dlldir));
    dllloc = which('K8055D.dll');
    path(oldpath);
    
    if isempty(dllloc) % is the file there?
        answer = questdlg({'SDK was not found in the indicated directory.',...
            'Click Retry to try again or Cancel to abort setup'},...
            'SDK Not Found','Retry','Cancel','Retry');
        if strcmp(answer,'Cancel')
            
            msgbox({'The K8055 SDK was not found in the indicated directory.',...
                'The SDK may be missing or corrupted.',...
                'Please download the SDK and run setup again'...
                'Detailed instructions can be found in README.pdf.'},'File not found','error');
            return;
        end
    else % success
        break;
    end
end

% remember file location
pref = vellboard.Prefs;
pref.K8055_DLL_Location = dllloc;
fprintf('K8055D.dll found at "%s"\n',dllloc);
fprintf('SDK directory set\n')

%% add package to MATLAB path
packageParentDir = fileparts(fileparts(mfilename('fullpath')));
addpath(packageParentDir);
fprintf('Added "%s" to MATLAB path\n', packageParentDir);

easyguidir = [packageParentDir '/EasyGUI'];
if exist(easyguidir,'file')
    addpath(easyguidir)
    fprintf('Added "%s" to MATLAB path\n', easyguidir);
else
    fprintf('Could not find EasyGUI directory. Skipping step.\n');
end

%% save the path
result = savepath;
if result==1
    msgbox({'Unable to save updated MATLAB path',...
        '  To save the path, you can: ',...
        '   1) Exit MATLAB ',...
        '   2) Right-click the MATLAB icon and select "Run as administrator" ',...
        '   3) Re-run Velleman.setup ',},'Unable to save path','error');
else
    fprintf('Saved updated MATLAB path\n');
    msgbox({'Setup successful. You can now use the functions in the'...
        'MATLAB Support Package for Velleman K8055/VM110.'},'Setup Successful');
end
end

Contact us