
4Ć16
Speed Mode Example (Continued)
4105 INT_R@ = TRUE \! Enable timer interrupt
4110 CCLK_EN@ = TRUE \! Enable CCLK (1 CCLK driver per rack)
5000 !
5001 !ăPlace additional initialization software here.
5002 !ă
6000 !ă
6001 !ăThe next statment synchronizes the task to the external
6002 !ăevent via the interrupt. Task execution will be suspended
6003 !ăuntil the interrupt occurs. When the interrupt occurs, if
6004 !ăthis task is the highest priority task waiting to execute,
6005 !ăit will become active. If it is not the highest priority
6006 !ătask, it will remain suspended until all higher priority
6007 !ătasks have finished executing at which point it will then
6008 !ăbecome active.
6010 CALL SCAN_LOOP( TICKS=9, EVENT=COUNTER_EVENT )
7000 !ă
7001 !
7002 !
7003 !ăThis example assumes that 32767 or fewer counts will be
7004 !ăreceived in the 50 msec. scan because statement 10000 only
7005 !ăreferences the least significant register (1) on the
7006 !ăregister.
10000 CALL PULSE_MULT( INPUT= COUNT%, MULTIPLIER= 16385, ăăăăăăăăăăă&
OUTPUT= COUNTER_VALUE% )
32767 END
4.4.2 Positioning Mode Example
The following is an example of a BASIC task that handles interrupts
from the module. All variables declared as COMMON are assumed
to have previously been defined during configuration.
In the example below, the module generates an interrupt every time
it accumulates the number of pulses indicated by the compare
register. Additional tasks or additional code in this task must be
written to take specific action.
1!ă
2 !ăPOSITIONING MODE EXAMPLE
3 !ăTASK NAME: PG_COMP
4 !ăPRIORITY: 10
5!
1000 COMMON COUNT% \!ăCounter data
1005 COMMON LOW_COMP% \!ăComparator data
1010 COMMON ISCR% \!ăInterrupt status and control
1015 COMMON RESET@ \!ăCounter reset
1020 COMMON CNTR_EQ_RST@ \!ăComparator equal interrupt reset
1025 COMMON EQU_INT@ \! Comparator equal int. enable
1030 COMMON CLR_MOD1@ \! Counter clear condition
1035 COMMON CLR_MOD2@ \! Counter clear condition
1040 COMMON CCLK_EN@ \!
1200 LOCAL LIMIT_SWITCH%(3) \!ăTable of limit switch positions
1205 LOCAL INDEX% \!ăIndex of limit switch interrupt
1210 LOCAL I% \!ăIndex of next limit switch interrupt
1215 LOCAL INT_SERVICE0% \!ăCounter for interrupt service 0
1220 LOCAL INT_SERVICE1% \!ăCounter for interrupt service 1
1225 LOCAL INT_SERVICE2% \!ăCounter for interrupt service 2
1230 LOCAL INT_SERVICE3% \!ăCounter for interrupt service 3
3000 !
3001 !ăThe following statement connects the name COUNTER_EVENT
3002 !ăto the interrupt defined in ISCR%. The event name should
3003 !ăbe as descriptive as possible. The watchdog timeout has
3004 !ăbeen disabled because the event is not periodic.
3005 !ă
3006 !ă
3007 !ă
3010 EVENT NAME=COUNTER_EVENT, INTERRUPT_STATUS=ISCR%, &
TIMEOUT=DISABLED
4000 !
4001 !ăThe following statements initialize the counter and set
4002 !ăup the interrupt control. Constant clock" is enabled on
4003 !ăthis module. If there is more than one interrupt task in
4004 !ăa chassis, the task that enables constant clock" should
Komentarze do niniejszej Instrukcji