4 using interrupts in application tasks – Rockwell Automation 57C409 2 Channel Analog Input Module User Manual

Page 22

Advertising
background image

4Ć6

4.3.2

Control Block Task Example

This example will read an analog input from channel 1 every 55

milliseconds and store the inverted value in the symbol READING%.

The analog value will be digitized every 500 microseconds.
1003 ! common data declarations

1004 !

1005 COMMON ANALOG INPUT 1%

\!Data from channel 1

1010 COMMON CCLK ENABLE 0@

\!Common clock enable Ć 0

1020 COMMON CCLK ENABLE 1@

\!Common clock enable Ć 1

1030 COMMON UPDATE TIME 1%

\!Update period for channel 1

1040 COMMON INPUT 1 FILTER%

\!Input filter for channel 1

1400 !

1450 ! local data declarations

1475 !

1500 LOCAL READING%

\!Current negative value of input

1600 !

1900 ! task initialization

1950 !

2000 INPUT 1 FILTER% = 0

\!300 rad/sec crossover frequency

2010 UPDATE TIME 1% = 1

\!500 microsecond conversion

2020 CCLK ENABLE 0@ = TRUE

\!Turn on the clock

2030 CCLK ENABLE 1@ = TRUE

\!Must turn on both outputs

4000 !

4001 ! Place any additional initialization statements here

4002 !

4900 ! The rest of the task is run every 55 milliseconds

4950 !

5000 CALL SCAN LOOP( TICKS=10)

5010 CALL INVERTER( INPUT= ANALOG INPUT 1%, &

OUTPUT=READING%)

10000 END

The symbolic names defined as COMMON" reference the inputs

defined in the configuration. The symbolic name READING%" is

local to the BASIC task and does not have I/O associated with it.

4.4

Using Interrupts in Application Tasks

Interrupts are used to synchronize software tasks with the analog to

digital conversion. This input module supports separate interrupts for

each A/D channel. The update period may be specified from 500

microseconds up to a maximum of 32.7675 seconds in increments of

500 microseconds.
In order to use interrupts on the input module, it is necessary to

assign symbolic names to the interrupt control registers. In AutoMax

Version 2.1 and earlier, this is accomplished with IODEF statements in

the configuration task. See Appendix E for an example. In AutoMax

Version 3.0 and later, you assign symbolic names using the

Programming Executive.
Only one task may act as a receiver for a particular hardware

interrupt. That task should declare the symbolic names assigned to

the interrupt control registers on the input module as COMMON.

Advertising