LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programming my PCI-6013 to include custom graphs and write to file capabilities

Beginer LabView user with a quick question......
Is there any way to create custom graphs in LabView? I know of the waveform charts and graphs that appear in the controls palette but I was looking to make something like a bar graph. Any information would be greatly appreciated.
0 Kudos
Message 1 of 10
(3,395 Views)
You can configure a waveform graph to be a column or bar graph. After placing the graph on the front panel, use the operator tool (looks like a hand) and click on the plot legend at the top right of the graph. This will give you the menu to configure the plot style.

To have a horizontal bar plot, use the XY graph.

See the attached example.

Christian L
NI Consulting Service
authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
Message 2 of 10
(3,395 Views)
Thank you Christian,
Your example was very helpful. A follow up question....is it possible to make the x-axis represent some other value instead of time? For instance, could I display the amplitude on the y-axis and on the x-axis have a variable number of signals? I want to show three voltage signals varying continuously, each signal being a bar on the graph (ie 3 signals - 3 bars)
0 Kudos
Message 3 of 10
(3,395 Views)
In general, use the XY graph, change it to a vertical bar plot, and reverse the order of the arrays on the Bundle function. You can turn off the X scale and add your own labels.

In specifics, you can do a lot of customization and dynamic configuration of the graphs using their different configuration and properties dialogs as well as the property node in the diagram. Using the property node you can change any of the graph properties at run time. See the attached VI for an example of using the property node.

Christian
authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
0 Kudos
Message 4 of 10
(3,395 Views)
Thank you again,
The bar graph with property nodes that you provided gave me the functionality I was looking for. However, I encountered some problems. When I wired my 3 dynamic data type signals to the "build array" VI and then into the bundle, the XY graph was no longer working. Error returned "You connected two terminals of different data types. Type of the source is a 1-D array of a cluster of 2 elements and Type of sink is 1-D array of a cluster of 2 elements." Any suggestions?
0 Kudos
Message 5 of 10
(3,395 Views)
My original example was not very clear as to the separation of source data and preparation of the data for the XY graph. In addition the preparation for the graph includes a small 'workaround' to make the data appear properly on the bar graph.

Workaround: I'm using 3 plots on the XY graph (one for each of your data values), but LabVIEW does not like to plot just one data point on a plot configured for a bar graph. So I add a second data point with value 0 to each of the three data values to generate 3 plots with two data points each.

The attached example separates the data source (in the red box - replace with your code) from the preparation of the data for the XY graph. You can see how each of your three values
is converted to a plot with 2 data points, each data point consisting of an X and Y value. The X value is the index counter of the loop and determines the location of the bar on the X axis.

Christian
authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
0 Kudos
Message 6 of 10
(3,395 Views)
I now understand what you mean by the seperation of the preparation of the data and the source of the data. However, I am still a little confused as to why I cannot get my data types to match up. I attached my VI so you could get a better look at it.
0 Kudos
Message 7 of 10
(3,395 Views)
The VI is having trouble with the dynamic data type from the DAQmx driver. In addition the For Loop is expecting an array of 3 data points, so that it can run three times and process each one individually.

In your VI you passed all three values into the loop individually rather than as an array. So I combined the three dynamic data values into an array and then converted them to a regular double data type. The loop is the same as my previous example.

See attached example.

Christian
authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
0 Kudos
Message 8 of 10
(3,395 Views)
I did not know about the "convert to double" VI. This will be very useful in the future. Nevertheless, when I run this graph I still only get an accurate display from Channel 1. Channel 2 and 3 do not move from 0. Any suggestions?
0 Kudos
Message 9 of 10
(3,395 Views)
It turns out the Convert to Double function does not work properly on the array of the dynamic data type (it only converts the first item). You need to convert each individual dynamic data item to a double separately, and then combine the three doubles into an array before passing them to the For loop.

Christian L
authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
0 Kudos
Message 10 of 10
(3,395 Views)