4 sample application task with interrupt – Rockwell Automation 57C422B 2 Axis Servo Module User Manual

Page 76

Advertising
background image

4-48

2-Axis Servo Module M/N 57C422B

4.49.4 Sample Application Task with Interrupt

The following sample application task illustrates the use of
interrupts on the 2-Axis module. This is not a complete
program, only a sample illustration using an interrupt. Note
that this sample assumes that the raw feedback from the
pulse generator is 1000 counts per revolution.

2000

LOCAL FDBK_SCALING

2010

LOCAL COMMAND%

2020

LOCAL DISTANCE

2030

LOCAL SPD

2040

LOCAL ACCEL

3000

INT_SRC_X! = 0

\! Initialize interrupt source

3010

INT_ENA_X! = 0

\! and enable registers and the

3020

REG_64% = 0

\! interrupt reset register;

3021

! INT_SRC_X! and INT_ENA_X! are

3022

! double precision variables

3023

!

3025

EVENT NAME=HW_EVENT, INTERRUPT_STATUS= ISCR%, &
TIMEOUT= DISABLED

3030

! line 3025 connects the variable name ISCR% to the

3035

! interrupt status and control register

3040

ENCODER_SETUP%=1414H

\! X-Axis gearing and feedback

3042

! encoders are in rotary

3045

! w/ *4 quadrature

3050

DRIVE SETUP%=0H

3060

SWITCHES%=011CH

\! enables drive fault input,

3065

! overtravel L/S, feedback

3067

! encoder marker pulse; home

3068

! direction is in the decreasing

3069

! position

3070

PGAIN%=17595

3080

IGAIN%=768

3090

VGAIN%=78

3100

FGAIN%=8320

3110

DBCOMP%=28

3120

MAX_FOLL_ERR%=2000

\! error is = to 0.5 axis revolutions

3130

MAX_VEL_ERR%=4000

\! 1 revolution of the axis

3140

IN_TOLERANCE%=10

3150

GEAR_RATIO!=0

3160

MAX_VOLTS%=1984

\! maximum volts = 10

3170

P_CONST%=-1

3180

N_CONST%=-1

3190

FDBK_UNWIND!=1600000

\! 400 axis revolutions

3200

GEAR_UNWINDI=4000

\! 4000 counts = 1 rev.

3201

! from regs. 36,37

3210

COMMAND%=0200H \ GOSUB 15010 \! change default setups

3211

MODES% = 0

3215

DELAY 10 TICKS

3217

MODES% = 21H

\! enable incremental index move

3218

! and position loop

3230

FDBK_SCALING=4000

\DISTANCE=20 \ SPD =40.0 \ ACCEL = 50.0

4000

! Index move

4010

CMD_POS! = FDBK_SCALING*DISTANCE

4020

CMD_VEL! = SPD*FDBK_SCALING*65.536

4030

CMD_ACC! = (ACCEL/4)*FDBK_SCALING*.065536

4040

CMD_DEC! = CMD_ACC!

4050

COMMAND% = 1

\GOSUB 15010

4055

!

4060

! Subroutine to wait for axis done

4070

INT_ENA-X! = 00010000H

4080

WAIT ON HW_EVENT

4090

IF X_AXIS_DONE@ THEN INT_SRC_X! = 0 \ INT_ENA_X! = 0

4110

REG_64% = 0

4120

IF (INT_ENA_XI <> 0) THEN GOTO 4080

4130

GOTO 4010

4140

!

15000 ! Subroutine to wait for command ack
15010 INT_ENA_X! = INT_ENA_XI OR 80000000H

Advertising