resample
Syntax
Shorthand
- resample: number
Extended
- resample:
interval: number
interval
: The time between samples, in seconds
Description
Resamples an analog data stream to a given sample rate, specified in seconds. The outgoing sample rate will be fixed even if the incoming sample rate is variable or inconsistent.
If the sample interval is larger than the source interval, resampling is calculated by taking every Nth sample from the source where N is resample-interval / source-interval. If N is a fraction and a calculated sample falls between two source samples, the older sample will be emitted.
If the resample interval is smaller than the source interval, resampling is calculated by emitting N samples for every source sample, where N is source-interval / resample-interval. The previous received source sample is repeated for each of N samples until a sample's time matches or crosses the new sample time.
The resample operation has a built-in safety limit. If more than 5 minutes passes between samples being passed to resample, then only the most recent 5 minutes of resampled values will be calculated.
Examples
- AdapterScript
var1:
- source: AIN0
- resample: 0.5
In the above example, AIN0
is an identifier available in LabJack data sources.