Arduino Mega 2560 sample rate inconsistent

3 次查看(过去 30 天)
Hi All,
I've been trying to get a constant sample rate on an analog input on my Arduino Mega 2560. I've created a very simple Simulink model, where an Arduino analog input is fed into both a scope and a workspace write block. The Arduino analog input is sampling at 0.001s (1ms), which I think should be well within the capabilities of the hardware.
It seems to run alright in external mode, by that I mean it runs. But the scope isn't displaying anything - I've set the model duration as both 10s and infinite, and still don't get anything displaying in the scope.
The real problem that I want to find the answer for is the data that is written to the Matlab workspace. I seem to get some decent data there, but the time base that it has is all over the shop! I'm getting nowhere near 1ms, the average is roughly 30ms, but it is no way consistent. Is there anyway to improve this? The settings in the model are default, but I have set it to a discrete step time, is this correct?
Has anyone had this problem, and been able to get an answer. This is my first time on this Q&A area, so don't quite know what information to provide to help.
Cheers Tom

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by