1 basic task example – Rockwell Automation 57C409 2 Channel Analog Input Module User Manual

Page 23

Advertising
background image

4Ć7

4.4.1

BASIC Task Example

The following is an example of a BASIC task that handles interrupts

from channel 0 from the input module.
1000 !

1002 ! common data declarations

1003 !

1004 COMMON ANALOG INPUT 0%

\!Data from channel 0

1005 COMMON ISCR CHANNEL 0%

\!Interrupt status & control 0

1010 COMMON CCLK ENABLE 0@

\!Common clock enable 0

1015 COMMON CCLK ENABLE 1@

\!Common clock enable 1

1020 COMMON UPDATE TIME 0%

\!Update period for channel 0

1025 COMMON INPUT 0 FILTERS%

\!Input filter for channel 0

1100 !

1150 ! local data declarations

1175 !

1200 LOCAL

ANALOG VALUE%

\!Analog value

2000 !

2001 !set up the conversion parameters

2002 !

2011 INPUT 0 FILTER% = 2

\!79 rad/sec filter

2900 !

2950 ! The following statement connects the name CHANNEL 0 EVENT

3000 ! to the interrupt defined in ISCR CHANNEL 0%. The event name

3001 ! should be as meaningful as possible. The watchdog timeout has

3002 ! been set to 120 clock ticks (660 msec). 1 tick

3003 ! equals .0055 seconds. If the time between

3004 ! interrupts exceeds this value, a bus error will

3005 ! be indicated on the processor's LED and the system

3006 ! will be stopped. For more information refer to

3007 ! the Enhanced BASIC Instruction manual (JĆ3675).

3008 !

3010 EVENT NAME=CHANNEL 0 EVENT, &

INTERRUPT STATUS=ISCR CHANNEL 0%, TIMEOUT=120

4000 !

4001 UPDATE TIME 0% = 1000

\!Convert every .5 seconds

4002 ! The following statements enable common clock" on this module.

4003 ! If there is more than one interrupt task in a chassis, the

4004 ! task that enables common clock" should always be the lowest

4005 ! priority task.

4006 !

4010 CCLK ENABLE 0@ = TRUE

\!Turn on the clock

5000 !

5001 ! Place any additional initialization statements 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 task waiting to execute at the time of the

6005 ! interrupt, it will become active. If it is not the highest

6006 ! priority task, it will remain suspended until all higher

6007 ! priority tasks have executed, at which point it will become

6008 ! active.

6009 !

6010 WAIT ON CHANNEL 0 EVENT

7000 !

7001 !

7002 ! The next statement performs the interrupt service routine

7003 !

7010 ANALOG VALUE% = ANALOG INPUT 0%

8000 GOTO 6010

10000 END

Advertising