Ultra5000™ C Programming using the Motion LibraryProgramming Manual
Publication 2098-PM001E-EN-P — July 2002P-2 PrefaceContents of this ManualThis manual contains the following sections:Related DocumentationThe followi
Publication 2098-PM001E-EN-P — July 2002A-2 Updates to the Motion LIbraryUpdates to the Motion Library for Ultraware Release 1.2 New Library Functions
Publication 2098-PM001E-EN-P — July 2002Updates to the Motion LIbrary A-3Modified library FunctionsLatchGetOutput(channel);In previous Ultraware versi
Publication 2098-PM001E-EN-P — July 2002A-4 Updates to the Motion LIbrary
Publication 2098-PM001E-EN-P — July 2002IndexAAllen-Bradley supportgeneral informationP-3IMC e-mail addresses, see back coverIMC fax numbers, see back
Publication 2098-PM001E-EN-P — July 2002 I-2 Indexdeclarations 1-19definition1-21, 1-21- (arithmetic operator)1-20-- (arithmetic operator) 1-2
Publication 2098-PM001E-EN-P — July 2002 Index I-3CamGetCycleCount 2-22CamGetCycleLimit 2-22CamGetFreeSegments 2-22CamHarmonic 2-27CamHarmonicCy
Publication 2098-PM001E-EN-P — July 2002 I-4 IndexProgramIsRunning 2-16ProgramKill 2-15ProgramRun 2-15ProgramStop 2-15RatchetGetVel 2-11Ratche
Publication 2098-PM001E-EN-P — July 2002 Index I-5AxisGetPGain 2-5AxisGetPosError 2-5AxisGetUpperCurLimit 2-5AxisGetVelError 2-6AxisIsEnabled 2-
Publication 2098-PM001E-EN-P — July 2002 I-6 IndexMoveAtSpeed 2-46MoveCloseBuffer 2-41MoveCorrect 2-41MoveCorrectAbs 2-42MoveCorrectInc 2-42Mo
Publication 2098-PM001E-EN-P — July 2002 Index I-7break 1-27build (command) 1-2conditional expressions 1-21constants 1-5continue 1-27control flo
Publication 2098-PM001E-EN-P — July 2002Preface P-3Using Online HelpThe following types of online help are available:Allen-Bradley SupportAllen-Bradle
Publication 2098-PM001E-EN-P — July 2002 I-8 IndexSerialPutChar 2-16SerialPutString 2-17SerialReceiverFull 2-17SerialTransmitterEmpty 2-17Slee
1Notes
Publication 2098-PM001E-EN-P — July 2002 0013-1085-005-01Supercedes Publication 2098-PM001D-EN-P – January 2002 © 2002 Rockwell Automation, Inc. All
Publication 2098-PM001E-EN-P — July 2002P-4 Preface
1 Publication 2098-PM001E-EN-P — July 2002Chapter 1Programming Motion Control in C IntroductionThe chapter introduces you to the C language and progra
Publication 2098-PM001E-EN-P — July 20021-2 Programming Motion Control in CThe first short program you will write: • Moves the axis 1000 counts in the
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-33. Open the source file and enter the following text with the text editor:#
Publication 2098-PM001E-EN-P — July 20021-4 Programming Motion Control in CExample 1 ExplainedAny C program, whatever its size, consists of functions
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-5Variables, Loops, and Constants The next example is a motion program that m
Publication 2098-PM001E-EN-P — July 20021-6 Programming Motion Control in CExample 2.1 ExplainedThe program still consists of a single function main.
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-7endpoint) the loop ends, and execution continues at the statement that foll
Important User InformationBecause of the variety of uses for the products described in this publication, those responsible for the application and us
Publication 2098-PM001E-EN-P — July 20021-8 Programming Motion Control in CExample 2.2 - Varying the Program using VariablesThere are many different w
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-9is executed, and the condition is re-evaluated. The loop terminates when th
Publication 2098-PM001E-EN-P — July 20021-10 Programming Motion Control in CExample 2.3 - Another Variance of the Program using VariablesA third way t
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-11User Defined FunctionsA function provides a convenient way to encapsulate
Publication 2098-PM001E-EN-P — July 20021-12 Programming Motion Control in C{MoveSetAcc(accdec); /* Initialize index move*/MoveSetVel(velocity);MoveSe
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-13The declarationlong insert(long distance, long velocity, long accdec);just
Publication 2098-PM001E-EN-P — July 20021-14 Programming Motion Control in CExample 4 - A Jog Program#include <motion.h>#define JOGREVERSE 7 /*
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-15Example 5 - A Gear Program#include <motion.h>#define ADCCHANNEL 1 /*
Publication 2098-PM001E-EN-P — July 20021-16 Programming Motion Control in CHoming with Latch FunctionsLatch functions are used to capture axis positi
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-17controller’s non-volatile memory but only one of each type may be accessed
i Publication 2098-PM001E-EN-P — July 2002Table of ContentsPrefaceIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Publication 2098-PM001E-EN-P — July 20021-18 Programming Motion Control in CTypes, Operators, and ExpressionsThe C language allows you a great deal of
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-19Two limitations that apply to variable names are: • Underscores (“_”) coun
Publication 2098-PM001E-EN-P — July 20021-20 Programming Motion Control in Clists the precedence and describes the functions and any limitations place
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-21Relational and Logical OperatorsThe relational operators (<, <=, >
Publication 2098-PM001E-EN-P — July 20021-22 Programming Motion Control in CFor example, the following code yields the absolute value of a number. if
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-23Control FlowIn this section you will learn about the functions that contro
Publication 2098-PM001E-EN-P — July 20021-24 Programming Motion Control in CIn grouping example A, the assignment statement is included in the while l
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-25The last statement (else) performs the default or “none of the above” case
Publication 2098-PM001E-EN-P — July 20021-26 Programming Motion Control in CSwitchThe switch statement performs a multiple path decision. It tests whe
Publication 2098-PM001E-EN-P — July 2002Programming Motion Control in C 1-27the update (expression3) is evaluated. The loop is repeated until test (ex
Publication 2098-PM001E-EN-P — July 2002 ii Table of ContentsStatements and Blocks . . . . . . . . . . . . . . . . . . . . . . . . . 1-23Example
Publication 2098-PM001E-EN-P — July 20021-28 Programming Motion Control in C
1 Publication 2098-PM001E-EN-P — July 2002Chapter 2Referencing the Motion LibraryThis chapter provides information on the functions available in the U
Publication 2098-PM001E-EN-P — July 20022-2 Referencing the Motion LibraryControl Setting FunctionsControl Setting functions directly control aspects
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-3Control Attributes• ControlGetFault• EncoderGetFaultState• EncoderGetOutput•
Publication 2098-PM001E-EN-P — July 20022-4 Referencing the Motion LibraryAxis Attributeslong AxisDefinePos(long position);Sets the axis command posit
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-5float AxisGetFeedbackVel(void);Returns the feedback velocity of the axis in
Publication 2098-PM001E-EN-P — July 20022-6 Referencing the Motion Libraryfloat AxisGetVelError(void);Returns the velocity error in counts/second. Not
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-7long AxisSetUpperCurLimit(float limit);Sets the upper current limit in Amps.
Publication 2098-PM001E-EN-P — July 20022-8 Referencing the Motion LibraryAxis Serviceslong AxisDisable(void);Disables the axis (amplifier). Returns 0
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-9Axis Statuslong AxisIsEnabled(void);Determines if Axis is enabled. Note: Pri
Publication 2098-PM001E-EN-P — July 2002Table of Contents iiiControl Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10lo
Publication 2098-PM001E-EN-P — July 20022-10 Referencing the Motion LibraryControl Attributeslong ControlGetFault(void);Returns controller fault. Vali
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-11long EncoderGetFaultState(long channel);Returns state of fault checking for
Publication 2098-PM001E-EN-P — July 20022-12 Referencing the Motion LibraryControl Serviceslong ControlClearFault(void);Clears a controller fault. Ret
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-13long EncoderSetPolarity(long channel, long polarity);Sets the polarity of t
Publication 2098-PM001E-EN-P — July 20022-14 Referencing the Motion Librarylong SequencerAddNode(long frame, void* fptr, void* dptr);Inserts a user fu
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-15Program Serviceslong InitMotionLibrary(void);Initializes the motion library
Publication 2098-PM001E-EN-P — July 20022-16 Referencing the Motion LibraryProgram Statuslong ProgramIsRunning(char* name);Determines if the specified
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-17long SerialPutString(const char *string);Puts a character string into the A
Publication 2098-PM001E-EN-P — July 20022-18 Referencing the Motion LibraryTimer Statuslong TimerDone(long channel);Returns non-zero if specified time
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-19Motion FunctionsMotion functions include all functions that cause or direct
Publication 2098-PM001E-EN-P — July 2002 iv Table of Contentslong CamCloseTable(void); . . . . . . . . . . . . . . . . . . . . . . . . . . 2-23l
Publication 2098-PM001E-EN-P — July 20022-20 Referencing the Motion LibraryGear Attributes• GearGetVel• GearSetRatio• GearSlewSetAcc• GearSlewSetDecGe
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-21Move Attributes• MoveSetAcc• MoveSetDec• MoveSetPos• MoveSetVelGet and set
Publication 2098-PM001E-EN-P — July 20022-22 Referencing the Motion LibraryCam Attributeslong CamGetCycleCount(void);Returns the cam cycle count.The c
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-23long CamSetCycleLimit(long limit);Sets the cam cycle limit. The cycle limit
Publication 2098-PM001E-EN-P — July 20022-24 Referencing the Motion Librarylong CamCycloidal(long master_position, long follower_position);Adds a cycl
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-25long CamCycloidalHarmonic(long master_position, long follower_position);Add
Publication 2098-PM001E-EN-P — July 20022-26 Referencing the Motion Librarylong CamDisable(void);Disables electronic cam. Returns 0 if successful, or
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-27long CamHarmonic(long master_position,long follower_position);Adds a harmon
Publication 2098-PM001E-EN-P — July 20022-28 Referencing the Motion Librarylong CamHarmonicCycloidal(long master_position, long follower_position);Add
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-29long CamLoad(char* name);Loads cam table number one. • The name argument sp
Publication 2098-PM001E-EN-P — July 2002Table of Contents vlong GearInProgress(void); . . . . . . . . . . . . . . . . . . . . . . . . . . 2-37
Publication 2098-PM001E-EN-P — July 20022-30 Referencing the Motion Librarylong CamModifiedSinusoidal(long master_position,long follower_position);Add
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-31long CamModifiedTrapezoidal(long master_position,long follower_position);Ad
Publication 2098-PM001E-EN-P — July 20022-32 Referencing the Motion Librarylong CamOpenTable(long table_number,long size,long order);Opens the cam tab
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-33long CamQueueReset(void);Resets the queue.Returns 0 if successful, or -1 if
Publication 2098-PM001E-EN-P — July 20022-34 Referencing the Motion Librarylong CamSaveTable(long table_number,char *name);Saves a cam table.• The tab
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-35Cam Statuslong CamIsEnabled(void);Determines if electronic cam is enabled.
Publication 2098-PM001E-EN-P — July 20022-36 Referencing the Motion LibraryGear Attributesfloat GearGetVel(void);Returns the gear velocity in counts/s
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-37long GearSlewDisable(void);Disables gearing slew. Returns 0 if successful,
Publication 2098-PM001E-EN-P — July 20022-38 Referencing the Motion Librarylong JogSetDec(float dec);Sets the default deceleration for the jog. Decele
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-39long JogStop(void);Stops the jog motion using the programmed deceleration v
Publication 2098-PM001E-EN-P — July 2002 vi Table of ContentsAnalog Output Attributes . . . . . . . . . . . . . . . . . . . . . . . 2-48long Ana
Publication 2098-PM001E-EN-P — July 20022-40 Referencing the Motion Librarylong JogInProgress(void);Determines if a jog is in progress.Returns non-zer
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-41Move Serviceslong MoveAbort(void);Halts motion immediately, ignoring decele
Publication 2098-PM001E-EN-P — July 20022-42 Referencing the Motion Librarylong MoveCorrectAbs(long position);Corrects a move to stop at a new target
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-43long MoveDV(long distance, float vel);The distance argument is the delta di
Publication 2098-PM001E-EN-P — July 20022-44 Referencing the Motion Librarylong MoveDwell(float time);The time argument specifies the time duration fo
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-45long MovePosition(long position);Starts an absolute move to the specified p
Publication 2098-PM001E-EN-P — July 20022-46 Referencing the Motion LibraryMove Statuslong MoveAtSpeed(void);Determines if a move is currently at the
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-47Digital and Analog I/O FunctionsDigital and Analog I/O functions control di
Publication 2098-PM001E-EN-P — July 20022-48 Referencing the Motion LibraryAnalog Output Attributeslong AnalogOutputSetVoltage(long channel, float vol
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-49long InputGetState(long channel);Returns the state of the digital input spe
1 Publication 2098-PM001E-EN-P — July 2002PrefaceIntroductionRead this preface to familiarize yourself with this manual. This preface covers the follo
Publication 2098-PM001E-EN-P — July 20022-50 Referencing the Motion LibraryDigital Output Serviceslong OutputSetAllOff(void);Turns all digital outputs
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-51Digital Output Statuslong OutputGetAll(void);Returns the state of all digit
Publication 2098-PM001E-EN-P — July 20022-52 Referencing the Motion LibraryLatch FunctionsLatch functions control registration events. The table prese
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-53long LatchGetCount(long channel);Returns the value of the latch counter. Th
Publication 2098-PM001E-EN-P — July 20022-54 Referencing the Motion LibraryLatch Serviceslong LatchOnIndex(long channel, long encoder, long rising);Ar
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-55long LatchOnInput(long channel, long input, long rising);Arms a latch to tr
Publication 2098-PM001E-EN-P — July 20022-56 Referencing the Motion Librarylong LatchSetAutoMode(long channel, long mode);Sets the auto mode of a latc
Publication 2098-PM001E-EN-P — July 2002Referencing the Motion Library 2-57Non-Volatile Array FunctionsNon-volatile array functions store numeric valu
Publication 2098-PM001E-EN-P — July 20022-58 Referencing the Motion Librarylong LongArraySetElement(long element, long data);Stores data into a previo
1 Publication 2098-PM001E-EN-P — July 2002Appendix AThis appendix summarizes the library functions added in various releases of the Ultraware software
Comentarios a estos manuales