09-06-2010 09:33 AM
I want to create a .dll from a simulink model .mdl file. I have created a simple "Sample.mdl" file which adds two inputs and gives the result.
Before generating .dll, i tried to run .mdl file using veristand.There i got the error attached below.
Method 1: I tried to create a .dll out of it by going to Simulation -> Configuration Parameters -> Real-Time workshop. There i tried to change the system target file to NIVeriStand.tlc, but i am not able to find that in System target file browser dialog box. Can anyone tell me the reason behind that.
Then i tried Method 2.
Method 2: I created C code from that .mdl using grt.tlc in Simulation -> Configuration Parameters -> Real-Time workshop. I clicked "build" button, then it created C equvalent code for that. Using Microsoft visual C++, i tried to generate .dll file but i got the following errors.
Can anybody please help me on this. My goal is to run this model with veristand eithor in.dll or .mdl format
Solved! Go to Solution.
09-07-2010 12:23 PM - edited 09-07-2010 12:28 PM
The first error is caused by Veristand not finding the NIVeriStandServer running within The MathWorks, Inc. MATLAB software. This error, coupled with the fact that it appears NIVeriStand.tlc is missing, suggests that the NI Veristand Model Framework was not installed properly. Repairing the NI Veristand Installation and ensuring that the model framework is selected as an installed component may remedy this.
If it is installed properly, can you provide the following troubleshooting information:
What version of NI Veristand are you using?
What version of MATLAB are you using?
What operating system are you using?
When you start Matlab do you see notification of the NIVeriStandServer starting within the command window? If so, what port number does it display in the start up information? Does this port number match the configuration for the model in System Explorer?
Is "NIVeriStandServer" a recognized command within MATLAB?
You may also take a look at this help document that explains how to get the NIVeriStandServer running if MATLAB application files are installed as read only :
MATLAB® is a registered trademark of The MathWorks, Inc.
09-08-2010 08:21 AM
Thanks for your reply.
I am able to solve some of the issues i mentioned previously.
1 . Now i am getting notification of the NIVeriStandServer starting within the matlab command window.
2. I am also able to see NIVeriStand.tlc in Real Time Workshop window and i am also able to see NI Veristand Blocks ( NI VeriStand In1,NI Veristand Out1 and NIVeriStandSignalPobe) in Simulink Library browser window.
Now i am facing issue while creating dll. I am getting below error while creating .dll. This is my Issue 1.
It will be very helpful, if any of you can share a simple .mdl file compatible with NiVeriStand, sothat i can try creating .dll with that.
Since i am not able to build .dll, i tried with .mdl file in VeriStand. I have attached my model also below. i am not sure whether it is correct or not. I have created a system definition file and a screen for that. But I am not able to see any change in outport indicator. This is my other issue.
Can any one please let me know where i am doing wrong.it would be very helpful if u can share a simple .mdl file compatible with veristand.
09-08-2010 11:34 AM
The error you are receiving when building the model DLL is most likely from not having the mex utility configured properly within The MathWorks, Inc. MATLAB software. Try this command:
This will walk you through configuring the compiler MATLAB will use to generate the DLL.
I looked at your VeriStand files and noticed that you don't have a control in your workspace for providing an input to your model. You need to provide that input to see a change in the output. There is a sinewave example included with VeriStand that may be helpful in demonstrating basic model interactions. The example can be found at this location:
MATLAB® is a registered trademark of The MathWorks, Inc. Other product and company names listed are trademarks and trade names of their respective companies.
09-08-2010 10:29 PM
I tried "mex -setup" command in the MATLAB command window. I have attached the sequence of steps happened in command window after giving that command. Please check that whether i have missed anything.
After giving that command, i again tried to build the dll, but again same error attached in the previous post (DLL_error.jpg). While building dll, I noticed the following in the command window :
### NI VeriStand 2010 Generating Ports Readme file
Could Not Find C:\Documents and Settings\NGFCS-USER\My Documents\MATLAB\sample_2_niVeriStand_rtw\*.obj
### Processing Template Makefile: C:\VeriStand\2010\ModelInterface\tmw\R2007b\NIVeri
### Real-Time Workshop build procedure for model: 'Sample_2' aborted due to an error.
Please let me know why it is not able to create .obj for that....Is it required to have Visual C/C++ in the machine to create .obj. Since in DLL_error.jpg, it is mentioned about some environmental variables related to Visual C/C++.
Regarding veristand files i have shared, i have created a user channel in the system definition files, that channel i am mapping to the inport of the model. Initial value of user channel i have given as -1. Please let me know whether this is the right way to do.
09-09-2010 06:37 AM
Finally I am able to create a .dll for my .mdl file.
I have installed VC++, then it worked.
But in veristand workspace screen, inport values (In1) values are not updating , if i change the value of user channel (ch1). I have mapped ch1 and In1 in my system definition file. But value of in1 is not changing with ch1.
Can any one please let me know what could be the reason for that.
I have attached the screen shots of mapping in system definition file and my work space screen. In the veristand screen, if i keep the Model Control block from "workspace controls", it is showing Invalid Mapping and NaN. Can any body let me know why it is showing lke that.
09-09-2010 02:54 PM
In the system definition file you attached, there user channel has a default setting of 0. If you create a numeric control for that user channel you can manipulate it's value and see the outport value change respectively. This is a perfectly acceptable way to manipulate the model inport, although you could also create a numeric control that maps directly to the model inport.
09-13-2010 08:15 AM
Thanks for your reply. i will check my .mdl file once again to find out whether I am doing any thing wrong in that.
I need a clarification related to veristand:
Please let me know whether the usage of NI Veristand Blocks (NI VeriStand In1,NI Veristand Out1 and NIVeriStandSignalPobe) is mandatory in .mdl file or we can use any model (.mdl) without these blocks.
09-13-2010 10:51 AM
The NIVeriStandSignal Probe is required for Veristand to communicate with the model. The NI Veristand inports and outports are required for any model inputs or outputs you want to access from VeriStand. You do not have to have NI Veristand inports or outports in your model but you you do have to place the signal probe block within the model.
09-15-2010 08:02 AM
Thanks for your explanation.
I have created a simple .mdl file to calculate the absolute value with one veristand inport and one outport. In that, I have added NiVeriStandSignalProbe block as a dummy block means it is not doing any functionality but to make my model compatiblw with Veristand, i have included that.
I am able to add this .mdl file to my system definition file, there i am not getting any errors. But when i am trying to run that from my Project Explorer i am getting the error and Matlab is getting closed.
I have attached .mdl file, system definition file and the error snapshots with this mail. Please let me know how i can come out of these errors.