What Do I Need to Include in My Project to Run the Generated C Code from Motion Assistant 1.2
Primary Software: Motion Assistant
Primary Software Version: 1.2
Primary Software Fixed Version: N/A
Secondary Software: N/A
Problem: A new and exciting feature of Motion Assistant 1.2 is that it will create C code as well as LabVIEW code. There are some steps to take to get this C code that is created as well as the necessary support files into a project so that the code can be compiled and run.
Solution: Follow the steps below to create a working project in Visual C++ or in LabWindows CVI.
Start by creating the C code by clicking on
Tools»Generate code»CVI Code in Motion Assistant 1.2. This generates two files: GeneratedCode.c and GeneratedCode.h
To Build a Project in Visual C++:- Launch Visual C++
- Open a new workspace (File»New»Workspace)
- Add a Win32 console application project to the workspace (File»New»Project»Win32 Console Application)
- Add the following files to the project:
- The generated files namely GeneratedCode.c and GeneratedCode.h
- <Motion Assistant>\Source\nimaCCodeGenTypes.c
- <Motion Assistant>\Source\nimaCCodeGenWin32.c
- Add the include files:
- <Motion Assistant>\Source\nimaCCodeGenTypes.h
- <Motion Assistant>\Source\nimaCCodeGenWin32.h
- Create a 'C' file that has a main function. Inside the main function call MotionAssistantScript function
- For example: Consider this snippet:
int main()
{
int err;
u16 axisMap = 0;
err = MotionAssistantScript();
printf("Error Value = %d\n", err);
axisMap = 255;
flex_stop_motion(5, 0, NIMC_KILL_STOP, axisMap);
return 0;
}
- Call this file "test.c". Include this file along with the above files
- Goto Project»Settings
- Select the Link Tab.
- Select the Input Category.
- In the Object/Library Modules add FlexMS32.lib
- In the Additional library path field, type the path to find FlexMS32.lib
- For Example:<National Instruments>\NI-Motion\FlexMotion\lib\Microsoft
- Select the C/C++ tab
- Select the Preprocessor Category
- Type the path to the Include directory in the Additional include directory field
- For Example: <National Instruments>\NI-Motion\FlexMotion\Include
- Build the project
- Execute
To Build a Project in LabWindows/CVI:- Start LabWindows/CVI
- Create a new project (File»New»Project)
- Add the following files to the project:
- GeneratedCode.c and GeneratedCode.h
- <Motion Assistant>\Source\nimaCCodeGenTypes.c
- <Motion Assistant>\Source\nimaCCodeGenWin32.c
- test.c (as mentioned above)
- Add the following include files:
- <Motion Assistant>\Source\include\nimaCCodeGenTypes.h
- <Motion Assistant>\Source\include\nimaCCodeGenWin32.h
- Add the lib file FlexMS32.lib
- Add the following include folder:
- <National Instruments>\NI-Motion\FlexMotion\Include
- Add the library OLE32.LIB which can be found in:
- <National Instruments>\CVI70\sdk\lib\msvc
- Build the project and execute
Related Links: Motion Assistant Version 1.2 for Windows 2000/NT/XP
Attachments:
Report Date: 09/21/2004
Last Updated: 03/09/2005
Document ID: 3DKCSKFL