Rockwell Automation 2098-IPD-xxx Ultra5000 C Programming using the Motion Library User Manual

Page 15

Advertising
background image

Publication 2098-PM001E-EN-P — July 2002

Programming Motion Control in C

1-3

3. Open the source file and enter the following text with the text

editor:

#include <motion.h>

int main (void)

{

InitMotionLibrary();

AxisEnable();

MoveSetAcc(1000);

MoveSetVel(1000);

MoveSetDec(1000);

MoveIncremental(1000);

while (MoveInProgress()) {/* loop */}

Sleep(1000);

MoveIncremental(-1000);

while (MoveInProgress()) {/* loop */}

AxisDisable();

return 0;

}

4. After the text is entered, right-click on the Project in which you

inserted the source file and select Build from the Project menu. If
all of the text was entered correctly, the compilation will proceed
and you will see the following statements sequentially display in
the Ultraware Output window:

Compiling yourfile.c...

Linking...

Build completed successfully!

Notice the new file created under the project. The file is named the
same as the project but has an .exe extension. This is the program’s
executable file that now may be loaded and run on the Ultra5000.

Note: If the build fails, refer to the Executable Program File section in

the Ultraware User Manual (2098-UM001F-EN-P) for instructions
on how to troubleshoot errors encountered while creating a
program.

5. Drag the .exe file from the Project to the Program branch of the

On-line Ultra5000.

6. After the on-line controller’s Program branch expands, right-click

on your program, and select Run from the menu to execute the
program.

Advertising