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

AnalogStripchart.m
% A  fancier version of SimpleAnalogStripchart. Adds buttons for selecting
% a channel, toggling the plot, changing the sample frequency, and stopping
% the script. Note that this implementation has an upper bound on sample
% frequency of about 70 Hz; go above this and the delay from the 
% board becomes more significant than the artificial pause.
%
% Doesn't have much error-checking for simplicity's sake, so deleting the 
% plot window will break the script. Make sure to clear out any lingering
% objects if you do this to avoid strange errors.
%
% See vellboard.Gui for a more complex but more robust implementation of a
% conceptually similar GUI.

%   Copyright 2011 The MathWorks, Inc.

samplefreq = 10; %starting sample frequency
numpoints = 300; %the number of points in the plot window

board = vellboard.ExperimentBoard;

plotgui = gui.autogui; %initialize gui
analogselect = gui.numericmenu('Analog Channel',[1,2]);
sampleslider = gui.slider('Sample Frequency (Hz)',[.1,75]);
sampleslider.Value = samplefreq;
plotbtn = gui.togglebutton('Toggle Plot');
exitbtn = gui.togglebutton('Exit');

chart = gui.stripchart(gca(),numpoints); %initialize chart


while ~exitbtn.Value
    if plotbtn.Value
        data = board.readAnalog(analogselect.Value); %get data
        chart.update(data); %update
    end
    pause(1/sampleslider.Value); %and wait
end

%cleanup
delete(board);
delete(plotgui);

Contact us