Program stop, Program stop -13 – Rockwell Automation 2098-IPD-xxx Ultra5000 C Programming using the Motion Library User Manual

Page 25

Advertising
background image

Publication 2098-PM001E-EN-P — July 2002

Programming Motion Control in C

1-13

The declaration

long insert(long distance, long velocity, long accdec);

just before main says that insert is a function that expects three long
arguments and returns a long value. This declaration, which is called a
function prototype, has to agree with the definition and uses of insert.
It is an error if the definition of the function or any uses of it do not
agree with its prototype.

Parameter names need not agree. In fact, parameter names are
optional in a function prototype, so the prototype could be written

long insert(long, long, long);

Function prototypes allow the compiler to detect errors in the number
of arguments or their types.

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. The state of this flag is checked through the use of the
StopRequested function.

Examples 4 and 5 are programs that show how the StopRequested
function should be used. The programs also provide examples of the
Jog and Gear functions. Notice the use of the ! operator to modify
StopRequested() in the while loop of both programs. This symbol (!)
is termed the not operator. The loop continues execution while the
StopRequested event has not occurred.

Note: Program comments explain this example and all subsequent

examples in this chapter.

ATTENTION

!

The StopRequested function must be called in your
main program execution loop if the program is to
react to a Stop command. If this function is not
called, the Stop command will be ignored. It is your
responsibility to ensure that all programs check for
and react to this event.

Advertising