« Close

Datasheets and User Guides

App Notes

Software & Driver

 

14.1.7 Average Min Max

 

Index: 3

Average Min Max will sample an analog input a specified number of times at a specified rate, then calculate the average, min and max.

 

Operation:

When the AIN#_EF_READ_A register is read the LabJack will collect the specified number of samples at the specified rate. The average, minimum, and maximum will then be calculated.

Internally this extended feature uses Stream-Burst (stream mode with a nonzero STREAM_NUM_SCANS) to acquire the data set and thus stream rules apply:

  • Range is controlled by the normal AIN range registers.
  • Single-ended or differential is controlled by the normal AIN negative channel registers.
  • Settling time is controlled for all channels by the special stream register STREAM_SETTLING_US.
  • ResolutionIndex is controlled for all channels by the special stream register STREAM_RESOLUTION_INDEX.  The default value of 0 corresponds to ResolutionIndex=1, and only indexes 1-8 are supported (high-res Pro converter not supported in stream).

If you are using this feature to reduce noise by oversampling-and-averaging, consider maximizing ResolutionIndex first as that is the best and fastest way to reduce noise.

 

Configuration:

The number of samples to be collected and averaged as well as the rate at which the samples should be collected need to be specified. If the signal has a known periodic component then setting the total acquisition time to an even multiple of the period will generally improve results.

Total Acquisition Time = NumSamples / ScanRate.

Total Acquisition Time should not exceed 180 ms.

AIN#_EF_CONFIG_A: Number of samples to be acquired. (default=200, max=16384)
AIN#_EF_CONFIG_B: Reserved.
AIN#_EF_CONFIG_C: Reserved.
AIN#_EF_CONFIG_D: ScanRate - The frequency at which samples will be collected.

 

Result Registers:

AIN#_EF_READ_A: Average (volts).  Reading this register actually initiates the data collection, thus this is a blocking read.
AIN#_EF_READ_B: Max (volts).
AIN#_EF_READ_C: Min (volts).

 

Example:

To measure a 10 Hz sign wave with amplitude 0.1 V and DC offset of 1.2 V, set then number of samples to 100 and the scan rate to 1000. The total acquisition time is 100 ms, which matches well with the signal's period.

AIN0_EF_INDEX = 3
AIN0_EF_CONFIG_A = 100
AIN0_EF_CONFIG_D = 1000

Results are Average = 1.201 V, min = 1.101 V and max = 1.301 V. Noise levels are less than 600 µV.

We can change the acquisition period to emphasize the benefit of matching to the period. If we change AIN0_EF_CONFIG_A to 70 then the results are still centered on 1.2, 1.1 and 1.3 V, but noise levels are ±5 mV.