Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
IV
ME 241 Spring 2014
Charts and Graphs
Collecting data using a While loop
Collecting data using DAQ to control number and frequency
ME 241 Spring 2014
Combined system image from: bigriveradvertising.com
ME 241 Spring 2014
Calibrator collected data one pair of points (independent and dependent variables) at a time.
Next step is to build a system to collect a series of data points over time.
That is, we want data pairs (t, y)
Begin by looking at graphical means of
displaying this kind of data in LabVIEW.
ME 241 Spring 2014
ME 241 Spring 2014
Labview “Graphs and Charts” video from NI website.
Duplicate the demonstration from the video.
Build a system that takes in slider data (-50 to +100)
Displays the last 100 data points on a chart while running.
Displays the complete data set on a graph when stop is pressed.
Put a 100 ms time delay into your While loop to slow the data collection rate
ME 241 Spring 2014
ME 241 Spring 2014
What happens if auto indexing is not enabled at the loop tunnel?
ME 241 Spring 2014
Trying changing the value of the delay timer
◦ How does it affect your ability to see rapid changes?
◦ How does it affect your ability to see longer term trends?
◦ How fast does the While loop collect data if the delay is set to zero?
ME 241 Spring 2014
First build a very simple system to collect data using a While loop. ◦ Just collect and display the data
Only a few components ◦ DAQ ◦ Waveform Chart ◦ While loop ◦ Stop button for the loop
Will then collect some data provided by a signal generator.
ME 241 Spring 2014
In order for the DAQ Assistant to configure properly, it must be able to look at your ADC.
Plug the 6009 into your computer using the USB.
ME 241 Spring 2014
Key is to set the acquisition mode to “1 Sample (on demand)”
Each iteration of the loop will cause the DAQ to collect a data point.
key to the use of the While loop
ME 241 Spring 2014
ME 241 Spring 2014
Finally need to connect the output of the measuring device to the desired channel on the 6009 ADC.
We are using differential channel 0 (AI0, AI4), so we want to connect our two wires there.
For the workshop: ◦ Have already connected wires to AI0, AI4 channel 0.
[may also be wired for channel 2 (AI2, AI6)] ◦ Just connect the matching BNC connector to “A” on the
desktop (this will connect the two wires into the signal generator at the front of the classroom)
ME 241 Spring 2014
We will supply a signal(s) from the signal generator. Try manipulating the settings of your system and observe what happens.
◦ Add a wait timer to the loop. What happens if you
use a large wait time (e.g. 1000s of ms)?
◦ Play with the settings on the Chart.
ME 241 Spring 2014
Make sure you save this VI for use later in the workshop.
ME 241 Spring 2014
ME 241 Spring 2014
Build a simple system in which the DAQ controls the frequency of data point collection and the number of points collected. ◦ Collect and display the data ◦ Send it to a Write to Measurement File
Again a few components ◦ DAQ (and two associated controls) ◦ Waveform Graph ◦ Write to Measurement File (and two associated controls)
Will then collect some data provided by a signal generator.
ME 241 Spring 2014
In order for the DAQ Assistant to configure properly, it must be able to look at your ADC.
Make sure the 6009 is still plugged into your computer using the USB.
ME 241 Spring 2014
The important change
Create these on the block diagram. They also appear
on the front panel
Open a new blank VI
Key is to set the acquisition mode to “N Samples”
DAQ will collect N samples at the rate specified ◦ Add 2 controls so I can
adjust N and the rate from the Front Panel
ME 241 Spring 2014
Must add on the Front Panel
Make sure it is a Graph (not a Chart)
ME 241 Spring 2014
Note the “new” settings
◦ One column only
Also add 2 controls so (from the Front Panel) you can ◦ select enable/disable
◦ select a file name
ME 241 Spring 2014
ME 241 Spring 2014
Wire the Block Diagram Arrange the Front Panel Customize labels, etc. if you wish
Default labeling can be confusing.
Worthwhile spending a few seconds to make sure the VI is clear, especially if you will be using it again.
Same is true for making the layout, wiring, etc. clear.
ME 241 Spring 2014
Enabled right now, or do I need to push the button to enable it?
Output of the measuring device connected to the desired channel on the 6009 ADC.
We are using differential channel 0 (AI0, AI4), so we want to connect our two wires there.
For the workshop: ◦ Have already connected wires to AI0, AI4 channel 0.
[may also be wired for channel 2 (AI2, AI6)] ◦ Just connect the matching BNC connector to “A” on the
desktop (this will connect the two wires into the signal generator at the front of the classroom)
ME 241 Spring 2014
We will supply a signal(s) from the signal generator.
Run the system with the Write to Measurement File button in the Disabled setting.
System will run until it collects the specified number of data points. The data will then be passed to the Graph and plotted.
No data is saved.
ME 241 Spring 2014
Run the system with the Write to Measurement File button in the Enabled setting.
System will run until it collects the specified number of data points. The data will then be passed to the Graph and plotted.
Data is saved to a File. ◦ Because we selected the “Use next available file name”
setting in the Write to Measurement File, you will get a new file each time you collect data (test.lvm, test2.lvm, test3.lvm, etc.)
◦ Use Excel to check this and open one of the Files.
ME 241 Spring 2014
ME 241 Spring 2014
New file every time.
In this example the DAQ was configured to collect 1000 data points at a rate of 1000/sec.
File contains 1000 data points.
X value (time) increases 0.001 between data points.
Make sure you save this VI for use later in the workshop.
ME 241 Spring 2014
ME 241 Spring 2014
image from: www.geocities.jp
The While loop timed system you built is convenient for looking at data as it is being collected.
The DAQ timed system you built is convenient for looking at complete blocks of data. ◦ Control/adjust the number of data points collected.
◦ View complete set of data on the Graph.
◦ Save data to a file for latter analysis.
ME 241 Spring 2014
Open a new blank VI
Open a Case Structure on the Block Diagram ◦ Make it large ◦ Make sure it is set to the “True” case
Enclose and copy the entire
contents of the Block Diagram of your While loop timed VI
Paste this inside the True case structure
Note: the contents of the front panel will also copy over
ME 241 Spring 2014
Switch the case structure on the Block Diagram to False
Enclose and copy the entire contents of the Block Diagram of your DAQ timed VI
Paste this inside the False case structure
Note: the contents of the front panel will also copy over. It may be messy (two sets of controls/indicators on top of each other spend a few seconds to sort them out
ME 241 Spring 2014
Clean up controls for two systems ◦ Chart on top ◦ Graph on bottom
Need a control to switch from True (While loop timed) to False (DAQ timed)*
We’ll also add a couple of lights to indicate which is on…
*Note: switch is only effective if you switch before you run (can’t change in the middle of running).
ME 241 Spring 2014
ME 241 Spring 2014
ME 241 Spring 2014
Make sure you save this VI for possible use later.
ME 241 Spring 2014
Test out the various features on your VI.
Experiment with changing the scales, number of data points collected, collection rate, etc.
ME 241 Spring 2014
Enable
Make sure you save this VI for possible use later.
ME 241 Spring 2014
You can now program in LabVIEW.
ME 241 - Level IV
ME 241 Spring 2014