Filter löschen
Filter löschen

GUI Timer to Control LabChart 'Realtime' Data collection

2 Ansichten (letzte 30 Tage)
Michael Horn
Michael Horn am 11 Mär. 2019
Kommentiert: per isakson am 8 Feb. 2020
Hello,
I'm looking to create a GUI that will allow me to gate when I pull data from an external device called Powerlab. There is currenly some interfacing code HERE which allows for the me to ge data but it is quite clunky. I'm wanting to use a timer function within a GUI to fetch new data on a regular interval, do some math on it and use this data to control another device for a closed-loop application.
When I run my code I get this error particular error (shown directly below) and I'm not really sure what to do about it.
<Error while evaluating TimerFcn for timer 'Reminder'
Undefined function 'updater' for input arguments of type 'timer'.>
I'd appreciate any helpful hints to help solve this issue.
Thanks,
Ryne
classdef SingleChannelGUI < matlab.apps.AppBase
%% Properties that correspond to app components
properties (Access = public)
%% Empty to limit size of post
end
%% Variables
properties (Access = public)
%% Empty to limit size of post
end
%% event functions
methods (Access = private)
%% Removed other functions to limit size of post
function updater(app,varargin)
gLCDoc.StartSampling(app.wndw)
plot(gChansData{gChans})
end
end
%% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
%% Empty to limit size of post
end
end
methods (Access = public)
% Construct app
function app = SingleChannelGUI
% Create and configure components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
%% Setup Labchart
global gLCApp; % defines global gLCApp
global gChans; % Array of channel numbers specifying channels to retrieve
global tmr; % Global timer for windowing
global wndw; % to set the sample window
wndw = 1;
GetLCApp;
gChans = 1; % collect sampling data from channel 1, call multiple channels like this [1 2]
doc1 = gLCApp.ActiveDocument;
RegisterLCEvents(doc1); % hook up the OnSelectionChange event and the sampling events such as OnNewSamples and OnBlockStart.
tmr = timer('Name','Reminder',...
'Period',wndw,... % Update the time every 1 second for now
'StartDelay',0,... % In seconds.
'TasksToExecute',inf,... % number of times to update
'ExecutionMode','fixedSpacing',...
'TimerFcn',{@updater});
doc1 = gLCApp.ActiveDocument;
RegisterLCEvents(doc1); % hook up the OnSelectionChange event and the sampling events such as OnNewSamples and OnBlockStart.
start(tmr); % Start the timer object.
end
%% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
%% Close out Lab Chart connection
stop(tmr)
ReleaseLCDoc(doc1); %uncomment this if finished with doc1.
ReleaseLC(); %uncomment this if finished with gLCApp.
end
end
end
  2 Kommentare
Misha Zahid
Misha Zahid am 6 Feb. 2020
Sir were you able to find a solution to this? I am working on a similar problem and stuck on the same thing as yours.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Develop uifigure-Based Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by