Skip to main content
Skip table of contents

Measuring Frequency/Pulses (App Note)

Pulse signals are a common type of sensor output. The quantity of interest is often described by the total number of pulses that occur, or the number of pulses that occur per second (the pulse frequency). For example, Some flowmeters have pulse outputs: a pulse indicates a certain flow quantity and the number of pulses per second is the flow rate. RPM sensors typically output a certain number of pulses per revolution.

Below are some common strategies to measure pulse signals using LabJack hardware.

LabJack Counter

All LabJack devices have at least one counter available through a digital IO channel. A counter simply increments an internal register whenever an external pulse is detected. By looking at the change in count over a change in time, frequency can be calculated. For example:

Frequency = (CurrentCount - PreviousCount) / (CurrentTimestamp - PreviousTimestamp)

See the counter documentation in your specific device datasheet for further information - links below. 
Note: On T-Series devices, we call timer and counter features DIO_EF (DIO Extended Features).

Counter Frequency Measurement Error

When using a counter to measure frequency, your measurement accuracy depends on how well you can associate a count value to some timestamp. A common technique is to retrieve the current count from the LabJack hardware, and when the read is complete, note the current millisecond timestamp from the application that is taking the LabJack measurements. In this case, jitter occurs due to any inconsistency in the time between the counter read and timestamp read, and it is commonly around ±1 ms when using built in timing functions on Windows/Linux/macOS. If this jitter is estimated as ±1 ms it could cause an error of ±2 ms because two separate readings are required to find the number of counts in a time period. If a measurement is done every 1000 ms, the jitter could cause up to ±2 ms of error out of 1000 ms total, or 0.2% error. If you count for 10 seconds between readings, this error would decrease to about 0.02% error. Below are some solutions to further reduce error:

  1. All LabJack hardware, besides the U12, can reduce this time jitter error by getting a timestamp from the device hardware rather than from your host computer. The timestamp can be retrieved in the same function call as the counter reading, reducing the timing jitter to less than 10 microseconds. See the system timer documentation, links below, in your device datasheet for more information:

  2. Rather than reading the counter using software timed command/response mode, you can read the timer in stream mode. Stream mode is hardware timed at a specified interval. For example, if you stream the counter at 100 scans/second, then you know that every 100th scan is exactly 1 second apart (to the accuracy of the LabJack’s clock - each device clock specifications linked below). See the stream and/or communications documentation in your device datasheet for further information:

Counter Examples

The following links have more details and examples related to working with the LabJack counter features.

LabJack Timer Feature

All LabJack devices, besides the U12*, support timers that can be used to measure frequency in firmware. Since these features are timed using LabJack timing resources in firmware, they are often more accurate than using a counter to measure frequency. See the timer documentation in your specific device datasheet for further information - links below.
Note: On T-Series devices, we call timer and counter features DIO_EF (DIO Extended Features).

* Special note about the U12:
The LabJack U12 does not have timers, so the best option for pulse timing is to retrieve analog or digital inputs in stream/burst mode and find the time in software. The smallest time resolution available on the U12 is from a burst of a single analog input. In this case the sampling rate can be up to 8192 samples/second, meaning that the time resolution is about 122 μs.

Timing Individual Pulses

Individual pulses can be timed by monitoring the digital or analog input channel(s) they are connected to.  However, this is generally the least recommended way to measure pulses due to the channel's limited sampling rate on LabJack devices, which can also limit the input signal frequency that can be fully captured for analysis.  We recommend using a LabJack counter or timer feature whenever possible.

Command response timing is inherently inconsistent and results in lower sampling rates compared to stream mode. Stream mode* is usually the better option to time individual pulses. All LabJack hardware supports stream mode acquisition. See the links below for stream and/or communications documentation for your specific device datasheet for further information:

*Advanced Analog Measurements

Stream mode, and particularly stream burst modes, are often the best way to analyze analog signals whose characteristics cannot be properly captured using a digital I/O feature. The high sampling rates, high sampling interval accuracy, and discrete values captured using stream burst can be leveraged for calculations such as FFT, finding signal midpoints, frequency, signal peaks, RMS values, etc.

Timer Examples

The following links have more details and examples related to working with the LabJack timer features.

Frequency To Voltage Converter

There are various commercial signal conditioning devices available to convert frequency to an analog voltage signal. It is typically easy to measure voltage from these converters with an analog input on a LabJack.

AutomationDirect is one source for signal conditioning modules, but other common electronic distributors/manufacturers such as Digikey, Newark, and Omega are also likely have frequency to voltage conditioners.

Amazon also carries some options.

For a lower level solution, consider the LM2917.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.