Simulink ignores Query Instrument sample time
2 views (last 30 days)
Multiplexer on 21 Aug 2017
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.
Sebastian Castro on 21 Aug 2017
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: