PulseCount/PulseCountReset (Pulse Count)
The PulseCount instruction is used to
Syntax
PulseCount ( Dest, Reps, PChan, PConfig, POption, Mult, Offset )
PulseCountReset( ) optional

The following code provides an example of using the PulseCount and PulseCountReset instructions in a program. The program measures a wind sensor and stores the result in miles per hour.
'Declare Variables and Units
Public Batt_Volt
Public WS_mph
Units Batt_Volt=Volts
Units WS_mph=miles/hour
'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,1,Min,0)
Sample(1,WS_mph,FP2)
EndTable
'Main Program
BeginProg
'zero all pulse counters before starting program
PulseCountReset
Scan(5,Sec,1,0)
'Default Datalogger Battery Voltage measurement Batt_Volt:
Battery(Batt_Volt)
'014A Wind Speed Sensor measurement WS_mph:
PulseCount(WS_mph,1,U11,1,1,1.789,1.0)
If WS_mph<1.01 Then WS_mph=0
'Call Data Tables and Store Data
CallTable(Table1)
NextScan
EndProg
Remarks
NOTE: A PulseCount measurement and a SDI12Recorder measurement cannot be made on the same
With the PulseCount instruction, a control port or universal terminal pair can be configured as high frequency input (up to 1 MHz), low level AC input, or switch closure (maximum frequency 150 Hz). See the datalogger user manual for more information.
The PulseCount instruction must be executed once before the pulse port is ready for input. This may be of particular concern for programs with long scan intervals. For example, the PulseCount instruction will not yield a valid output until the turn of the second hour if the PulseCount instruction is used within a program with a scan interval of 1 hour.
For cases involving Scans that have subroutine calls that include a Scan/NextScan sequence, the PulseCountReset must be placed in a conditional statement prior to the PulseCount instruction, and the Subroutine call must 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.
NOTE: This instruction should NOT be placed inside a conditional statement, subroutine, subscan, or SlowSequence scan. To ensure all pulses are detected, it must be executed each time the main program is executed.
Parameters
Dest (Destination)
The Variable in which to store the results of the instruction. Right-click the parameter to display a list of defined variables.
If this instruction has a Repetitions parameter and it is greater than 1, the results are stored in an array with the variable name. The array must be dimensioned large enough to hold all of the values returned from all of the Reps.
Type: Variable or Array
Reps (Repetitions)
The number of repetitions for the measurement or instruction.
Type: Constant integer (or expression that evaluates as a constant).
Measurements are made on consecutive channels. If the Reps parameter is greater than 1, the Dest parameter must be a variable array.
PChan (Pulse Channel)
The number of the pulse channel for the measurement. When Reps are used, subsequent measurements will be automatically made on the following channels. Right-click to display a list.
Terminal assignments for this instruction must fall within the guidelines for universal terminal pairs (see Universal Terminal and Control Port Pairs for more information).
Code | Description |
---|---|
C1 | Control terminal 1 (not valid for low-level AC) |
C2 | Control terminal 2 (not valid for low-level AC) |
C3 | Control terminal 3 (not valid for low-level AC) |
C4 | Control terminal 4 (not valid for low-level AC) |
U1 | Universal terminal 1 (not valid for low-level AC) |
U2 | Universal terminal 2 |
U3 | Universal terminal 3 (not valid for low-level AC) |
U4 | Universal terminal 4 |
U5 | Universal terminal 5 (not valid for low-level AC) |
U6 | Universal terminal 6 |
U7 | Universal terminal 7 (not valid for low-level AC) |
U8 | Universal terminal 8 |
U9 | Universal terminal 9 (not valid for low-level AC) |
U10 | Universal terminal 10 |
U11 | Universal terminal 11 (not valid for low-level AC) |
U12 | Universal terminal 12 |
Type: Constant
PConfig (Pulse Channel Configuration)
A code specifying how the pulse channel should be configured. Right-click the parameter to display a list.
NOTE: Code 0 may be used to disable the measurement during cleaning or calibration, if the PConfig parameter is a variable.
Code | Description |
---|---|
0 | Disabled |
1 | Switch Closure with pull up |
2 | Switch Closure with pull down |
3 | High frequency with pull up |
4 | High frequency with pull down |
5 | Low Level AC |
Type: Constant (or Variable that evaluates to 0, 1,
POption (Pulse Option)
A code that determines if the raw result (multiplier =1, offset = 0) is returned in counts or frequency. Right-click to display a list.
Code | Description |
---|---|
0 | Counts |
1 | Frequency in Hz; counts/scan interval in seconds |
>1 | Running average of frequency (Hz).The value entered is the time period of the running average in milliseconds and must be a multiple of the scan interval |
Type: Constant
If an overrange occurs and running averaging is in use, the overrange value is an element of the average until it has fallen off the end of the list. If a running average were set for 1000 milliseconds then an overrange will be the value from the PulseCount instruction until 1 second has passed. Use the PulseCountReset instruction to avoid this.
Mult, Offset (Multiplier and Offset)
Factors by which to scale the raw results of the measurement. Typically used to convert the raw measurement to engineering units or to units other than which is output. For example, the TCDiff instruction measures a thermocouple and outputs temperature in degrees C. A multiplier of 1.8 and an offset of 32 will convert the temperature to degrees F.
For temperature measurements, a multiplier (mult) of 1 and an offset of 0, would output in degrees Celsius. For analog measurements, a multiplier (mult) of 1 and an offset of 0, would output the measured voltage in millivolts divided by the excitation voltage in volts.
If Repetitions of greater than 1 are used for this instruction, Repetitions can also be used for the Multiplier and Offset. See Multipliers, Offsets, and Disable Variables with Repetitions for more information.
Type: Constant, Variable, Array, or Expression