Download the Step-by-Step Procedure PDF
Graphs and charts differ in the way they display and update data. VIs with a graph usually collect the data in an array and then plot the data to the graph. When the data is plotted, the graph discards the previously plotted data and displays only the new data. You typically use a graph with fast processes that acquire sets of data continuously.
In contrast, a chart appends new data points to those points already in the display to create a history. On a chart, you can see the current reading or measurement in context with data previously acquired. When more data points are added than can be displayed on the chart, the chart scrolls so that new points are added to the right side of the chart while old points disappear to the left. You typically use a chart with slow processes in which only a few data points per second are added to the plot.
Follow this procedure to create an example to help understand how charts and graphs function in LabVIEW. Before starting this procedure, you need to complete the exercise in the Taking a Measurement module.
-
Create a numeric slider control for the Fahrenheit temperature control
-
Right-click the front panel and select Modern»Numeric»Vertical Pointer Slide
-
Title this Temp (F) for the temperature in Fahrenheit
-
Set the maximum input to 200 and minimum input to -200
-
Right-click the control and select Visible items»Digital Display to display the digital value
-
Create a waveform chart and waveform graph indicator
-
Right-click the front panel and select Modern»Graph»Waveform Graph
-
Left-click to place the graph
-
Right-click the front panel and select Modern»Graph»Waveform Chart
-
Left-click to place the chart below the graph
-
Create a thermometer numeric indicator to display the temperature in degrees Celsius
-
Right-click the front panel and select Modern»Numeric»Thermometer
-
Title this Temp (C) for the temperature in Celsius
-
Set the maximum input to 100 and minimum input to -100
-
Right-click the control and select Visible items»Digital Display to display the digital value
-
Convert the temperature from Fahrenheit to Celsius
-
Navigate to the block diagram using <Ctrl-E>
-
Place a Subtract function by right-clicking the block diagram and selecting Programming»Numeric»Subtract and left-clicking to place
-
Wire the Temp (F) control to the top input
-
Right-click the bottom input and select Create»Constant and enter 32 for the value
-
Place a Divide function by right-clicking the block diagram and selecting Programming»Numeric»Divide and left-clicking to place it above the Subtract function
-
Right-click the top input, select Create»Constant, and enter 5 for the value
-
Right-click the bottom input, select Create»Constant, and enter 9 for the value
-
Place a Multiply function by right-clicking the block diagram and selecting Programming»Numeric»Multiply and left-clicking to place it to the right of the Subtract and Divide functions
-
Wire the divide output to the top input terminal of the Multiply function
-
Wire the subtract output to the bottom input terminal of the Multiply function
-
Wire the output of the Multiply function to the input of the waveform chart and the input to the Temp (C) thermometer numeric indicator
-
Attempt to wire the output from the Multiply function to the input of the waveform graph
-
Note that this causes a broken wire because it requires an array input
-
Place a While Loop around the code to create an array and allow the VI to run continuously
-
Move the waveform graph to the right of the rest of the code on the block diagram
-
Right-click the block diagram and select Programming»Structures»While Loop
-
Left-click and drag this around the code, excluding the waveform graph
-
Right-click the conditional terminal and select Create»Control to create a Stop button on the front panel
-
Create an auto-indexing tunnel to output an array when the While Loop is exited
-
Wire the output from the Multiply function to the input of the waveform graph indicator that is outside the While Loop
-
This automatically creates a non-auto-indexing tunnel, and the wire is broken because the graph indicator requires an array
-
Right-click the tunnel and select Enable Indexing to output an array of values
-
Add a 100 ms wait to the VI
-
Right-click the block diagram and select Programming»Timing»Wait (ms)
-
Left-click to place within the While Loop
-
Right-click the input and select Create»Control and enter 100 for the value
-
Run the VI to observe the results
-
Note that the waveform chart updates with every iteration of the While Loop
-
Note that the waveform graph does not update until you press the Stop button