필터 지우기
필터 지우기

App Designer - timer with random interruption

조회 수: 5 (최근 30일)
Chris
Chris 2021년 1월 20일
편집: Chris 2021년 2월 5일
Hello, maybe somebody know what is not working correct.
I implanted a timer (replaced a loop) for measurements my motor data. But sometimes if I increase/decrease with a spinner my velocity of the motor, the timer finished before I push the stop bottom. It happen always randomly. I guess something is affecting each other but I don’t know what. Maybe anyone has an idea?
Thanks a lot :)
methods (Access = private)
function MemoryTimerFcn(app,~,~)
% read my data (now I just put two inside=
app.actualVelocity.Value = webread()
app.actualMotorCurrent.Value = webread()
end
% .....a lot of other functions
end
function startupFcn(app)
app.MemoryTimer = timer(...
'ExecutionMode', 'fixedRate', ...
'Period',0.2, ...
'BusyMode', 'drop',...
'TimerFcn', @app.MemoryTimerFcn);
end
function MotorON(app, event)
start(app.MemoryTimer);
end
function MotorOFF(app, event)
stop(app.MemoryTimer);
end
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2021년 1월 26일
Chris - can you show where you call MotorON and MotorOff? Is the second function only called when you want to stop the motor (how do you know when to call this?) and is this function the only way to stop the timer? Also, how do you know that the timer has stopped prematurely - is there some sort of indication in the console (or whatever) output?
Chris
Chris 2021년 2월 5일
편집: Chris 2021년 2월 5일
Hello Geoff, thanks for helping me, sorry for my late answer.
I called the MotorON, MotorOFF with two Buttons. Yes for e.g. my measurements stop sometime if change my velocity value with a spinner.
I change already a lot of things, but I still have my problems with Timers. I guess they affect each other so they jumped out and worked in another process and than continuous.
Now I have already 4 timers:
  • measurements (is working almost the whole time)
  • live plotting data (Start/Stop - Button)
  • heartbeat (all the time) to check the communication with my motor control is existing
  • profile drive, read data from excel (velocity over time) and send them to my motor controller
The code is just an extract:
methods (Access = private)
function MemoryTimerFcn(app,~,~)
app.actualVelocity.Value = webread()
app.actualMotorCurrent.Value = webread()
end
function MemoryTimerFcn2(app,~,~)
%plotting my acutual data, Start/Stop Buttons
end
% send new velocity data (table) after time delay is over
function MemoryTimerFcn3
app.timerDelaySecs = app.X;
app.MemoryTimer3 = timer(...
'StartDelay',app.timerDelaySecs,...
'ExecutionMode', 'singleShot', ...
'BusyMode', 'queue',...
'TimerFcn', @app.MemoryTimerFcn3);
if (app.count <= size(app.data,1))
start(app.MemoryTimer3);
else
MotorOFFButtonPushed(app)
end
end
end
---------------------------------------------------------------------------
function startupFcn(app)
% measurements
app.MemoryTimer = timer(...
'ExecutionMode', 'fixedRate', ...
'Period',0.2, ...
'BusyMode', 'queue',...
'TimerFcn', @app.MemoryTimerFcn);
% live plotting data
app.MemoryTimer2 = timer(...
'ExecutionMode', 'fixedRate', ...
'Period',0.2, ...
'BusyMode', 'queue',...
'TimerFcn', @app.MemoryTimerFcn2);
% heartbeat, started here
app.MemoryTimer4 = timer(...
'ExecutionMode', 'fixedRate', ...
'Period',3, ...
'BusyMode', 'queue',...
'TimerFcn', @app.MemoryTimerFcn4);
start(app.MemoryTimer4);
end
Thanks for helping :)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by