Skip to content
Tutorials Center
My learning

Topics

Lesson 18 of 36 ยท Data Types and Arrays

Waveforms and Error Clusters

Understand the LabVIEW waveform type (t0, dt, Y), dynamic data, charts versus graphs, and the error cluster with error in and error out wiring patterns.

Two data types appear in almost every measurement VI: the waveform, which carries a signal with its timing, and the error cluster, which carries success or failure through your program. This lesson explains both, and how charts and graphs display signals. LabVIEW cannot run on this site, so the examples are JavaScript stand-ins that model the structures; they are not LabVIEW output.

The waveform data type

A waveform is a cluster-like type with:

  • t0: the timestamp of the first sample.
  • dt: the time between samples, in seconds.
  • Y: a 1D array of values (typically DBL).
  • Attributes: optional named extras, such as channel names and units.

Because timing travels with the data, a waveform tells every downstream function the sample rate. Many Signal Processing functions accept waveforms directly and update the timing for you (for example a decimation function changes dt). The wire is brown.

Related types: the digital waveform, for digital lines, and the older dynamic data type (dark blue) used by Express VIs. Dynamic data is convenient for quick work but hides the structure, so for more control convert it with Convert from Dynamic Data to a waveform, an array or a scalar.

Waveform functions

In Programming > Waveform:

  • Build Waveform creates a waveform from t0, dt and Y, or modifies one in place.
  • Get Waveform Components extracts t0, dt, Y.
  • Get Waveform Attribute and Set Waveform Attribute.
  • Append Waveforms.
  • Get Waveform Subset by time or index.

A DAQ read of a waveform gives the correct t0 and dt automatically, based on the task's sample rate.

Charts versus graphs

LabVIEW has two families of plots:

  • A waveform graph shows a whole buffer at once: wire an array or waveform and it draws the complete data, replacing the old content each time.
  • A waveform chart appends new points to a rolling history, like a strip chart recorder. You send it one value or a small block each loop iteration. It remembers the history length (default 1024 points), configurable by right-click > Chart History Length.

Use a graph when you have a buffer to show, and a chart when you stream data a bit at a time. An XY graph takes separate X and Y arrays (or a cluster of both) so spacing can be uneven. A Mixed Signal Graph shows analog and digital together. Right-click a graph to set scaling, autoscaling, cursors, plot style, legends and so on.

Waveform parts

t0 Start time
dt Seconds per sample
Y Array of values

Timing travels with the data.

1 / 2

The error cluster

Almost every LabVIEW function that can fail has error in and error out terminals at the bottom of its connector. The error cluster has three fields:

  • status: Boolean; True means error.
  • code: I32; a number identifying the error. Zero means no error. Positive codes usually mean errors; negative codes can be warnings in some contexts (with status False for a warning).
  • source: a string with where it came from.

The rules

  1. Error in with an error already set: most functions do nothing and pass the error to error out unchanged. This stops a chain of operations after the first failure.
  2. Error in clear: the function runs, and sets error out if it fails.
  3. The first error wins; later functions do not overwrite it.

So you wire the error wire through the diagram, from the first function to the last, in a straight line, bottom of the diagram. This also forces execution order. Finally, the error ends at a Simple Error Handler or General Error Handler (Programming > Dialog & User Interface), which shows a dialog with a plain-language message, or at an error indicator on the panel.

Working with errors

  • Unbundle By Name reads status to branch.
  • Merge Errors combines several error wires, reporting the first.
  • Clear Errors resets an error you have decided to ignore. Use sparingly and on purpose.
  • Custom errors: Error Cluster From Error Code builds one from a code; use codes in the 5000 to 9999 range or negative 8999 to negative 8000, which LabVIEW reserves for users, and describe them in an error-code file (.txt or .xml).
  • A While Loop that talks to hardware should stop when the error status is True: OR the error status with the Stop button.

Case structure on errors

If you wire an error cluster to a Case structure's selector, it offers two cases: No Error and Error. Put the useful work in No Error, and a cleanup or log in Error.

Stand-in 1: a waveform

This models a waveform as an object with t0, dt, Y, and computes time axes and basic statistics, like a graph would use them. It is a model, not LabVIEW's type.

JS Stand-in: a waveform with timing

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Stand-in 2: error-in / error-out chaining

This models the key rule: once an error is set, later nodes skip their work and pass it on. The first error wins.

JS Stand-in: the error wire stops the chain

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Notice that Close was skipped. In real code you often do want to close resources even after an error. Hardware close functions (such as DAQmx Clear Task and VISA Close) are designed to run and still report the original error. Check each function's help.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which three items make up a waveform?

    A waveform has a start time, a time step and an array of values, plus optional attributes.
  2. 2. What is the difference between a chart and a graph?

    Use a graph for a buffer and a chart to stream data.
  3. 3. What does True mean for the status field of an error cluster?

    status True means error.
  4. 4. What does a typical function do when error in already holds an error?

    That is how a chain of calls stops safely after the first failure.

Summary

  • A waveform carries t0, dt and Y, so timing travels with the data; convert dynamic data when you need control.
  • Graphs show a whole buffer, charts keep a rolling history, XY graphs handle uneven X.
  • The error cluster has status, code and source; wire error in/out through every node in a straight chain.
  • Functions skip work when error in is set, so the first error wins; finish with an error handler.
  • Use Merge Errors, Clear Errors and custom codes deliberately.

Next: Talking to Instruments with VISA