Using MSVC to Run MATRIXx SystemBuild Models in LabVIEW
Overview
The Application Note Running MATRIXx SystemBuild Models in LabVIEW/LabVIEW Real-Time describes how a MATRIXx SystemBuild model can be run in LabVIEW. It uses LabWindows/CVI to compile the model into a DLL that can be called from LabVIEW. This is an alternate template that uses Microsoft Visual C++. This allows for linking non ANSI C code.
Differences Between CVI and MSVC Templates
The two methods are very similar, so first refer to the process that uses CVI (linked below). There are only minor difference. The file c_dllsched.tpl is identical. - Exported DLL functions: LabWindows/CVI exports the functions that are contained in the header file. For MSVC _declspec(dllexport) is used to export functions in a DLL.
- Byte Alignment: LabWindows/CVI uses #pragma pack(1) to align on 1 byte. In MSVC the preferred method is to set it in the project.
- Project File: LabWindows/CVI and MSVC have different project files. A .dsp project file is generated that is compatible with MSVC 6.0. If you are using a different version you may need to create a new project as described in the Creating a New DLL Project section.
Download and copy the attached templates to the same folder as the shipping templates for MATRIXx (default location is C:\Program Files\National Instruments\MATRIXx\mx_63.2\case\ACC\templates). The templates depend on the templates that ship with MATRIXx. If the templates are placed in a different folder, then the shipping templates also should be copied to that same folder. These templates are intended for use with MATRIXx 6.3. The file c_dllsched.tpl is identical to that provided in the Running MATRIXx SystemBuild Models in LabVIEW/LabVIEW Real-Time.
See Also:
Running MATRIXx SystemBuild Models in LabVIEW/LabVIEW Real-Time
Creating a New DLL Project
- Launch MSVC.
- Choose File>New and Create a Win32 - Dynamic Link Library.
- Choose to create a empty DLL project.
- Add the .c and .h files to the project by selecting Project>Add to Project>Files.
- Go to Project>Settings. On the C/C++ tab choose Code Generation. Set Struct Member Alignment to 1 byte for the project.
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
