2 control block task example – Rockwell Automation 57C409 2 Channel Analog Input Module User Manual
Page 24
![background image](/manuals/580481/24/background.png)
4Ć8
4.4.2
Control Block Task Example
The following is an example of a control block task that handles
interrupts from channel 1 of the input module.
1000 !
1001 ! common data declarations
1003 !
1004 COMMON ANALOG INPUT 1%
\!Data from channel 1
1005 COMMON ISCR CHANNEL 1%
\!Interrupt status & control 1
1010 COMMON CCLK ENABLE 0@
\!Common clock enable 0
1015 COMMON CCLK ENABLE 1@
\!Common clock enable 1
1020 COMMON UPDATE TIME 1%
\!Update period for channel 1
1025 COMMON INPUT 1 FILTER%
\!Input filter for channel 1
1200 !
1300 ! local data declarations
1400 !
1401 LOCAL
LOOP GAIN%
\!Gain of amplifier
1402 LOCAL
OFFSET%
\!Amplifier offset
1403 LOCAL
NORM ANALOG IN% \!Analog value
1500 !
2000 !
2001 ! set up the conversion parameters
2002 !
2010 UPDATE TIME 1% = 100
\!Convert every 50 milliĆseconds
2011 INPUT 1 FILTER% = 2
\!79 rad/sec filter
3000 !
3001 ! The following statement connects the name CHANNEL 1 EVENT
3002 ! to the interrupt defined in ISCR CHANNEL 1%. The event name
3003 ! should be as meaningful as possible. The watchdog timeout has
3004 ! been set to 12 clock ticks (66 msec). If the time between
3005 ! interrupts exceeds this value, a bus error will
3006 ! be indicated on the processor's LED and the system
3007 ! will be stopped. For more information refer to the
3008 ! Enhanced BASIC Language Instruction Manual (JĆ3675).
3009 !
3010 EVENT NAME=CHANNEL 1 EVENT, &
INTERRUPT STATUS=ISCR CHANNEL 1%, TIMEOUT=12
4000 !
4001 ! The following statements enable common clock" on this module
4002 ! If there is more than one interrupt task in a chassis, the
4003 ! task that enables common clock" should always be the lowest
4004 ! priority task.
4005 !
4010 CCLK ENABLE 0@ = TRUE
\!Turn on the clock
4020 CCLK ENABLE 1@ = TRUE
\!Must turn on both outputs
5000 !
5001 ! Place additional initialization software here
5002 !
6000 !
6001 ! The next statement synchronizes the task with the external
6002 ! event via the interrupt. Task execution will be suspended
6003 ! until the interrupt occurs. If this task is the highest
6004 ! priority waiting to execute at the time of the interrupt, it
6005 ! will become active. If it is not the highest priority task, it
6006 ! will remain suspended until all higher priority tasks have
6007 ! executed, at which point it will become active.
6008 !
6010 CALL SCAN LOOP( TICKS=9, EVENT=CHANNEL 1 EVENT)
7000 !
7001 !
7002 ! The next statements perform the interrupt service routine
7010 CALL AMPLIFIER( INPUT1=ANALOG INPUT 1%, &
GAIN1=LOOP GAIN%, INPUT2= OFFSET%, LOOP GAIN%, &
OUTPUT=NORM ANALOG IN%)
10000 END