Rockwell-automation 2098-IPD-xxx Ultra5000 C Programming using the Mot Bedienungsanleitung Seite 24

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 114
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 23
Publication 2098-PM001E-EN-P — July 2002
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; /* Increment partcount by
1. */
}
Example 3 Explained
A function definition has this form:
return-type function-name(parameter declarations, if any)
{
declarations
statements
}
The function insert is called from only one place by main, in the line
partcount = insert(INSERTDIST, INSERTVEL, INSERTACCDEC);
The call passes three arguments to insert, which each time returns a
long integer partcount. The first line of insert itself,
long insert(long distance, long velocity, long accdec)
declares the parameter types and names, and the type of the result
that the function returns. The names used by insert for its parameters
are local to insert, and are not visible to any other functions (i.e.,
Other routines can use the same names without conflict.).
The value of partcount is transferred to main by the return statement.
Any expression may follow return:
return expression;
A function need not return a value; a return with no expression causes
control, but no value, to be returned to the caller. Also, the calling
function can ignore a value returned by a function.
Seitenansicht 23
1 2 ... 19 20 21 22 23 24 25 26 27 28 29 ... 113 114

Kommentare zu diesen Handbüchern

Keine Kommentare