LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XY Graph Multi Plot with Absolute Time - No Plots Showing

Solved!
Go to solution

Hey All,

I have an application to read Torque, Angular Encoder Position, Load Cells, and Temperature. I am acquiring data continuously and planning to have a few graphs for different test modes. The first graph I tried was just Torque (Y axis) vs Encoder Angle (X axis), and this worked great with the Express XY Graph. I remember I had to wire 'False' to the Reset input to get this working. 

 

The next graph I need to plot is a multi plot, Torque on left Y axis, Angle on Right Y axis, and Time on the x-axis. I quickly realized that this is more complicated and creating this with the Express XY Graph VI posed some issues with converting my signals to the 'dynamic data type'.

 

I have been trying to work with the regular XY Graph and Chart VI's, so far I can set up the graph and the x-axis time window is working fine, but I can't seem to display the signals anymore. It is frustrating because just plotting torque vs angle was working great, but trying to plot them both on the y-axis vs time is causing me some headaches. I have attached my code, let me know if you have any ideas on what my problem may be?

 

Kind Regards, 

 

Douggle07

0 Kudos
Message 1 of 11
(5,479 Views)

Plotting data as a function of time, particularly when the time represents equally-spaced sampling times, is the task for which the chart was developed.  For the Chart, you don't need to express time explicitly -- its "ideal" input is the Waveform, a LabVIEW Cluster that appends the starting time (t0) and the sampling time (dt) to the array of data (Y).  If you look at the DAQmx Write functions on your Block Diagram, you can see that the second form of output is Waveform (Samples).  LabVIEW will plot the Y data, and will "create" the Time Axis from t0 and dt.

 

The Chart is designed to plot continuously, either scrolling (like a paper Strip Chart recorder) or working in "oscilloscope" mode, either overwriting the previous points with new points (sweep chart) or blanking the screen when a new set of points come in (scope chart).

 

I see you have some charts on your Block Diagram.  As I mentioned above, if you wire a Waveform (or a cluster of Waveforms to plot two data streams as the same function of time), the X (Time) scale will take care of itself, even if the Chart "scrolls off the end" (you can control how many points show up by adjusting the plot width).

 

Bob Schor

Message 2 of 11
(5,454 Views)

Thanks for the quick response Bob,

It seems like charts will keep things simple in the sense that I won't need to worry about converting signal data types and adding a subVI to run a graph like a chart.

 

With your advice, I now have my data displaying on the chart.

It seems like instead of 'Time' on the x-axis, the chart is actually putting the samples on the x axis since I am acquiring my signals with continous sampling. Other than just changing the Scaling Factor Multiplier to convert 'samples' to 'seconds' is there a better way to solve this? Below is a reference for the graph I am trying to achieve.

 

Douggle07_0-1576514476092.png

Below is the graph I have achieved so far from LabVIEW.

Douggle07_1-1576514574608.png

0 Kudos
Message 3 of 11
(5,422 Views)

Hi Douggle,

 


@Douggle07 wrote:

the chart is actually putting the samples on the x axis since I am acquiring my signals with continous sampling. Other than just changing the Scaling Factor Multiplier to convert 'samples' to 'seconds' is there a better way to solve this? Below is a reference for the graph I am trying to achieve.


Yes, the chart is "just" using the sample index for X axis.

But when you are using "continuous" readings from DAQmx then scaling is all you need to adapt the X axis to your needs.

 

Other options include using waveforms (with embedded timestamp data) and enable using those timestamp informations for X axis. Or use (waveform) graphs…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 11
(5,419 Views)

If you had attached your code, I would have been able to show you how to fix it the two ways that GerdW suggested.  First, as I mentioned, if you change your DAQmx function to output a Waveform (instead of just the Samples array), LabVIEW would see the time information that the Waveform carries and automatically format, It the Time axis accordingly.  The other thing you can do is to, yourself, modify the Chart X Scale properties.  

 

To get you started, I created a Waveform of 10 cycles of a 1 Hz waveform sampled at 100 Hz for 1001 points (so I'd get both the point at t = 0 and t = 10).  Two I plotted as Waveforms, and two as simply the data arrays.  The top plots are the "raw" data (default format of the Charts), while the bottom two have the Chart Properties altered.  For the Waveform Plot, I changed the Format to "Relative Time" (so it basically ignores the starting Date and Time, and says "We start at Time 0"), while for the "Y" Plot, I changed the Multiplier to 0.01 (as each data point is 0.01 sec).  Finally, so I could run it multiple times and have the Charts "start fresh", I also cleared the Chart History before doing the plots.

Chart Formatting.pngChart Formatting FP.png

Bob Schor

0 Kudos
Message 5 of 11
(5,314 Views)

Thanks for the responses again,

 

It seems that I'll need to plot my data with an XY Graph after all, just to implement the cursors for data analysis (I've heard there is no way to use cursors with LabVIEW charts...).

The cursors will be crucial for my clients since they can see transitions and critical points easily without digging through raw data post-test.

 

So it seems like things will get a little more complicated for me, from my understanding I'll need to do a Multi-plot XY Graph, 2 Y-axis (Torque vs Time, Angle vs Time) and 1 X-axis, Time. This XY Graph will need to act like a chart..

 

I'm still modifying the code from my first post, more or less.

 

0 Kudos
Message 6 of 11
(5,305 Views)

Been working at this for a bit now, I referenced an article https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P82GSAS&l=en-CA and implemented the use of shift registers to make the graph act as a chart. Below is a snippet of the area of code I'm editing.

 

Douggle07_1-1576600798160.png

 

I'm able to run this with no errors so far, but no signals are displayed on the Build XY Graph. I'm thinking I need to implement something to simulate a 'chart history', or another method to keep displaying the previous loop iterations. The Build XY Graph 'Reset' terminal, is set to false but it still doesn't change anything.

0 Kudos
Message 7 of 11
(5,292 Views)

The Build XY express VI would take care of the history keeping for you.

 

But there is a lot of other things going on that I think are interfering.  Like the Reshape array.  And building an array from two 1-D's to one 2-D when it probably should have the "concatenate mode" set.  If you attached an actual VI, we could play with it and make it work.

0 Kudos
Message 8 of 11
(5,289 Views)

Thanks, I attached the one I'm working with now. There shouldn't be any SubVI's yet so it should run ok...

0 Kudos
Message 9 of 11
(5,281 Views)
Solution
Accepted by topic author Douggle07

If you want a Waveform Graph instead of the Waveform Chart, then use ... the Waveform Graph, and forget (for functions of time) the X-Y Graph.  You can use the latter when you plot one function-of-time against another (e.g. Voltage vs Current).  The Waveform Graph and Waveform Chart both accept (more-or-less) the same types of input, so you can run my Example just by replacing Waveform Chart by Waveform Graph.  The X Scaling might be a little different, but you should be able to handle it now.

 

Bob Schor

Message 10 of 11
(5,265 Views)