Slow matlab while doing hardware in the loop

4 views (last 30 days)
Hello,
I have developed a Matlab program which runs some hardware in the loop. The hardware I use is:
  • Matlab R2008a 32bit on windows seven
  • labjack U6 (USB 2.0) Using loadlibrary + calllib functions
  • Phidget 1056 (USB 2.0) Using loadlibrary + calllib functions
  • 2 serial interfaces, one @ 34800 baud, one @ 921600 baud
Using serial object and fread function. Buffer is set to contain 5 packages of data so the loop doesn’t have to wait for the buffer to fill.
  • UDP interface running at 1 Hz loop, sending data
I have several machines running this software but unfortunately one of the machines doesn’t run the program at the correct speed, it only runs at 50 samples/sec.
The program is a while loop which is controlled by a GUI. The while loop should poll the data from all device at a sample rate of 200Hz and the serial interface running at 34800 baud is polled 1 time every 200 samples.
The problem I have is that the whole program is slower, not just one interface like the serial or the usb.
I hope that someone of you has a suggestion in increasing the speed of the Matlab process.
I already checked the following things:
  • USB interfaces are indeed high speed 2.0 interface
  • Using the original software for the separate devices works like a charm
  • Using three different laptops and only this one give the problem
  • Installed a clean version of windows (xp, vista and seven) no different
  • Updated all drivers
  • Used different USB ports
  • Used the profiler to check for time consuming actions.
  • %MatlabRoot\toolbox\matlab\iofun\@serial\subsref.m >> line 121 takes a lot of time (0.012s each call).
  • Secondly the calllib function getting the data from the phidget spatial takes a lot of time (~0.0092s each call)
  • Compared to the machines that are running good, the serial connections consume more time. In the good machines the most time is used to send the data over the UDP connection (relative to the number of calls). The phidget command is the slowest part of the program (~0.0021s each call)
System specs of the problem machine:
  • Matlab r2008a
  • Windows seven 32bit
  • usb 2.0
  • intel atom n550 1.5ghz
  • 2gb ddr3 ram
I am quite sure that the problem lies in Matlab, as all the other software runs good (using the same dll’s and hardware drivers).
I check the activities of windows itself, it only uses 1.2gb of ram and 50 – 60% of the cpu while running the program. Antivirus and the like are turned off.
Thanks in advance for any help.
Johan de Leeuw

Answers (2)

Walter Roberson
Walter Roberson on 14 Dec 2011
R2008a is not officially supported for Windows 7; official Windows 7 support started with R2009a. http://www.mathworks.com/matlabcentral/answers/16902-error-in-installing-matlab-r2008a-in-windows-7
  1 Comment
HansJoore
HansJoore on 15 Dec 2011
Hi,
thank you for your answer, I also tried windows xp and vista but not better results on that.
I also dumped the GUI to check if this on is interfering with my program, but unfortunately no result.
Johan

Sign in to comment.


Ruud
Ruud on 3 May 2012
Dear Johan,
I am just getting started with matlab, and was wondering if you mind sharing your code (i.e. the program you wrote to run a labjack device). We have a LJ U6 like you, and would like to use this for data acquisition purposes (i.e. build a gui that allows us to send and receive data to several other external devices).
Thanks for any help. Ruud

Categories

Find more on Creating and Concatenating Matrices 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!