VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Running Simulink .mdl file under VeriStand

I'm trying to run a simulink .mdl file under Veristand (on Host PC) but MATLAB 2008b keeps crashing.  I created a simple simulink model: Veristand inport, gain block, outport and the Signal Probe Block.  I set solver to Fixed Step ODE3, turned logging off and set run length to inf.  The model will execute under simulink when the  play button is pressed.  I created an .in4 file and added the .mdl under the Models entry.  I get a green check mark and Simulink opens the model.  Exiting the explorer, I choose Run Workspace from the Getting started, I get some messages about TCP Reader and TCP Writer connecting - then MATLAB throws an error dialogue box and says it encountered a problem and needs to close.  Shortly after Veristand says it experienced a problem and needs to close.  Any ideas?  Is there some additional MATLAB configuration that needs to occur? 

0 Kudos
Message 1 of 9
(10,070 Views)

That sounds like all you need to do. Do you see anything in the MATLAB command window about 'termination deferred' after you load the model or try to hit run?

 

I've also seen things go badly when a "clear all" is executed in MATLAB. This causes the NI VeriStand server to go out of MATLAB memory and then the connection gets messed up. Is there anywhere you are running a "clear all" command, perhaps in a model callback?

 

MATLAB® and Simulink® are registered trademarks of The MathWorks, Inc. Other product and company names listed are trademarks and trade names of their respective companies.

Stephen B
0 Kudos
Message 2 of 9
(10,063 Views)

I'll take a closer look at the MATLAB execution window to see what MATLAB is doing during that time.  As far as I know there are no clear all being executed anywhere.  As a further sanity check, I built the model as a DLL and that executed fine without error both on local host and a Remote RT Target. 

0 Kudos
Message 3 of 9
(10,060 Views)

My local NI rep stopped by yesterday and said he thought the problem might be a conflict on Port 6012 - the port that Veristand Server uses to communicate to Simulink.  He said change the port number... I found this in the docs:

 

By default, NI VeriStand adds the command NIVeriStandAddPaths('start',6012) to the matlabrc.m file, a file that is installed by The MathWorks, Inc. MATLAB® software. This command starts the NI VeriStand Server on port 6012 when the MATLAB application software launches. To start the NI VeriStand Server on a different port, open matlabrc.m in a text editor and change 6012 to the port that you want to use. The matlabrc.m file is located in the <MATLAB>\toolbox\local\ directory.

If you want to temporarily change the port number, first stop the NI VeriStand Server by entering the command NIVeriStandAddPaths('stop'). Then enter the command NIVeriStandAddPaths('start', XXXX), where XXXX is the port number you want to use.

 

However, this does not seem to be the way it is implemented.  The NIVeriStandAddPaths.m file does not contain a way to do that.  Am I missing a patch?

0 Kudos
Message 4 of 9
(10,041 Views)

After some playing around, i found you can change the port NI VeriStand Server uses by doing the following in the MATLAB command window:

 

niveristandserver ('stop')

 

and then

 

niveristandserver ('start' portnumber)

 

This changes the server port number to the one you specify.  Be sure to change the Port number appropriately in the System Explorer-Models-ModelSpecification.

 

Sadly, this did not fix my problem. 

 

The error info I get from MATLAB says:

AppName: matlab.exe  AppVer:1.0.0.1  ModName: niveristandserver.mexw32  ModVer: 2.0.0.0  Offset: 000076f8

 

One of you NI guys be able to decode that for me?

0 Kudos
Message 5 of 9
(10,037 Views)

Who was the local rep that you were working with?  It might be a good idea for you to give us a call so that we can work with you directly on this.

 

Have you had a chance to try another model just to make sure there is nothing odd about the one you are using now?  If you post your model I could give it a try as well, but my guess is that there is something specific to your computer that is causing this issue.  I realize this is unlikely, but if you happened to have another machine available I would be curious to know if it behaved the same way.  Also, what OS are you using and do you have any firewalls enabled? Finally, a troubleshooting tool that may be useful here is Process Explorer for Sysinternals.  This utility should allow you to see which dlls are being accessed by which applications.  You could use it to make sure that the VeriStand Server is actually running under MATLAB. 

MATLAB® and Simulink® are registered trademarks of The MathWorks, Inc. Other product and company names listed are trademarks and trade names of their respective companies.

0 Kudos
Message 6 of 9
(10,027 Views)

Sure, I can call you guys.  What's the number and is there someone I should ask for?  I have tried a few different models will no luck.  Following your suggestion I downloaded Proc Explorer and the Veristand server (NIVeriStandServer.mexw32) is being loaded under MATLAB.  Using process monitor, I can see some calls are being made in to the VS Server DLL.  OS is Windows Xp pro.  I've turned off everything I can think of: Firewalls, virus protection, etc.  It would be very difficult to try it on another machine.  Attached are some files so you can try it yourself.  Thanks for the support.    As an aside, it appears the chat room won't upload .mdl extensions.  Rename simple.txt to simple.mdl and Jay_mdl_test.txt to .in4 extension. 

Download All
0 Kudos
Message 7 of 9
(9,907 Views)

I just ran your .mdl file in version 2008b and everything worked perfectly fine on my machine.  I always hate to suggest this because it never reveals the root cause of the issue, but at this point it might be in your best interest to try repairing and/or reinstalling VeriStand and MATLAB.  Also, if you would like to work with us directly on this you could create a service request by visiting www.ni.com/support

 


MATLAB® and Simulink® are registered trademarks of The MathWorks, Inc. Other product and company names listed are trademarks and trade names of their respective companies.

0 Kudos
Message 8 of 9
(9,883 Views)

Glad to hear it ran on your system.  I will try reloading MATLAB and VeriStand and post the results here. 

0 Kudos
Message 9 of 9
(9,866 Views)