Professional Documents
Culture Documents
Text-Based Integration.. Step by Step Procedure
Text-Based Integration.. Step by Step Procedure
To illustrate the needs for text-based integration in LabVIEW, consider an equation used to convert the
resistance of a thermistor to the appropriate temperature in degrees Celsius.
You can see that this is a complex polynomial equation that requires many mathematical operations. While
possible, this is something that can quickly become cluttered in LabVIEW and difficult to follow as seen in
Figure 2:
Figure 3 is an example of how the formula could be represented in a traditional text-based language such
as C. This is a lot easier to understand, and it resembles closely the actual equation. Now look at how to
implement this using the Formula Node and MathScript Node.
ni.com/students/learnlabview
b. Right-click the Voltage channel in the Channel Settings list box and select Remove from Task
c. Click the blue plus (+) sign to add a channel to the task and select Resistance
2. Place a Formula Node on the block diagram to convert resistance to degrees Celsius
a. Right-click the block diagram and select Mathematics >> Scripts & Formulas >> Formula Node
b. Paste the following equation into the Formula Node window and resize accordingly
float64 M;
M=ln(R/10000);
T=(1/(A+B*M+C*M*M+D*M*M*M))273.15;
3. Add inputs to the Formula Node for all input variables in the equation
f. Wire the Data output from the DAQ Assistant to the R input of the Formula Node
a. Right-click the block diagram and select Programming >> Structures >> While Loop
ni.com/students/learnlabview
6. Create the stop condition to include when the Stop button is pressed or an error is detected
a. Unwire the Conditional Terminal from the Stopped output terminal of the analog input DAQ Assistant
b. Right-click the block diagram and select Programming >> Boolean >> Or
c. Wire the output from the Stop button control to the bottom input of the Or Boolean function
d. Right-click the block diagram and select Programming >> Cluster, Class, & Variant >> Unbundle by
Name and place this to the right of the analog input DAQ Assistant
e. Wire the Error Out output terminal of the analog input DAQ Assistant to the input of the Unbundle by
Name function and ensure Status is selected to be unbundled
f. Wire the output of the Unbundle by Name function to the top input of the Or function
g. Wire the output of the Or function to the input of the Conditional Terminal
MathScript Node
You can also use the MathScript Node to run preexisting .m file scripts as well as develop .m files in LabVIEW
for signal processing.
Before starting this procedure, you need to complete the exercise and use the solution in the Taking a
Measurement module. You can also create a numeric control to simulate the data acquisition input.
Note: If you are not using a DAQ Assistant to acquire resistance data and convert to temperature, skip ahead
to step 2 and use a numeric control in place of the DAQ assistant.
1. Configure the voltage input DAQ Assistant to the input resistance from the DMM terminals
b. Right-click the Voltage channel in the Channel Settings list box and select Remove from Task
c. Click the blue plus (+) sign to add a channel to the task and select Resistance
2. Place a MathScript Node on the block diagram to convert resistance to degrees Celsius
a. Right-click the block diagram and select Mathematics >> Scripts & Formulas >> MathScript Node
b. Paste the following script into the MathScript Node window and resize accordingly
double M;
M=log(R/10000);
T=(1/(A+B*M*M+C*M*M+D*M*M*M));
T=T273.15;
ni.com/students/learnlabview
3. Add inputs to the Formula Node for all input variables in the equation
c. Wire the Data output from the DAQ Assistant to the R input of the MathScript Node
g. Wire the Data output from the DAQ Assistant to the R input of the MathScript Node
a. Right-click the block diagram and select Programming >> Structures >> While Loop
6. Create the stop condition to include when the Stop button is pressed or an error is detected
a. Unwire the Conditional Terminal from the Stopped output terminal of the analog input DAQ Assistant
b. Right-click the block diagram and select Programming >> Boolean >> Or
c. Wire the output from the Stop button control to the bottom input of the Or Boolean function
d. Right-click the block diagram and select Programming >> Cluster, Class, & Variant >> Unbundle by
Name and place this to the right of the analog input DAQ Assistant
e. Wire the Error Out output terminal of the analog input DAQ Assistant to the input of the Unbundle by
Name function and ensure Status is selected to be unbundled
f. Wire the output of the Unbundle by Name function to the top input of the Or function
g. Wire the output of the Or function to the input of the Conditional Terminal
2011 National Instruments. All rights reserved. LabVIEW, National Instruments, NI, and ni.com are trademarks of National Instruments.
Other product and company names listed are trademarks or trade names of their respective companies.
ni.com/students/learnlabview