Allen-Bradley Ultra5000 Programming Manual

Allen-Bradley Ultra5000 Programming Manual

C programming using the motion library
Hide thumbs Also See for Ultra5000:
Table of Contents

Advertisement

Ultra5000
C Programming using the
Motion Library
Programming Manual

Advertisement

Table of Contents
loading

Summary of Contents for Allen-Bradley Ultra5000

  • Page 1 Ultra5000 ™ C Programming using the Motion Library Programming Manual...
  • Page 2 • avoid a hazard • recognize the consequences Identifies information that is critical for successful IMPORTANT application and understanding of the product. Allen-Bradley is a registered trademark of Rockwell Automation, Inc. Ultra3000, Ultra5000 and Ultraware are trademarks of Rockwell Automation, Inc.
  • Page 3: Table Of Contents

    Using Online Help ......P-3 Allen-Bradley Support ......P-3 Local Product Support .
  • Page 4 Table of Contents Statements and Blocks ......1-23 Example 8 - Grouping Statements....1-23 If-Else .
  • Page 5 Table of Contents Control Attributes......2-10 long ControlGetFault(void); ......2-10 long EncoderGetFaultState(long channel);...
  • Page 6 Table of Contents long CamCloseTable(void); ......2-23 long CamConstantVelocity(long master_position, long follower_position); ....... . 2-23 long CamCycloidal(long master_position, long follower_position);...
  • Page 7 Table of Contents long GearInProgress(void); ......2-37 long GearIsEnabled(void); ......2-37 Jog Attributes.
  • Page 8 Table of Contents Analog Output Attributes ..... . . 2-48 long AnalogOutputSetVoltage(long channel, float voltage); . . . 2-48 Digital Input Status ......2-48 long InputGetAll(void);...
  • Page 9: Preface

    • Who should use this manual • Contents of this Manual • Related documentation • Conventions Used in this Manual • Using Online Help • Allen-Bradley ® support Who Should Use this Use this manual if you are new to programming in the Ultraware...
  • Page 10: Contents Of This Manual

    Ultra Family Brochure 2098-BR001x-EN-P drive capabilities To ensure correct operation, Allen-Bradley publications referenced should be at or above the revision level listed. (e.g., 2098-UM001F-EN-P is revision F of the Ultraware User Manual.) Conventions Used in this The following conventions are used throughout this manual: Manual •...
  • Page 11: Using Online Help

    • Warranty support • Support service agreements Technical Product Assistance If you need to contact Allen-Bradley for technical assistance, please review the information in this manual or in the Online Help file first. Then call your local Allen-Bradley representative. For the quickest possible response, we recommend that you have the catalog numbers of your products available when you call.
  • Page 12 Preface Publication 2098-PM001E-EN-P — July 2002...
  • Page 13: Programming Motion Control In C

    Creating A Basic Motion Until now all motion occurred in what is called the direct mode; you told the Ultra5000 what to do by selecting direct commands from the Program Ultraware Commands menu. It is far more useful to have all the moves a machine axis will do, along with I/O statements, etc., in a...
  • Page 14: Creating And Running A Program

    Programming Motion Control in C The first short program you will write: • Moves the axis 1000 counts in the positive direction • Delays program execution for 1 second • Returns the axis 1000 counts in the negative direction While the code is compact, what is important at this point is the process.
  • Page 15 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...
  • Page 16: Example 1 Explained

    Programming Motion Control in C Example 1 Explained Any C program, whatever its size, consists of functions and variables. A function contains statements that specify the operations to be done, and variables that store the values used in those operations. Braces (opening {, and closing }) enclose the statements in a function.
  • Page 17: Variables, Loops, And Constants

    Programming Motion Control in C Variables, Loops, and Constants The next example is a motion program that makes a series of 10 index moves of 1000 counts each. This program introduces you to: • Comments • Declarations • Variables • Arithmetic expressions •...
  • Page 18: Example 2.1 Explained

    The type long means that the variables listed are long integers, by contrast the type float means floating point, i.e., numbers that may have a fractional part. On the Ultra5000, a long integer is a 32-bit quantity that contains a value in the range ±2,147,483,647; a floating...
  • Page 19 Programming Motion Control in C endpoint) the loop ends, and execution continues at the statement that follows the loop. Statements contained inside the braces of a while loop, and in many other cases yet to come, should always be indented so you can see at a glance which statements are inside the loop.
  • Page 20: Example 2.2 - Varying The Program Using Variables

    Programming Motion Control in C Example 2.2 - Varying the Program using Variables There are many different ways to write a program for a particular task. This program performs the same tasks as Example 2.1 - A Motion Program Using Variables, but it uses slightly different software code. #include <motion.h>...
  • Page 21 You may have noticed that there is a return statement at the end of main. Since main is a function like any other, it may return a value to its caller, which in effect is the Ultra5000 operating system. This return value is not currently used.
  • Page 22: Example 2.3 - Another Variance Of The Program Using Variables

    1-10 Programming Motion Control in C Example 2.3 - Another Variance of the Program using Variables A third way to achieve the same result is to write the program as follows: #include <motion.h> #define ACCEL 2000 /* counts/second**2 */ #define DECEL 2000 /* counts/second**2 */...
  • Page 23: User Defined Functions

    Programming Motion Control in C 1-11 User Defined Functions A function provides a convenient way to encapsulate a sequence of motion commands and computations. Example 3 - Nested Functions in a Motion Program This program shows the function insert and the main program to exercise it.
  • Page 24: Example 3 Explained

    1-12 Programming Motion Control in C MoveSetAcc(accdec); /* Initialize index move MoveSetVel(velocity); MoveSetDec(accdec); OutputSetState(INMOTION, ON); /* Set Output 1 */ MoveIncremental(distance); /* Start Move */ while (MoveInProgress()); /* Wait for move to complete */ OutputSetState(INMOTION, OFF); /* Clear Output 1 */ return ++partcount;...
  • Page 25: Program Stop

    Program Stop Ultraware uses the Program Stop command to request the programs executing on the Ultra5000 to stop. This command provides a controlled stop to program execution, unlike the Kill command. When the Program Stop command is executed, a SystemSignal_Stop flag is set.
  • Page 26: Example 4 - A Jog Program

    1-14 Programming Motion Control in C Example 4 - A Jog Program #include <motion.h> #define JOGREVERSE 7 /* Input 7 */ #define JOGFORWARD 8 /* Input 8 */ #define ACCDEC 10000 /* counts/second**2 */ #define JOGVEL 20000 /* counts/second */ #define STOPPED /* Jog modes */...
  • Page 27: Example 5 - A Gear Program

    Programming Motion Control in C 1-15 Example 5 - A Gear Program #include <motion.h> #define ADCCHANNEL /* Analog input chnl 1 */ /* This program uses analog input channel 1 to determine the gearing ratio. The purpose of comparing the old ratio to new is to avoid resetting the gear ratio when it has not changed.
  • Page 28: Homing With Latch Functions

    0; Non-Volatile Storage Global variables are handled through arrays created in Ultraware and stored in the Ultra5000 non-volatile memory. Refer to the Ultraware User Manual (2098-UM001F-EN-P) for information on creating non-volatile arrays. There are two types of arrays that can be created in Ultraware: those containing long integer values and those containing floating-point values.
  • Page 29: Example 7 - A Non-Volatile Array Program

    Programming Motion Control in C 1-17 controller’s non-volatile memory but only one of each type may be accessed at a time. One way to access non-volatile arrays is shown. Example 7 - A Non-Volatile Array Program #include <motion.h> /* This program assumes that two 10-element arrays have been created through Ultraware.
  • Page 30: Types, Operators, And Expressions

    Types, Operators, and The C language allows you a great deal of flexibility in deciding what type of data the Ultra5000 will use. Some of the data is preset or static, Expressions such as (#define ACCEL 1000), while other data changes or is assigned different values as your program runs (long partcount;...
  • Page 31: Declarations

    Programming Motion Control in C 1-19 Two limitations that apply to variable names are: • Underscores (“_”) count as a letter, and should be used to enhance readability. • Upper and lower case letters are unique, so code and Code are two distinct names.
  • Page 32 1-20 Programming Motion Control in C lists the precedence and describes the functions and any limitations placed on the arithmetic operations in C. Operator: Precedence: Function: Limitations: Multiplies the value on its right by the value on its left. Divides the value at its left Answer is truncated if by the value on its right.
  • Page 33: Relational And Logical Operators

    Programming Motion Control in C 1-21 Relational and Logical The relational operators (<, <=, >=, >) make comparisons that test expressions. They have lower precedence than arithmetic operators, Operators but higher precedence than the equality operators (==, !=). The logical operators (&&...
  • Page 34: Operator Precedence

    1-22 Programming Motion Control in C For example, the following code yields the absolute value of a number. if (y < 0) x = -y; else x = y; This statement can be written as x = (y < 0) ? –y : y; The meaning of either statement above is: If y is less than zero, then x = -y;...
  • Page 35: Control Flow

    Programming Motion Control in C 1-23 Control Flow In this section you will learn about the functions that control the flow of a C program. The functions include: • Statements and Blocks • If-Else • Else-If • Switch • While, For and Do-While Loops •...
  • Page 36: If-Else

    1-24 Programming Motion Control in C In grouping example A, the assignment statement is included in the while loop, because a while loop runs from the while to the next semicolon. In grouping example B, the braces group both the assignment and MoveAbsolute statements into a single block.
  • Page 37 Programming Motion Control in C 1-25 The last statement (else) performs the default or “none of the above” case, and may be omitted in obvious situations. The structure is shown below. if (expression1) /* If expression1 is 1, perform statement1 */ statement1;...
  • Page 38: Switch

    1-26 Programming Motion Control in C Switch The switch statement performs a multiple path decision. It tests whether an expression matches one of several constant integer values, and branches accordingly. If no expression value matches, control passes through each case until the default statement is encountered, or no action takes place when the default option is absent.
  • Page 39: Break And Continue

    Programming Motion Control in C 1-27 the update (expression3) is evaluated. The loop is repeated until test (expression2) is false or zero. for (expression1;expression2;expression3) statement; /* if expression2 is non-zero, loop until zero The initialize and update components (expression1 and expression3) may be omitted, but the semicolons must remain.
  • Page 40 1-28 Programming Motion Control in C Publication 2098-PM001E-EN-P — July 2002...
  • Page 41: Referencing The Motion Library

    Chapter Referencing the Motion Library This chapter provides information on the functions available in the Ultraware Motion Library. The functions are grouped into the following areas: • Control Setting Functions • Motion Functions • Digital and Analog I/O Functions • Latch Functions •...
  • Page 42: Control Setting Functions

    Referencing the Motion Library Control Setting Functions Control Setting functions directly control aspects of the controller. Use these functions: Axis Attributes Get and set axis • AxisDefinePos attributes. • AxisGetCommandCur • AxisGetCommandPos • AxisGetCommandVel • AxisGetFeedbackOffset • AxisGetFeedbackPos • AxisGetFeedbackVel •...
  • Page 43 Referencing the Motion Library Control Attributes Get control attributes. • ControlGetFault • EncoderGetFaultState • EncoderGetOutput • EncoderGetPos • RatchetGetVel Control Services Manage control services. • ControlClearFault • EncoderDisableFault • EncoderEnableFault • EncoderSetPolarity • RatchetSetMode • SequencerAddNode • SequencerRemoveNodes Program Services Manage program •...
  • Page 44: Axis Attributes

    Referencing the Motion Library Axis Attributes long AxisDefinePos(long position); Sets the axis command position to the specified position. Position is programmed in counts. Returns 0 if successful, or -1 on an error. float AxisGetCommandCur(void); Returns command current (filtered and clipped output of the velocity regulator) measurement in Amps.
  • Page 45: Float Axisgetfeedbackvel(Void)

    Referencing the Motion Library float AxisGetFeedbackVel(void); Returns the feedback velocity of the axis in counts/second. Note: Velocity error is calculated by subtracting this value from the command velocity. float AxisGetFGain(void); Returns the acceleration feedforward gain of the velocity loop. float AxisGetIGain(void); Returns the integral gain of the velocity loop in units of 1/second.
  • Page 46: Float Axisgetvelerror(Void)

    Referencing the Motion Library float AxisGetVelError(void); Returns the velocity error in counts/second. Note: Velocity error is calculated by subtracting the value of feedback velocity from the command velocity. long AxisSetFeedbackOffset(long offset); Sets the feedback offset of the axis. Offset is programmed in counts. Returns 0 if successful, or -1 on an error.
  • Page 47: Long Axissetuppercurlimit(Float Limit)

    Referencing the Motion Library long AxisSetUpperCurLimit(float limit); Sets the upper current limit in Amps. Returns 0 if successful, or -1 on an error. Publication 2098-PM001E-EN-P — July 2002...
  • Page 48: Axis Services

    Referencing the Motion Library Axis Services long AxisDisable(void); Disables the axis (amplifier). Returns 0 if successful, or -1 on an error. This function will cause the axis to coast to a stop IMPORTANT without controlled deceleration if the axis is disabled while motion is occurring.
  • Page 49: Axis Status

    Referencing the Motion Library Axis Status long AxisIsEnabled(void); Determines if Axis is enabled. Note: Prior to initiating motion ensure that the axis is ready using the AxisIsReady function. Returns non-zero if the axis is enabled. long AxisIsReady(void); Determines if axis is ready. Note: After the axis is enabled, the motor may not be ready immediately, particularly if it is set for self-sensing startup.
  • Page 50: Control Attributes

    2-10 Referencing the Motion Library Control Attributes long ControlGetFault(void); Returns controller fault. Valid fault returns are: • 0 = Not faulted • 4 = Motor overtemperature, thermostat • 5 = IPM fault (overtemperature, overcurrent, short) • 9 = Bus undervoltage •...
  • Page 51: Long Encodergetfaultstate(Long Channel)

    Referencing the Motion Library 2-11 long EncoderGetFaultState(long channel); Returns state of fault checking for an encoder. The channel selects the encoder channel. Valid channels are as follows: • 1 = Motor Encoder • 2 = Aux Encoder The returned state can be one of the following: •...
  • Page 52: Control Services

    2-12 Referencing the Motion Library Control Services long ControlClearFault(void); Clears a controller fault. Returns 0 if successful, or -1 on an error. long EncoderDisableFault(long channel); Disables fault checking for an encoder. The channel selects the encoder channel. Valid channels are as follows: •...
  • Page 53: Long Encodersetpolarity(Long Channel, Long Polarity)

    Referencing the Motion Library 2-13 long EncoderSetPolarity(long channel, long polarity); Sets the polarity of the specified encoder channel. Valid channel arguments are: • 1 = Motor Encoder • 2 = Auxiliary Encoder Valid polarity arguments are: • 0 = Positive •...
  • Page 54: Long Sequenceraddnode(Long Frame, Void* Fptr, Void* Dptr)

    2-14 Referencing the Motion Library long SequencerAddNode(long frame, void* fptr, void* dptr); Inserts a user function into a sequencer frame. The frame argument indicates which frame of the sequencer the function is to be inserted. Valid frames arguments are 1 - 4. The ftpr argument is a pointer to the user function to be inserted.
  • Page 55: Program Services

    Referencing the Motion Library 2-15 Program Services long InitMotionLibrary(void); Initializes the motion library functions so the program may access them. If this function is not called, all motion library function calls will fail. Returns 0 if successful, or -1 on an error. If Motion Library functions are used in a program, IMPORTANT this function should be called as the first line of the...
  • Page 56: Program Status

    2-16 Referencing the Motion Library Program Status long ProgramIsRunning(char* name); Determines if the specified program is running. Returns non-zero if the program is running. long StopRequested(void); Determines if a program stop has been requested. Returns non-zero if the program is requested to stop. This function must be called in your main program ATTENTION execution loop if the program is to react to a Stop...
  • Page 57: Long Serialputstring(Const Char *String)

    Referencing the Motion Library 2-17 long SerialPutString(const char *string); Puts a character string into the ASCII transmit buffer. Returns 0 if successful, or -1 on an error. Serial Status long SerialClearToSend(void); Returns non-zero if space is available in ASCII transmit buffer. long SerialDataReady(void);...
  • Page 58: Timer Status

    2-18 Referencing the Motion Library Timer Status long TimerDone(long channel); Returns non-zero if specified timer has completed. Valid channel arguments are 1 - 8. Publication 2098-PM001E-EN-P — July 2002...
  • Page 59: Motion Functions

    Referencing the Motion Library 2-19 Motion Functions Motion functions include all functions that cause or directly affect motion of the axis. The motion library provides functions for moving, jogging, electronic gearing, and electronic cams. The following table presents the functions names for each function in this category along with a brief description.
  • Page 60 2-20 Referencing the Motion Library Gear Attributes Get and set gear • GearGetVel attributes. • GearSetRatio • GearSlewSetAcc • GearSlewSetDec Gear Services Turns electronic gearing • GearDisable on of off. • GearEnable • GearSlewDisable • GearSlewEnable Gear Status Query gear status. •...
  • Page 61 Referencing the Motion Library 2-21 Move Attributes Get and set move • MoveSetAcc attributes. • MoveSetDec • MoveSetPos • MoveSetVel Move Services Move the axis to a • MoveAbort specified absolute position, or by a • MoveAbsolute specified incremental • MoveCloseBuffer distance.
  • Page 62: Cam Attributes

    2-22 Referencing the Motion Library Cam Attributes long CamGetCycleCount(void); Returns the cam cycle count. The cycle count is the number of complete cycles that the cam has gone through since it was enabled. Cam cycle count is in cycles. long CamGetCycleLimit(void); Returns the cam cycle limit.
  • Page 63: Long Camsetcyclelimit(Long Limit)

    Referencing the Motion Library 2-23 long CamSetCycleLimit(long limit); Sets the cam cycle limit. The cycle limit is the number of cycles that the cam will go through before automatically disabling. If the cycle limit is zero, the cam will run continuously. •...
  • Page 64: Long Camcycloidal(Long Master_Position, Long Follower_Position)

    2-24 Referencing the Motion Library long CamCycloidal(long master_position, long follower_position); Adds a cycloidal curve to the table. The profile of a normalized cycloidal curve is shown in Figure 2.1. • The master_position argument defines the master position at the end of the curve. •...
  • Page 65: Long Camcycloidalharmonic(Long Master_Position, Long Follower_Position)

    Referencing the Motion Library 2-25 long CamCycloidalHarmonic(long master_position, long follower_position); Adds a cycloidal harmonic curve to the table. The profile of a normalized cycloidal harmonic curve is shown in Figure 2.2. • The master_position argument defines the master position at the end of the curve.
  • Page 66: Long Camdisable(Void)

    2-26 Referencing the Motion Library long CamDisable(void); Disables electronic cam. Returns 0 if successful, or -1 on an error. long CamDwell(long master_position); Adds a dwell segment to the table. • The master_position argument defines the master position at the end of the segment. Returns 0 if successful, or -1 if there was an error.
  • Page 67: Long Camharmonic(Long Master_Position,Long Follower_Position)

    Referencing the Motion Library 2-27 long CamHarmonic(long master_position,long follower_position); Adds a harmonic curve to the table. The profile of a normalized harmonic curve is shown in Figure 2.3. • The master_position argument defines the master position at the end of the curve. •...
  • Page 68: Long Camharmoniccycloidal(Long Master_Position, Long Follower_Position)

    2-28 Referencing the Motion Library long CamHarmonicCycloidal(long master_position, long follower_position); Adds a harmonic cycloidal curve to the table. The profile of a normalized harmonic cycloidal curve is shown in Figure 2.4. • The master_position argument defines the master position at the end of the curve.
  • Page 69: Long Camload(Char* Name)

    Referencing the Motion Library 2-29 long CamLoad(char* name); Loads cam table number one. • The name argument specifies the name of the file. This is the base filename of the cam file, with the file path and extension added automatically. A cam table cannot be loaded if it is active or queued.
  • Page 70: Long Cammodifiedsinusoidal(Long Master_Position,Long Follower_Position)

    2-30 Referencing the Motion Library long CamModifiedSinusoidal(long master_position,long follower_position); Adds a modified sinusoidal curve to the table. The profile of a normalized modified sinusoidal curve is shown in Figure 2.5. • The master_position argument defines the master position at the end of the curve.
  • Page 71: Long Cammodifiedtrapezoidal(Long Master_Position,Long Follower_Position)

    Referencing the Motion Library 2-31 long CamModifiedTrapezoidal(long master_position,long follower_position); Adds a modified trapezoidal curve to the table. The profile of a normalized modified trapezoidal curve is shown in Figure 2.6. • The master_position argument defines the master position at the end of the curve.
  • Page 72: Long Camopentable(Long Table_Number,Long Size,Long Order)

    2-32 Referencing the Motion Library long CamOpenTable(long table_number,long size,long order); Opens the cam table. • The table_number argument specifies the table number. Valid tables are one, two, and three. • The size argument specifies the number of segments to be allocated.
  • Page 73: Long Camqueuereset(Void)

    Referencing the Motion Library 2-33 long CamQueueReset(void); Resets the queue. Returns 0 if successful, or -1 if there was an error. long CamQueueTable(long table_number,long cycle_limit); Queues a cam table. • The table_number argument specifies the table number. Valid tables are one, two, and three. •...
  • Page 74: Long Camsavetable(Long Table_Number,Char *Name)

    2-34 Referencing the Motion Library long CamSaveTable(long table_number,char *name); Saves a cam table. • The table_number argument specifies the table number. Valid tables are one, two, and three. • The name argument specifies the name of the file. This is the base filename of the cam file, with the file path and extension added automatically.
  • Page 75: Cam Status

    Referencing the Motion Library 2-35 Cam Status long CamIsEnabled(void); Determines if electronic cam is enabled. Returns non-zero if cam is enabled. long CamPhaseInProgress(void); Checks if phase adjustment is in progress. Returns non-zero if phase adjustment is in progress. long CamQueueFull(void); Checks if the queue is full.
  • Page 76: Gear Attributes

    2-36 Referencing the Motion Library Gear Attributes float GearGetVel(void); Returns the gear velocity in counts/second. long GearSetRatio(float ratio); Sets the default count-to-count electronic gear ratio. If gearing is enabled, the ratio is changed to the specified ratio subject to any Gear Slew settings.
  • Page 77: Long Gearslewdisable(Void)

    Referencing the Motion Library 2-37 long GearSlewDisable(void); Disables gearing slew. Returns 0 if successful, or -1 on an error. long GearSlewEnable(void); Enables gearing slew. Returns 0 if successful, or -1 on an error. Gear Status long GearAtSpeed(void); Determines if electronic gearing is at speed. Returns non-zero if gear enabled and slew is not active.
  • Page 78: Long Jogsetdec(Float Dec)

    2-38 Referencing the Motion Library long JogSetDec(float dec); Sets the default deceleration for the jog. Deceleration is programmed in counts/second². Returns 0 if successful, or -1 on an error. long JogSetVel(float vel); Sets the default velocity for the jog. Velocity is programmed in counts/ second.
  • Page 79: Long Jogstop(Void)

    Referencing the Motion Library 2-39 long JogStop(void); Stops the jog motion using the programmed deceleration value. Returns 0 if successful, or -1 on an error. Jog Status long JogAtSpeed(void); Determines if a jog is at the programmed speed. Returns non-zero if jog is at speed. long JogGetMode(void);...
  • Page 80: Long Joginprogress(Void)

    2-40 Referencing the Motion Library long JogInProgress(void); Determines if a jog is in progress. Returns non-zero if jog is in progress. Move Attributes long MoveSetAcc(float acc); Sets the programmed acceleration for a move. Acceleration is programmed in counts/second². Returns 0 if successful, or -1 on an error. long MoveSetDec(float dec);...
  • Page 81: Move Services

    Referencing the Motion Library 2-41 Move Services long MoveAbort(void); Halts motion immediately, ignoring deceleration and position values. Returns 0 if successful, or -1 on an error. This function stops motion immediately; without ATTENTION decelerating the motor in a controlled manner. If a controlled deceleration is desired, your program should use the MoveStop function to slow the motor using the programmed deceleration value.
  • Page 82: Long Movecorrectabs(Long Position)

    2-42 Referencing the Motion Library long MoveCorrectAbs(long position); Corrects a move to stop at a new target position specified in the argument. Uses the programmed move acceleration, deceleration, and velocity values. Position is programmed in counts. The reference position for the MoveCorrectAbs function is set using the MoveSetPos function.
  • Page 83: Long Movedv(Long Distance, Float Vel)

    Referencing the Motion Library 2-43 long MoveDV(long distance, float vel); The distance argument is the delta distance of the move. The vel argument specifies the move profile final velocity. This function fits a move profile to the specified DV parameters using linear acceleration and deceleration.
  • Page 84: Long Movedwell(Float Time)

    2-44 Referencing the Motion Library long MoveDwell(float time); The time argument specifies the time duration for which the axis will remain stationary. This function inserts into the move buffer a move profile dwell. Returns 0 if successful, or -1 on an error. long MoveGetFreeSegments(void);...
  • Page 85: Long Moveposition(Long Position)

    Referencing the Motion Library 2-45 long MovePosition(long position); Starts an absolute move to the specified position using the programmed move acceleration, deceleration, and velocity values. Position is programmed in counts. The reference position for the MovePosition function is set using the MoveSetPos function.
  • Page 86: Move Status

    2-46 Referencing the Motion Library Move Status long MoveAtSpeed(void); Determines if a move is currently at the programmed speed. Returns non-zero if move is at speed. long MoveBufferFull(void); Determines if the move buffer, opened with the MoveOpenBuffer function, is full. Returns non-zero if move is at speed.
  • Page 87: Digital And Analog I/O Functions

    Referencing the Motion Library 2-47 Digital and Analog I/O Digital and Analog I/O functions control discrete I/O. The following table presents the function names for each function in this category Functions along with a brief description. More detailed descriptions of the functions are contained on the pages following the table.
  • Page 88: Analog Output Attributes

    2-48 Referencing the Motion Library Analog Output Attributes long AnalogOutputSetVoltage(long channel, float voltage); Sets the voltage output value for the auxiliary analog channel specified by the channel argument. Valid channel arguments are: • 1 = Auxiliary analog output channel 1 •...
  • Page 89: Long Inputgetstate(Long Channel);

    Referencing the Motion Library 2-49 long InputGetState(long channel); Returns the state of the digital input specified by the channel argument. Valid channel arguments are 1 through 28 as follows. Channel Input Description 1 – 16 IN1 – IN16 Digital inputs 1-16 Auxiliary encoder index Auxiliary encoder channel B Auxiliary encoder channel A...
  • Page 90: Digital Output Services

    2-50 Referencing the Motion Library Digital Output Services long OutputSetAllOff(void); Turns all digital outputs OFF. Returns 0 if successful, or -1 on an error. long OutputSetAllOn(void); Turns all digital outputs ON. Returns 0 if successful, or -1 on an error. long OutputToggle(long channel);...
  • Page 91: Digital Output Status

    Referencing the Motion Library 2-51 Digital Output Status long OutputGetAll(void); Returns the state of all digital outputs. The return value is bitmapped as follows: Input Description 0 – 7 OUT1 – OUT8 Digital outputs 1-8 8 – 31 — Reserved long OutputGetState(long channel);...
  • Page 92: Latch Functions

    2-52 Referencing the Motion Library Latch Functions Latch functions control registration events. The table presents the function names for each function in this category along with a brief functional description. Detailed descriptions of the functions follow the table. Use these functions: Latch Attributes Get latch attributes.
  • Page 93: Long Latchgetcount(Long Channel)

    Referencing the Motion Library 2-53 long LatchGetCount(long channel); Returns the value of the latch counter. The channel argument selects the channel latch counter to read. Latch count is the number of latches that have occurred. Valid channel arguments are: • 1 = Primary motor latch •...
  • Page 94: Latch Services

    2-54 Referencing the Motion Library Latch Services long LatchOnIndex(long channel, long encoder, long rising); Arms a latch to trigger on an encoder index. The channel argument selects the latch channel. The encoder argument selects which encoder index triggers the latch. Valid channel arguments are: •...
  • Page 95: Long Latchoninput(Long Channel, Long Input, Long Rising)

    Referencing the Motion Library 2-55 long LatchOnInput(long channel, long input, long rising); Arms a latch to trigger on an digital input signal. Valid channel arguments are: • 1 = Primary motor latch • 2 = Secondary motor latch • 3 = Primary auxiliary latch •...
  • Page 96: Long Latchsetautomode(Long Channel, Long Mode)

    2-56 Referencing the Motion Library long LatchSetAutoMode(long channel, long mode); Sets the auto mode of a latch. Enabling auto mode allows the latch to automatically rearm after detecting a latch. The latch count is read with the LatchGetCount function. Valid channel arguments are: •...
  • Page 97: Non-Volatile Array Functions

    2-57 Non-Volatile Array Non-volatile array functions store numeric values for retrieval from non-volatile memory in the Ultra5000. The array index is zero-based Functions with a range of 0 through the size of the array minus one. Non-volatile arrays must be set up in Ultraware IMPORTANT before they may be accessed by a program.
  • Page 98: Long Longarraysetelement(Long Element, Long Data)

    2-58 Referencing the Motion Library long LongArraySetElement(long element, long data); Stores data into a previously selected zero-based, long integer array. The element argument indicates which cell of the array to access. The data argument is the new value to be stored in the specified element. Returns 0 if successful, or -1 on an error.
  • Page 99: Updates To The Motion Library For Ultraware Release 1.5

    Appendix This appendix summarizes the library functions added in various releases of the Ultraware software. Updates to the Motion New Library Functions CamCloseTable Library for Ultraware CamConstantVelocity Release 1.5 CamCycloidal CamCycloidalHarmonic CamDwell CamGetFreeSegments CamHarmonic CamHarmonicCycloidal CamLoadTable CamModifiedSinusoidal CamModifiedTrapezoidal CamOpenTable CamPhaseAbort CamPhaseAdvance CamPhaseInProgress CamPhaseRetard...
  • Page 100 Updates to the Motion LIbrary Updates to the Motion New Library Functions AxisDefinePos(position); Library for Ultraware GearSlewEnable(); Release 1.2 GearSlewDisable(); GearInProgress(); GearAtSpeed(); GearSlewSetAcc(accel); GearSlewSetDec(decel); CamLoad(name); CamEnable(); CamDisable(); CamIsEnabled(); RatchetGetVel(); AxisSoftLimitEnable(); AxisSoftLimitDisable(); AxisResetPosLimit(); AxisPosLimitIsTriggered(); AxisPosLimitGetStatus(); ProgramRun(name); ProgramStop(name); ProgramKill(name); ProgramIsRunning(name); TimerEnable(channel,preset); TimerDone(channel); TimerAccumulated(channel);...
  • Page 101 Updates to the Motion LIbrary Modified library Functions LatchGetOutput(channel); In previous Ultraware versions, this library function returned the motor encoder output position captured when the latch occurred. The axis feedback offset was not applied to the latched positions. In Ultraware 1.20 Motion Library, this function returns the Axis feedback position, with the feedback offset added, captured when the latch occurred.
  • Page 102 Updates to the Motion LIbrary Publication 2098-PM001E-EN-P — July 2002...
  • Page 103 Index example troubleshooting Allen-Bradley support using general information IMC e-mail addresses, see back cover IMC fax numbers, see back cover IMC telephone numbers, see back cover C programming 2-47 AnalogInputGetVoltage pre-requisites 2-48 AnalogOutputSetVoltage 2-23 CamCloseTable 1-19 arithmetic operators 2-23 CamConstantVelocity...
  • Page 104 Index 1-19 1-18 declarations expressions definition 1-21 1-21 1-20 - (arithmetic operator) 2-57 FloatArrayGetElement 1-20 -- (arithmetic operator) 2-58 FloatArraySelect 1-20 - (binary arithmetic operator) 2-57 FloatArraySetElement 1-21 ! (logical operator) 1-26 1-21 != (logical operator) functions 1-20 % (arithmetic operator) 2-47 AnalogInputGetVoltage 1-21...
  • Page 105 Index 2-22 2-38 CamGetCycleCount JogForward 2-22 2-39 CamGetCycleLimit JogGetMode 2-22 2-39 CamGetFreeSegments JogGetState 2-27 2-40 CamHarmonic JogInProgress 2-28 2-38 CamHarmonicCycloidal JogReverse 2-35 2-37 CamIsEnabled JogSetAcc 2-29 2-38 CamLoad JogSetDec 2-29 2-38 CamLoadTable JogSetVel 2-30 2-39 CamModifiedSinusoidal JogStop 2-31 2-53 CamModifiedTrapezoidal LatchGetCount 2-32 2-53...
  • Page 106 Index 2-16 2-38 ProgramIsRunning JogForward 2-15 2-39 ProgramKill JogGetMode 2-15 2-39 ProgramRun JogGetState 2-15 2-40 ProgramStop JogInProgress 2-11 2-38 RatchetGetVel JogReverse 2-13 2-37 RatchetSetMode JogSetAcc 2-14 2-38 SequencerAddNode JogSetDec 2-14 2-38 SequencerRemoveNodes JogSetVel 2-17 2-39 SerialClearToSend JogStop 2-16 SerialClose 2-17 SerialDataReady 2-16 SerialGetChar...
  • Page 107 Index 2-10 AxisGetPGain ControlGetFault 2-12 AxisGetPosError EncoderDisableFault 2-12 AxisGetUpperCurLimit EncoderEnableFault 2-11 AxisGetVelError EncoderGetFaultState 2-11 AxisIsEnabled EncoderGetOutput 2-11 AxisIsReady EncoderGetPos 2-13 AxisPosLimitGetStatus EncoderSetPolarity 2-57 AxisPosLimitIsTriggered FloatArrayGetElement 2-58 AxisResetPosLimit FloatArraySelect 2-57 AxisSetFeedbackOffset FloatArraySetElement 2-37 AxisSetFGain GearAtSpeed 2-36 AxisSetIGain GearDisable 2-36 AxisSetKff GearEnable 2-36 AxisSetKp GearGetVel...
  • Page 108 Index 2-46 2-41 MoveAtSpeed MoveAbort 2-41 2-41 MoveCloseBuffer MoveAbsolute 2-41 2-46 MoveCorrect MoveAtSpeed 2-42 2-41 MoveCorrectAbs MoveCloseBuffer 2-42 2-41 MoveCorrectInc MoveCorrect 2-42 2-42 MoveDistance MoveCorrectAbs 2-43 2-42 MoveDV MoveCorrectInc 2-43 2-42 MoveDVS MoveDistance 2-44 2-43 MoveDwell MoveDV 2-44 2-43 MoveGetFreeSegments MoveDVS 2-44 2-44...
  • Page 109 Index 1-27 1-20 break - (arithmetic operator) 1-20 build (command) -- (arithmetic operator) 1-21 1-20 conditional expressions - (binary arithmetic operator) 1-21 constants ! (logical operator) 1-27 1-21 continue != (logical operator) 1-23 1-20 control flow % (arithmetic operator) 1-18 1-21 data sizes &&...
  • Page 110 Index 2-16 2-17 SerialPutChar TimerEnable 2-17 SerialPutString tip of the day 2-17 SerialReceiverFull troubleshooting 2-17 SerialTransmitterEmpty build (command) 2-15 1-18 Sleep types source file creation 1-23 statements stop (command) 1-18 variable names example variables 2-16 StopRequested 1-26 switch where to find help 1-26 while 2-17...
  • Page 111 Notes...
  • Page 114 Publication 2098-PM001E-EN-P — July 2002 0013-1085-005-01 Supercedes Publication 2098-PM001D-EN-P – January 2002 © 2002 Rockwell Automation, Inc. All rights reserved. Printed in the U.S.A.

Table of Contents