timer period resolution issue
1 view (last 30 days)
Show older comments
Hi all,
I am using MATLAB 2022b version.
I am developing a script which sends the packet at every 10 msec.
I configured the timer in free running mode with the period of 10 msec and then started storing the time stamp value in an array at each interrupt in my timer ISR.
Then plotted the difference between the time stamp values ,we are observing that the timer interrupt is varying from 7msec to 15msec.
But when the same calculations are carried out for 1sec period, we have observed that max error was 2msec .
Can you please provide me a wayout to configure the timer at 10 msec period.
0 Comments
Answers (2)
Dr. JANAK TRIVEDI
on 7 Feb 2023
% Start timer
t = timer('TimerFcn',@timerISR, 'Period', 10/1000, 'ExecutionMode', 'fixedRate');
start(t);
% Timer ISR function
function timerISR(~,~)
tic; % Start measuring processing time
% Code to store time stamp value in an array
processingTime = toc; % End measuring processing time
set(t,'Period',(10 - processingTime)/1000); % Adjust timer period
end
See Also
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!