Haider
Haider

Reputation: 189

A Bug in MATLAB in the simulink serial acquisition block in MATLAB

I just wanted to share my way to solve a bug in Simulink (in Matlab v2010a and the same pause instruction which is the cause of the problem found in MATLAB2014a as well).

When I get a serial input via the simulink serial acquisition block , if the data input rate is moderately fast (like more than 100 sample/sec.) , I see that the 1st 3 sec or so, the data input will be good then after those few seconds a very strange noise will appear.

By digging deep in the source code of this serial acquisition block, I saw that it is using a delay instruction ‘pause(0.001)’ and has been used apparently to delay the code running for 1 ms after each 1 sample acquisition.

Upvotes: 1

Views: 253

Answers (1)

Haider
Haider

Reputation: 189

Answering my own question: An article I found in MSDN titled “Windows Time” states: “GetTickCount and GetTickCount64 are limited to the resolution of the system timer, which is approximately 10 milliseconds to 16 milliseconds.” [1]. That means that delay will effectively limiting the maximum samples per sec. that can be read by this block.

I have deleted this pause line in the simulink serial acquisition block (line no. 331 in the script of the ‘serial receive’ block named ‘sserialrb.m’ in MATLAB R2010(a)) and everything worked well.

Hope this will help somebody!

[1] MSDN, "Windows Time," http://msdn.microsoft.com/en-us/library/windows/desktop/ms725496%28v=vs.85%29.aspx , 2012.

Upvotes: 0

Related Questions