Clear Filters
Clear Filters

Arduino Mega 2560 sample rate inconsistent

3 views (last 30 days)
Thomas
Thomas on 6 Jul 2016
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

Answers (0)

Categories

Find more on MATLAB Support Package for 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!