LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

What should be in the "test.c" file that needs to be included in a cvi file to use the cvi code created by motion assistant?

I was looking at the help page here that gives a list of things to be included in a cvi project to use the generated code by motion assistant  http://digital.ni.com/public.nsf/allkb/DF5262A85EC2819386256F160067F059.  I have everything it mentioned except for the text.c which the page says this about:
 
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

My question is that it doesn't really mention what needs to be in it other than the call to MotionAssistantScript, but this code snippet implies that I need to write it specific to my application.  But as it doesn't really specify what should be in it to run properly or how to write it I am confused.  Some clarification and maybe an example of how these could be written properly or two would be appreciated.

Thanks

Ben

0 Kudos
Message 1 of 4
(2,994 Views)

Hello Ben,

The template you are looking at should work with your setup, with only a few minor modifications.  If you take a look at the NI-Motion C Reference Help for the function flex_stop_motion, you will see that it accepts 4 parameters: boardID, axisOrVectorSpace, stopType, axisOrVSMap.

status = flex_stop_motion(u8 boardID, u8 axisOrVectorSpace, u16 stopType, u16 axisOrVSMap);

Depending on the configuration you have setup, you will need to change these parameters accordingly, as described in the Motion Reference Help.  For example, to use this example to stop axis 1 on a board with boardID 1, you would use the following parameters:

flex_stop_motion(1, NIMC_AXIS1, NIMC_KILL_STOP, 0)

Regards,

Jasper S

 

0 Kudos
Message 2 of 4
(2,972 Views)
Then I guess here is another question.  Although taht page I linked earlier said I  needed to create test.c I linked all the files other then that yesterday and ran the program and made a call to the Motion function in the main part of the GeneratedCode.c from Motion assist and the thing ran beautifully.  Granted of course I had to modify the code from motion assist and my code to have a few extra includes but other then that it worked fine.  So is this test.c file neccesary and what is it exactly neccesary for.  I would like it so that someone could create a motion setup in motion assist and run it in my code at some point without having to recompile the whole thing everytime so do you have any suggestions how I might be able to do that?
0 Kudos
Message 3 of 4
(2,961 Views)

Hello,

The test.c file is simply a means to run the Motion Assistant code.  You can call the MotionAssistantScript function from anywhere, but it is recommended that it be ran with error handling, along with a stop command following the script.  Because this script is C code, it must be compiled whenever changes are made.

Regards,

Jasper S

0 Kudos
Message 4 of 4
(2,943 Views)