Moving Average: Interval Compute (High Speed) | LabJack
« Close

Datasheets and User Guides

App Notes

Software & Driver


Moving Average: Interval Compute (High Speed)

This script reads analog inputs and computes the average value of each read channel on a given interval. This is useful for situations where analog inputs want to be read at high data rates. Keep in mind that while a script is computing the average value analog input values aren't being read. In time-critical applications where this is important to characterize and understand, I/O lines can be toggled and monitored with an oscilloscope to determine if the script is reading data fast enough and with low enough jitter.

This script can be customized by editing the sampling interval, number of samples to average, user-ram update rate, and channel register constants.

Warning: This script calculates the moving average by maintaining a "sum" which is (in memory) a float32 data type. While the value will remain close to the true value, the precision may slowly drift.

This example can be found in our Kipling git repository: