Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated  Rate this Document

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++:
  1. Launch Visual C++
  2. Open a new workspace (File»New»Workspace)
  3. Add a Win32 console application project to the workspace (File»New»Project»Win32 Console Application)
  4. 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

  5. Add the include files:
    • <Motion Assistant>\Source\nimaCCodeGenTypes.h
    • <Motion Assistant>\Source\nimaCCodeGenWin32.h

  6. 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

  7. Goto Project»Settings
    1. Select the Link Tab.
    2. Select the Input Category.
    3. In the Object/Library Modules add FlexMS32.lib
    4. In the Additional library path field, type the path to find FlexMS32.lib
      • For Example:<National Instruments>\NI-Motion\FlexMotion\lib\Microsoft

    5. Select the C/C++ tab
    6. Select the Preprocessor Category
    7. Type the path to the Include directory in the Additional include directory field
      • For Example: <National Instruments>\NI-Motion\FlexMotion\Include

  8. Build the project
  9. Execute

To Build a Project in LabWindows/CVI:

  1. Start LabWindows/CVI
  2. Create a new project (File»New»Project)
  3. 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)

  4. Add the following include files:
    • <Motion Assistant>\Source\include\nimaCCodeGenTypes.h
    • <Motion Assistant>\Source\include\nimaCCodeGenWin32.h

  5. Add the lib file FlexMS32.lib
  6. Add the following include folder:
    • <National Instruments>\NI-Motion\FlexMotion\Include

  7. Add the library OLE32.LIB which can be found in:
    • <National Instruments>\CVI70\sdk\lib\msvc

  8. 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

    Your Feedback! poor Poor  |  Excellent excellent   Yes No
     Document Quality? 
     Answered Your Question? 
      1 2 3 4 5
    Please Contact NI for all product and support inquiries.submit