LABVIEW HANDOUT 3 CHAPTER 3: THE MATHSCRIPT NODE

advertisement
LABVIEW HANDOUT 3
CHAPTER 3: THE MATHSCRIPT NODE AND XY GRAPH
Open a Blank VI. Create and run the following program that generates an array of values from a
Sine Function:
Replace the Sine Function with a MathScript Node:
Functions Palette>>Programming >>Structures>> MathScript Node
Place an Input Terminal on the right-hand side of the MathScript Node and an Output
Terminal on the left-hand side.
Right-Click>>Add Input
Right-Click>>Add Output
Type i into the input and y into the output. Type in the first and second lines and connect the
wires. Run the program to verify that the output is the same as before:
Remove the For Loop and modify the program as follows:
Hover the cursor over the broken wire and read the error message. Change the output type of the
MathScript Node to a 1-D array of double-precision floating point numbers:
Right-Click>>Choose Data Type>>1D-Array>>DBL 1D
Notice that the output wire from the MathScript Node to the Array Indicator is now thick
orange. Run the program and verify that the output is the same as before. Place a XY Graph
onto the Front Panel:
View>>Controls Palette>>Modern>>Graph>>XY Graph
Add an Output Terminal on the MathScript Node and name it x. Change its representation to a
1-D Array. Add a Bundle function to the right of the MathScript Node. Resize the Bundle to
have two inputs. Wire the x and y outputs of the MathScript Node to the top and bottom inputs
of the Bundle, respectively. Wire the output of the Bundle to the XY Graph. Run the program.
Edit the above program as shown below. Change the input constants to controls:
Right-Click>>Change to Control
Use the Align Objects
and the Distribute Objects
buttons to quickly arrange the
program parts. Run the program and verify it is working correctly.
Place an Enumerated Control onto the Front Panel:
View>>Controls Palette>>Modern>>Ring & Enum>>Enum
Rename the Enumerated Control to Shape. Right-click the Enumerated Control, and type in
the following, and press OK:
Right-Click>>Properties
Scroll through the options on the Enumerated Control. Now change the program to what you
see below. Run the program to examine the different wave patterns that you can now generate:
Place a Cluster Shell on the Front Panel on the left-hand side of the program and name it
Digitizing Parameters:
View>>Controls Palette>>Modern>>Array, Matrix & Cluster>>Cluster
Copy and Paste this Cluster Shell and place one below the first (name it Waveform
Parameters), and place one to the right of the program (name it Waveform Output). Place the
following controls into the Digitizing Parameters Cluster Shell one at a time: Number of
Samples, Sampling Frequency. Change the size of the Cluster Shell to the contents by
autosizing it:
Right-Click On An Edge>>Autosizing>>Size to Fit
Place the following controls into the Waveform Parameters Cluster Shell one at a time:
Frequency, Amplitude, and Shape. Place the following Array Indicators into the Waveform
Output Cluster Shell one at a time: Time, and Displacement. The Front Panel should look like
this:
Delete all broken wires on the Block Diagram by using CTRL-B. Place an Unbundle By Name
function to the right of the Digitizing Parameters and Waveform Parameters Cluster Shells
on the Block Diagram:
Functions>>Programming>>Cluster, Class, & Variant>>Unbundle By Name
Wire the Digitizing Parameters Cluster Shell to the Unbundle By Name icon. Resize it to
show the two controls. Do the same for the Waveform Parameters Cluster Shell. Wire the
outputs of the Unbundle By Name icons to the appropriate Input Terminals on the MathScript
Node. Wire the output of the Bundle on the output side of the MathScript Node directly to the
Waveform Output Cluster Shell. The updated Block Diagram is presented below. Verify that
it operates as before:
On the Front Panel, save the Digitizing Parameters Controls Cluster:
Right-Click On The Border>>Advanced>>Customize
File>>Save As: Digitizing Parameters
Save the Waveform Parameters Controls Cluster and the Waveform Output Indicator
Cluster in the same way. On the Front Panel, open the Icon Editor by right-clicking the icon
and selecting Edit Icon. Delete the current design by double-clicking on the Filled Rectangle
Tool.
Use the Text Tool to type in Wave Sim, then press OK. Right-click on the icon on the Front
Panel and select the Show Connector Option. Right-click again on the icon and select the
Patterns Option. Select a pattern with two rectangles on the left side and one on the right side.
On the Front Panel, left-click the upper left box on the icon to select it, and then left-click the
Digitizing Parameters Cluster Shell to assign the connector. The box should change color.
Assign the lower left connector to the Waveform Parameters Cluster Shell and the right
connector to the Waveform Output Cluster Shell. Right-click on the icon on the Front Panel
and select Show Icon. Using Show Context Help, hover the cursor over the icon to see the
connections:
Place your name on the Front Panel. Save the program as Waveform Simulator.vi. Print out
the program using Microsoft Word by taking a screen shot of the Front Panel and Block
Diagram.
Download