beautypg.com

Pulsecountreset example 1 – Campbell Scientific CR9000X Measurement and Control System User Manual

Page 262

background image

Section 7. Measurement Instructions

7-38

See Section 3.4 Pulse Count Measurements for more info on PulseCount.

If the running averaging is in use, the over-range or erroneous high pulse count
value will be included in the average for the duration of the averaging period
(e.g., with a 1000 millisecond running average, the over-range will be the
value from the PulseCount(...) instruction until 1 second has passed).

When using multiple scans within the main program area, resetting the
counters and averages with the PulseCountReset instruction prior to restarting
the Scan avoids this (see PulseCountReset Example 1 below).

For cases involving Scans that have calls to subroutines, the

PulseCountReset should be placed in a conditional prior to the PulseCount
instruction, and the Subroutine call should be placed after the PulseCount
instruction. If possible, calls to DataTables that store the results from the
PulseCount instruction should be placed prior to the Subroutine call (see
PulseCountReset Example 2 below).

The first Scan after the PulseCountReset instruction is
encountered, the PulseCount destination variable’s value remains
unchanged from its previous value. If this variable’s value is
used for logic control, it may need to be changed through
program control to 0 or NAN (example programs set it to 0.

This instruction cannot be used in a SubScan or Slow Sequence
Scan.

PulseCountReset Example 1

Public

PulseHz, Flag(8)

'Declare Public Variables


DataTable

(Table1,Flag(3) = False,-1)

'Define Data Tables

DataInterval

(0,0,0,10)

Sample

(1,PulseHz,IEEE4)

EndTable

'Main Program

BeginProg
Do

Scan

(1,Sec,0,0)

‘Insert Measurement Instructions Here

If NOT Flag(1) Then

ExitScan

EndIf

Flag(3) = True

Disable output with first scan

NextScan

PulseHz = 0

Set PulseCount variable value to 0

PULSECOUNTRESET

‘Reset Pulse Counters prior to entering scan

Scan

(1,Sec,100,0)

PulseCount (PulseHz,1,6,1,0,2000,1,0)

CallTable Table1

If Flag(1) Then ExitScan

Flag(3) = False

NextScan

Loop
EndProg

NOTE