4 applying the module, 1 speed mode example – Rockwell Automation 57C421B Pulsetach Input Module/DCS 5000/AutoMax User Manual

Page 37

Advertising
background image

4Ć15

4.4

Applying the Module

In order for hardware to be referenced by application software, it is

first necessary to assign symbolic names to the hardware. This is

accomplished in the configuration, as described in the section 4.3.
Each task that wishes to reference the symbolic names assigned to

the Pulsetach Input module may do so by declaring those names

COMMON. Once this has been done, any reference to those

symbolic names within the task will reference the bit or register

defined in the configurations.
The frequency with which tasks read input variables and write output

variables depends on the programming language being used.

Ladder Logic and Control Block tasks read all their inputs once at

the beginning of each scan, regardless of how often the inputs are

referenced in the task and write all output variables at the end of the

scan. BASIC statements (even within Control Block tasks) read an

input each time it is referenced and write an output each time it is

referenced.

4.4.1

Speed Mode Example

The following is an example of a Control Block task that handles

interrupts from the module. All variables declared as COMMON are

assumed to be previously been defined during configuration.
In the example below, the module is continuously accumulating

pulses from a pulsetach. The module is set up to capture the value

of the counter at a periodic rate and then generate an interrupt. This

task could be used to read in counts and then accumulate them in

software. It could also be used to generate a velocity signal (dx/dt).

1

2

!ăSPEED MODE EXAMPLE

3

!ăTASKNAME : PG_SPEED

4

!ăPRIORITY : 5

5

1000

COMMON TIMER%

\!Counter read time

1005

COMMON ISCR%

\!Interrupt and status register

1010

COMMON COUNT%

\!Counter data

1015

COMMON MULT@

\!Pulse multiplier

1020

COMMON CCLK_EN@

\!CCLK enable

1025

COMMON INT_R@

\! Timer interrupt enable

1200

LOCAL COUNTER_VALUE%

\!Counter value from buffer

2100

MULT@ = ON

\!Pulse multiplier times 4

2200

TIMER% = 99

\!Read every 50 milliseconds

2201

!

2202

! Set all other timers in the rack here.

2203

! (To be done in only 1 task in a rack.)

2204

!

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 set to 12 Processor clock ticks (12*5.5 secs). If the time

3005

!ăbetween interrupts exceeds this value, a severe error

3006

!ăwill be declared and the system will be stopped. For

3007

3008

3009

3010

EVENT NAME=COUNTER_EVENT, INTERRUPT_STATUS=ISCR%,

TIMEOUT=12

4000

4001

!ăThe following statement enables the constant clock" from

4002

!ăthis module. If there is more than one interrupt task in a

4003

!ăchassis, the task that enables the constant clock" should

4004

!ăalways be the lowest priority task.

4005

4100

DIS_CRL@=FALSE

\!Counter will be reset on interrupt.

Advertising