Rockwell Automation 2098-IPD-xxx Ultra5000 C Programming using the Motion Library User Manual
Page 3
![background image](/manuals/580132/3/background.png)
i
Publication 2098-PM001E-EN-P — July 2002
Table of Contents
Where to Find Help . . . . . . . . . . . . . . . . . . . . . . . . . . . P-1
Contents of this Manual. . . . . . . . . . . . . . . . . . . . . . . . . . . P-2
Related Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . P-2
Conventions Used in this Manual. . . . . . . . . . . . . . . . . . . . P-2
Using Online Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . P-3
Allen-Bradley Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . P-3
Programming Motion Control
in C
Creating and Running a Program . . . . . . . . . . . . . . . . . 1-2
Example 1 - A Basic Motion Program . . . . . . . . . . . . . . . . . . . . 1-2
Example 1 Explained. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Variables, Loops, and Constants . . . . . . . . . . . . . . . . . . 1-5
Example 2.1 - A Motion Program Using Variables . . . . . . . . . . . 1-5
Example 2.1 Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6
Example 2.2 - Varying the Program using Variables . . . . . . . . . 1-8
Example 2.2 Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Example 2.3 - Another Variance of the Program using Variables . .
1-10
Example 2.3 Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
User Defined Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
Example 3 - Nested Functions in a Motion Program . . . 1-11
Example 3 Explained . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
Program Stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Example 4 - A Jog Program . . . . . . . . . . . . . . . . . . . . . 1-14
Example 5 - A Gear Program . . . . . . . . . . . . . . . . . . . . 1-15
Homing with Latch Functions . . . . . . . . . . . . . . . . . . . . . . 1-16
Example 6 - A Homing Program . . . . . . . . . . . . . . . . . . 1-16
Non-Volatile Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Example 7 - A Non-Volatile Array Program . . . . . . . . . . 1-17
Types, Operators, and Expressions . . . . . . . . . . . . . . . . . . 1-18
Variable Names and Data Types/Sizes . . . . . . . . . . . . . 1-18
Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
Relational and Logical Operators . . . . . . . . . . . . . . . . . . . . 1-21
Conditional Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 1-21
Operator Precedence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-22
Control Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-23