LabVIEW DAQ: Stop on Speed Threshold, Not Sample Count

Brian Holt6 min read
Data AcquisitionOther ManufacturerTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Reject the fixed-length quick fixes

Do not shorten the record by guessing how long the shaft engagement will take. The current call collects 30,000 samples from three channels at a sample rate of 20k. Any shorter fixed count can cut off a slow engagement, while the present count leaves unwanted constant-speed data after a fast engagement.

Quick fix Why it fails Use instead
Reduce the sample count Engagement duration can change, so a fixed endpoint does not follow the process event. Stop or trim at the measured speed threshold.
Stop the loop after displaying the target speed A block may already contain samples beyond the crossing, leaving the same constant-speed tail. Find the crossing index inside the block and truncate there.
Compare only the last sample in each block The threshold may be crossed earlier in that block, and a brief crossing can be hidden if speed later falls back. Search every speed sample in acquisition order.
Trim only the speed waveform The three channels then have different lengths or lose time alignment. Apply one endpoint index to all three waveforms.

For a quick production recovery, acquire in manageable blocks, detect the target crossing, and retain data only through that sample. After production is stable, add noise qualification and explicit timeout handling.

Use the speed waveform as the stop condition

The shaft-speed channel already contains the event that defines the useful record. Replace the fixed sample count as the primary endpoint with a comparison between each acquired speed sample and the known target.

For acceleration toward a positive target, the usual crossing test is measured speed greater than or equal to target speed. For a decreasing-speed event, reverse the comparison. If the waveform represents a voltage proportional to speed, compare against the voltage corresponding to the target only after confirming the scaling. A modified LabVIEW example used an input rising above 4.0 V; that value demonstrates the comparison pattern and is not a shaft-speed setting.

Stopping a software loop happens after a read returns. The returned block can therefore extend past the physical crossing. The exact analytical endpoint is not the loop-stop time; it is the first qualifying sample inside the speed waveform. Preserve its index and use it to trim every channel.

Replace the one-shot read with a block loop

Modify the Acquire Waveforms VI arrangement so acquisition proceeds through repeated reads rather than one request for the entire 30,000-sample record. Keep all three channels in the same acquisition so their sample positions remain aligned.

  1. Start the acquisition and initialize storage for the three waveform channels.
  2. Read the next block from all channels.
  3. Search the speed channel from its first new sample to its last new sample.
  4. Append the block if no sample meets the target condition, then read again.
  5. If a crossing is found, append only the samples through that crossing index for all three channels.
  6. Stop and clear the acquisition after the retained data has been copied.
  7. Pass the trimmed waveforms to the waveform-analysis VIs.
start acquisition
repeat
    read the next block from all three channels
    search the speed samples in chronological order

    if the first target crossing is found
        retain every channel through the same crossing index
        exit the acquisition loop
    else
        retain the complete block
until stopped or the allowed record length is reached

stop acquisition
send retained waveforms to analysis

Keep a maximum-record exit as a fault path. Without it, a broken speed sensor, an unreachable target, or a stalled shaft can leave the acquisition waiting indefinitely. The existing 30,000-sample limit can serve as that ceiling if it is long enough for the slowest valid engagement.

Trim every waveform at one crossing index

Search for the first qualifying speed sample, not the maximum speed and not the final sample above the target. If the crossing occurs at position N in the current speed block, retain positions from the start of that block through N from each of the three channel blocks. Include the crossing sample when the analysis needs the measured point that satisfied the endpoint condition.

When previous blocks have already been accumulated, the endpoint in the complete record is the number of retained samples from prior blocks plus the local crossing position. Keep the waveform timing information intact when taking the subset. Removing waveform metadata or rebuilding arrays without their time origin and sample interval can make otherwise aligned channels appear to have unrelated time bases.

No conversion from one channel's position to another is required when all channels return equal-length, simultaneous blocks. If channel lengths differ, or the channels came from separate acquisition tasks, stop and correct the acquisition architecture before trimming. A shared numeric index is valid only when the samples represent the same acquisition timeline.

Qualify noisy threshold crossings

A single greater-than comparison is enough for a clean, monotonic speed signal. Noise near the target can produce an early crossing, however. Choose the qualification method from the physical requirement rather than hiding the problem by raising the threshold.

Observed behavior Correction Verification
One noisy sample reaches the target early Require a selected number of consecutive qualifying samples. Replay a record containing noise near the target and confirm the endpoint does not move to an isolated spike.
Speed oscillates around the target Use separate enter and release thresholds when the logic must remain latched. Confirm one engagement produces one stop event.
Target falls between two samples Use the first qualifying sample for acquisition control; interpolate later only if the analysis requires a refined crossing time. Compare the reported crossing with the two samples that bracket it.
Scaled speed disagrees with raw voltage Perform the comparison in one declared engineering domain and verify the channel scaling. Check that the displayed speed and stop decision use the same conversion.

Do not choose a consecutive-sample count until the permitted detection delay and signal bandwidth are known. Each added sample delays the declared crossing by one sample interval. Record that rule with the analysis configuration so a later maintenance change does not alter engagement duration silently.

Verify the captured engagement before release

  1. Run with a target that the shaft reaches normally.
  2. Confirm the retained speed waveform ends at the first sample that satisfies the selected comparison.
  3. Confirm all three waveforms have the same sample count, time origin, and sample interval.
  4. Check that the final portion no longer contains an extended constant-speed segment.
  5. Run a slower engagement and verify that acquisition continues until the target rather than stopping at an assumed time.
  6. Test an unreachable target and confirm the maximum-record or operator-stop path ends the acquisition cleanly.
  7. Feed the trimmed record to each required waveform-analysis VI and check that it processes only the engagement interval.

If a complete block still appears after the crossing, the application is stopping only between reads. Keep the loop behavior, but trim the final block at its internal crossing index. If samples disappear before the event, inspect block accumulation and the maximum-record exit rather than lowering the target.

FAQ

How do I stop LabVIEW acquisition when shaft speed reaches a target?

Read the three channels in repeated blocks, search every new speed sample for the target crossing, and exit after retaining samples through the first qualifying index.

How do I remove samples collected after the speed threshold?

Find the crossing position inside the final speed block and take the same inclusive subset from all three waveforms. Do not discard the whole final block or trim only the speed channel.

How do I prevent noise from stopping the DAQ too early?

Require consecutive qualifying samples or apply a latched threshold rule. Select the qualification from the permitted detection delay and verify it against recorded noise near the target.

How do I know when to stop troubleshooting LabVIEW DAQ logic?

Stop here if channel lengths differ, timing metadata is missing, acquisition will not stop through its normal control path, or the hardware continues sampling after the task is cleared. Preserve the smallest repeatable VI, note the LabVIEW version—the supplied example was saved in 6.1—and escalate to official National Instruments support with the acquisition configuration and captured waveforms.

Back to blog