Example 4 - a jog program, Example 4 - a jog program -14 – Rockwell Automation 2098-IPD-xxx Ultra5000 C Programming using the Motion Library User Manual

Page 26

Advertising
background image

Publication 2098-PM001E-EN-P — July 2002

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

0

/* Jog modes */

#define

FORWARD

1

#define

REVERSE

2

/* This program uses inputs 7 and 8 to Jog the axis in the

reverse and forward direction, respectively. It will

continue to run until a Stop or Kill command is issued from

Ultraware. */

int main (void)

{

long Jogging;

InitMotionLibrary();

AxisEnable();

JogSetAcc(ACCDEC);

JogSetVel(JOGVEL);

JogSetDec(ACCDEC);

while (!StopRequested())

{

Jogging = JogGetMode();

if (!JogInProgress()) {

if (InputGetState(JOGREVERSE) == ON)

JogReverse();

else if (InputGetState(JOGFORWARD) == ON)

JogForward();

}

else if (((InputGetState(JOGREVERSE) == OFF) &&

(Jogging == REVERSE)) ||

((InputGetState(JOGFORWARD) == OFF) &&

(Jogging == FORWARD)))

JogStop();

}

AxisDisable();

return 0;

}

Advertising