Rockwell Automation 57C421B Pulsetach Input Module/DCS 5000/AutoMax User Manual
Page 39

4Ć17
Positioning Mode Example (Continued)
4005
!ăalways be the lowest priority task.
4006
!
4010
FOR I% = 0 TO 3 \ READ LIMIT_SWITCH%(I%) \ NEXT I%
4015
RESET@ = TRUE \ RESET@ = FALSE
\!ăZero counter
4020
I% = 0
\!ăInitialize limit switch index
4025
LOW_COMP% = LIMIT_SWITCH%(I%)
\!Set comparator to 1st value
4030
CNTR_EQ_RST@ = FALSE
\!ăInitialize 'Comp=' status
4035
EQU_INT@ = ON
\! Enable comp = interrupt
4040
CLR_MOD1@ = OFF
\! Reset on equal
4045
CLR_MOD2@= ON
\! Reset on equal
4050
CCLK_EN@ = ON
\! Enable constant clock
5988
!
5989
!ăPlace additional initialization software here.
5990
!
5991
!
5992
!ăThe next statement synchronizes the task to the external
5993
!ăevent via the interrupt. Task execution will be suspended
5994
!ăuntil the interrupt occurs. When the interrupt occurs, if
5995
!ăthis task is the highest priority task waiting to
5996
!ăexecute, it will become active. If it is not the highest
5997
!ăpriority task, it will remain suspended until all higher
5998
!ăpriority tasks have executed at which point it will then
5999
!ăbecome active.
6000
!
6010
WAIT ON COUNTER_EVENT
6997
!
6998
!ăThe following statements perform the interrupt service
6999
!ăroutine.
7000
!
7010
INDEX% = I% + 1
\!ăSave this index value
7015
I% = I% + 1 \ IF I% > 3 THEN I% = 0
\!ăStep to next point
7020
LOW_COMP% = LIMIT_SWITCH%( I% )
\!ăSet up next value
7025
CNTR_EQ_RST@ = FALSE
\!ăReset interrupt
7030
ON INDEX% GOSUB 8000, 8200, 8400, 8600 \ !Execute routine
7035
GOTO 6010
7997
!
7998
!ăInterrupt service routine for limit switch value (0).
7999
!
8000
INT_SERVICE0% = INT_SERVICE0% + 1
8190
RETURN
8197
!
8198
!ăInterrupt service routine for limit switch value (1).
8199
!
8200
INT_SERVICE1% = INT_SERVICE1% + 1
8390
RETURN
8397
!
8398
!ăInterrupt service routine for limit switch value (2).
8399
!
8400
INT_SERVICE2% = INT_SERVICE2% + 1
8590
RETURN
8597
!
8598
!ăInterrupt service routine for limit switch value (3).
8599
!
8600
INT_SERVICE3% = INT_SERVICE3% + 1
8790
RETURN
9000
DATA 1000
\!ăLimit switch position 0
9005
DATA 500
\!ăLimit switch position 1
9010
DATA 2500
\!ăLimit switch position 2
9020
DATA 3000
\!ăLimit switch position 3
32767
END