Create an NI-DAQ™mx Custom Scale Programmatically in LabVIEW

Updated Aug 3, 2023

Environment

Software

  • LabVIEW

Driver

  • NI-DAQmx

  • I want to apply a custom offset to the data I am acquiring. This offset may be different for each channel. What is the easiest way to do so?
  • I know NI-DAQ™mx custom scales can be created and applied in MAX, but how can I do this programmatically in LabVIEW?
  • How can I convert programmatically my current or voltage input into the physical value I'm looking for (e.g. psi, N, m/s...)?

To create and configure an NI-DAQmx custom scale programmatically in LabVIEW, you can use the DAQmx Create Scale VI available in the Functions Palette under Measurement I/O » NI DAQmx - Data Acquisition » DAQmx Advanced » DAQmx Scale Setup. This polymorphic VI allows you to create custom scales of the type linear, map ranges, polynomial, and table.


Applying an NI-DAQmx Custom Scale

To apply a custom scale to a DAQmx virtual channel, wire the scale out terminal of the DAQmx Create Scale VI to the custom scale name terminal of the DAQmx Create Virtual Channel VI.


The DAQmx Create Scale.vi is a polymorphic VI and can be configured for the following scale types:


Linear

Creates a custom scale that uses the equation y = mx + b, where x is a pre-scaled value, and y is a scaled value. The equation is identical for input and output. If the equation is in the form y = mx + b, you must first solve for y in terms of x. You can represent m and b with the slope and y-intercept inputs of the DAQmx Create Scale VI, respectively.

Map Ranges

Creates a custom scale that scales values proportionally from a range of pre-scaled values to a range of scaled values. Four inputs are available on DAQmx Create Scale VI to specify pre- and post-scaled minimum and maximum values.

Polynomial

Creates a custom scale that uses an nth order polynomial equation. NI-DAQmx requires both a polynomial to convert pre-scaled values to scaled values (forward) and a polynomial to convert scaled values to pre-scaled values (reverse). If you only know one set of coefficients, use the DAQmx Compute Reverse Polynomial Coefficients VI to generate the other set. DAQmx Create Scale VI contains two inputs for these forward and reverse polynomial coefficients.

Table

Use the pre- and post-scaled inputs of the DAQmx Create Scale VI to create a custom scale that maps corresponding scaled values. NI-DAQmx applies linear interpolation to values that fall between the values in the table. Read operations clip scaled samples that are outside the maximum and minimum scaled values found in the table. Write operations generate errors for samples that are outside the minimum and maximum scaled values found in the table. 


 


For more information about NI-DAQmx Custom Scales, please see What Are NI-DAQmx Custom Scales and How Do I Use Them?

Additional Information
DAQmx Scales can be programatically saved to MAX using the DAQmx Save Scale VI and similarly deleted using the DAQmx Delete Scale VI. Both of these functions can be found in NI-DAQmx»Advanced»System Setup»Storage.

Properties of Saved Scales can be altered using the DAQmx Persisted Scale Property Node. Editable Properties of scales are:

  • Active Scale (Specifies the saved custom scale to which subsequent properties apply.)
  • Author (Indicates the author of the custom scale.)
  • Allow Interactive Editing (Indicates whether the custom scale can be edited in the DAQ Assistant.)
  • Allow Interactive Deletion (Indicates whether the custom scale can be deleted through MAX.)