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

Updated Oct 10, 2024

Environment

Software

  • LabVIEW

Driver

  • NI-DAQmx

The following article will explain a way to create customs scales programmatically using a DAQmx function that allows multiple types of configuration. This guide assumes knowledge of the use of LabVIEW with NI-DAQmx functions. See the following for more details:

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.)