微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 测试测量 > 虚拟仪器 > 贴个英文FAQ-前面板对象部分

贴个英文FAQ-前面板对象部分

时间:12-13 整理:3721RD 点击:
03年的,有点old
不过内容不错
FAQs (back)
Front Panel Objects
What are the differences between charts and graphs?
<Wayne Galbraith waynegATcyllene.uwa.edu.au>
(Timeless)
LabVIEW provides the ability to plot charts in 2 dimensions and graphs in both 2 and 3 dimensions. The latter can be either in the form of a surface, toroid or wire graph.
Charts are the easiest of the LabVIEW plots to use. Charts provide the fastest plotting of data as they use an internal FIFO buffer to retain a specified amount of existing data points, with new points simply being appended to the plot. Charts plot all data as a function where all data is plotted against the 'X' axis in an incremental manner. This is the fundamental difference between charts and graphs allows charts to simply append each new point to the plot.
Inputs to charts can be numeric values in which case each new point is plotted point by point, or an input can consist of an array allowing the plot to be constructed array by array. Charts can draw in three different modes: strip, scope or sweep. The strip chart is where each point is plotted on the right hand side of the chart boundary. With the scope chart, once the existing chart display is full, the chart is cleared and the next point is started from the left hand side of the screen. The sweep chart is similar to the scope chart, but does not clear the existing chart and each new point redraws over an existing point if present.
Graphs on the other hand replot each and every point every single time the graph is updated. Although this increases the drawing overhead, graphs provide flexibility in terms of what they will plot. The two types of graph are waveform and XY.
The waveform graph plots data against the X axis using the default values for X0 and delta x. The input in this case is simply a 1D array of data. Alternatively you can plot data against the X axis by defining the X0 point and the delta x. In this case the inputs are numeric values defining X0 and delta x, the final input is still a 1D array. These three values are bundled together to make a cluster input to the graph.
The XY graph is the most flexible of all LabVIEW's plotting functions. This graph may be any shape as required. The input to this graph can be either two individual arrays bundled together representing the x and y values or an array of clusters where each cluster contains an x and y value.
Graphs do have the overhead of requiring that the complete graph be replotted for every new point that is received, and hence may plot slower than charts. A graph plot will eventually become slower and slower (this will only become evident with a very large number of data points being plotted) with subsequent addition of data if new data is simply left to append onto the existing array. To restrict data points simply set up a FIFO buffer and truncate from the front of the plotting buffer.
(back)
How do I plot multiple Y axes on a single plot?
<Rolf Kalbermatter rolf.kalbermatterATciteng.com, John Marshall john.marshallATphysics.org, Jim Medlin jimATmedlin.com, Paul Sullivan PaulATSULLutions.com>
(Sep 2000)
Prior to LabVIEW 6.0i according to the National Instruments' KnowledgeBase Document ID: 1B077H0W, "Currently you cannot have multiple Y-axes on your XY Graph in LabVIEW." For versions earlier than 6.0i they explain how you can create the appearance of two Y-axes by superimposing a slider on a graph. Their example VI looks good but the plotted data doesn't match the scales. (Turn off autoscaling for the Y-axis to see this more easily.) Check it out anyway at www.ni.com to see how the various parts are combined.
An alternative for those with earlier versions earlier of LabVIEW is to use the Componentworks control (also from NI), but with the of release of 6.0i multiple X and Y axes are supported and the LabVIEW upgrade is cheaper than purchasing Componentworks. We'll now discuss alternatives for LabVIEW versions prior to 6.0i.
If you want real performance with multiple axes, you will have to do your own scaling. Make the graph have a scale of 0 to 1 and then normalize your incoming data to that scale. Hide the graph scale and add two sliders (instead of just one), one to each side of the graph. Edit the sliders to only show their scales and set the min and max values of the scale to the desired values.
To size the sliders to the exact size of the graph, temporarily create attribute nodes for the sliders and set them to "housing size >> height". Wire a control to each of these attribute nodes and size the height that way. Another approach is to select the slider and choose Edit >> Edit Control... to open the control editor. In the control editor, choose Windows >> Show Parts Window to display a window in which dimensions of all the parts of the slider can be adjusted digitally.
You can make the color of the slider scale the same as the plot color. Change the frame color for better contrast of the scales.
Autoscaling can be easily accomplished by creating an attribute node for the "Y Range" of the graph, reading that value, multiplying by the scaling factor of each waveform, and feeding it to the "Range" attribute of each Slider.
Another approach is to overlay two separate graphs, with the uppermost having a transparent background *and* plot area. That allows each plot to have a separate y axis scale. As long as the plots are the same size, this gives the appearance of 2 plots on 1 graph with 2 scales. With this approach, you cannot use the zoom function of the palette.
(back)
How do I programmatically clear graphs and charts?
<Brian Paquette Brian_PaquetteATsensarray.com>
(Timeless)
To clear Waveform Charts: (a) create an attribute node for the chart, (b) select "History data" as the attribute, and (c) wire up an empty array to the attribute node. As a tip, don't do this when the VI starts but instead do it when the VI exits. That way, when the VI loads it will be ready to go and the user won't see any data from the last run at all.
To clear Waveform Graphs and XY Graphs: (a) create a local variable for the graph, and (b) wire up an empty array to the local variable. As a tip, do it when the VI exits. Alternatively, you can contrive your wiring so you deliver an empty array to the terminal itself when the VI is exiting, but the local variable is probably easier to implement.
(back)
How do I give two colours to a line graph or a chart so they change when crossing a threshold?
<Craig Graham c.n.grahamATlancaster.ac.u>
(May 2001)
Copy your data to two arrays, in one array make all values at or above the threshold "NaN" and in the other array make all values at or below the threshold "NaN". Plot both arrays on the same graph indicator and you can set the properties of each data set independently, even though they appear to be the same line.
(back)
Why is the time display on my graph wrong by x hours?
<Alex Le Dain alexATicon-tech.com.au>
(Timeless)
With internet technologies available for data acquisition it is important to have the capturing machine time stamp its data correctly regardless of it's location in the world. So, for example, if we place a Waveform Chart on our front panel and change the X axis Formatting, Format and Precision to Date & Time, we see that the X0 is set to 1/1/1904 with an offset equivalent in hours equal to your time zone offset from GMT. Thus to get the offset correct you need to correctly set your X0 value.
For example, using a Waveform Graph, you could correct your graphs using the Get Date/Time In Seconds VI for X0. The Get Date/Time In Seconds VI description says that this VI returns the seconds that have elapsed since 12:00am Friday 1st January 1904 Universal Time. Therefore literally 12:00am at 0 degrees longitude. Wiring the output from the Get Date/Time In Seconds VI to X0 will set your graph to show the current time on its X axis.
Does this GMT offset have other implications? If for example you thought of using the Get Date/Time In Seconds VI to test for time since midnight, you could think that dividing the output by 86400 (seconds in a day) and checking the remainder would give the seconds since midnight at your local time. It doesn't. What it effectively returns is the seconds since midnight minus your time zone offset. In other words LabVIEW makes the correct assumption about midnight at your locality as it occurred GMT offsets hours relative to midnight UST.
(back)
How do I change the front panel colour while a VI is running?
<Alex Le Dain alexATicon-tech.com.au>
(Timeless)
There is no direct way, however there are a couple of ways to do this programmatically. You can either place a large color box indicator covering the entire panel area and move it to the background. Changing the color of this indicator would look the same as changing the front panel color. Or, an alternative is to use a large boolean indicator and change it's colour via an atrribute node.
(back)
How do I set autoscaling for the maximum data point only?
<Greg McKaskle>
(Timeless)
Autoscaling affects both ends of the scale as well as the intermediate markers. It isn't possible to "auto" just one marker. You can write to an attribute node to set any of these individually; so you can turn off autoscaling, preview the data being wired to the chart and update the attributes when needed. If you have LV5.1, the picture control examples contain VIs that do autoscaling for graphs.
If your data is always above zero, then another trick would be to make a second plot that is always zero. You can even make the plot be the background color or transparent; so it won't even show up. This doesn't work if the idea is to ignore negative values when scaling, but can always be used to expand the scales.
(back)
Why does my output show -0.998 instead of -1?
<Scott Hannahs, sthATmagnet.fsu.edu>
(Timeless)
This is *not* a bug. It appears as a result of the limitation of finite computers. There is not now and never will be a fix. The main fix is to the programmer. As a caveat, do not ever, ever, ever compare real numbers. They are uncertain within the least significant bit.
These uncertainties arise in several situations. Another example where this must be taken into account is the output of both"Format & Strip" and "From Exponential/Fract/Eng"; enter a string of "0.1" and you get the number: 0.10000000000000000100. You cannot represent 0.1 as a finite binary string.
As to a wish for a finite conversion width, nope. The problem is that the conversion does have a finite width. It is that factor of 5 in base 10 numbers that makes a finite decimal be an infinite repeating binary string. You can represent all numbers that can be formed as sums of 1/2, 1/4, 1/8, 1/16, 1/32. Unfortunately 1/10 can only be approximated. The wish seems to indicate that the binary is converted to base 10 (with a finite conversion width) and then compared. Actually it is all compared in binary, when you display it, you can convert it to 10 digits or what ever you want.
In summary, any binary representation will be approximate. How approximate is based on the word length. It is that factor of 5 in base 10 numbers that gets us. It appears that you have 17 digits of accuracy which is about right for a double precision number. Extended have more, singles have less. That is mathematical reality. Computers are not idealized mathematical machines. If it was easy everyone would be an expert. Knowing how things are treated by the underlying hardware can keep one from having these problems.
(back)
So how do I compare real numbers then?
<Scott Hannahs, sthATmagnet.fsu.edu>
(Timeless)
What you need is a comparison that assumes that equal is the same as close enough. One way is to define an epsilon and check to make sure that your error is greater than that epsilon where epsilon is dependent on the type of number (single, double, extended) that you are using. For example to compare A greater than or equal to B (as double precision) you could use as your test.
A-B >= -1e-17*(A+B)/2
Or maybe 1e-16 to be safe. To be really careful use 2^-31 as your criterion. This handles the case where A is already 10^-31 in magnitude or when both variables are zero.
A simpler method is to multiply your numbers by 10 to make integers, round them and then compare. In fact you can multiply by whatever power of 10 desired.
(back)
Is there a NaN equivalent for integer data types?
<Paul Sullivan PaulATSULLutions.com, Uwe Frenz Uwe.frenzATgetemed.de>
(May 2002)
NaN is defined only for floating point numbers. In a U32 all the possible values are actual numbers and there is no place left for a special value that says there is nothing there. If you need an "empty" value in an integer data type you have to pick a value that never appears in your particular application (if there really is one) to serve as a flag. In other words there is no "empty value" in integer data types.
(back)

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top