Simulink ignores Query Instrument sample time
1 次查看(过去 30 天)
显示 更早的评论
I have my application that uses block called "Query Instrument" to read data over Serial port. Block have parameter Block Sample Time set to 0.5 (half second?). My model fixed step size is also set to 0.5. The data from Serial is being saved to workspace with "To Workspace" block (saved as array).
What is happening is that Simulink completely ignores Query Instrument sample time and performs simulation as fast as possible. Even if i stop it after real time 4 seconds my workspace variable have over 500 elements.
Now what i expect is that if i start simulation to receive data over Serial port, with its sample time being 0.5 and Simulink step size set to 0.5, when i start simulation and count to 4 seconds real time and then stop it, i should have around 8 element array in workspace (not exactly as i might be not fast enough to stop/start counting).
So with that what above, my questions are: Why does this happen? Why Simulink ignores sampling time? Do i understand something wrong? Why does Query Instrument even have sample time parameter if Simulink ignores it? How do i change it? I want my model read data from Serial in real time.
0 个评论
采纳的回答
Sebastian Castro
2017-8-21
You're right that Simulink simulations run as fast as possible by default.
If you want to slow this down so your instrument is being read approximate real-time, try using this block:
- Sebastian
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!