LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting Voltage Reading over Distance

Solved!
Go to solution

Hello,

 

I'm attempting to plot the readings of a load cell voltage (for tension) over the displacement from the origin of a linear actuator on the same axis.  I simply want the readings of the two while loops to input into a chart and plot the correlation between them.  Seems simple enough, but whatever I try, I cannot seem to have the chart plot anything.  When I run the program in highlight execution, it seems to stop at the end of the while loop and never feed any data into the XY chart.  I'm sure it's just some rookie mistake that I have with data type, or some failure of understanding how the while loop needs to actually get data to the next step. 

 

Please let me know what I can do.

 

Attached is a picture of the VI, and the VI itself.

 

Thanks,

James

Download All
0 Kudos
Message 1 of 10
(3,881 Views)

Just at first glance, you have a problem where the data leaves the upper while loop.

 

You're taking one data point and putting it into a build array.  This results in an array of length 1... which makes a very boring looking graph.  You then pass this one point out of the array.

 

What you want to do is collect a whole bunch of points, make them into a long array and then pass this out to the graph.  This is done by making the tunnel index. (Right click and select "Enable Indexing."

 

Auto-indexing.jpg

0 Kudos
Message 2 of 10
(3,877 Views)

You have a similar situation with the lower while loop also.

 

On top of that, there are a whole bunch of other issues.  First, I think you need to find out why the while loop is stopping.  You're using a error status to stop the upper loop, so you should put an indicator on it to find out why you're getting an error and try to fix that.  (Also, your "Or False" is meaningless, so you can just delete that.)

 

Generally, I would just use a "Stop" button to end the loop.

 

The way you currently have it set up, you have strain on the X-axis and Stress on the Y-axis.  That would work okay, but you're generating this data in two separate (and independent) loops.  The problem here is that you can't be sure that the loops are running in the same speed, or stopping at the same time, therefore you might have different numbers of data points for stress than for strain and you can't be sure they'll line up with each other.

 

The solution to that is to put them in the same loop so that they run at the same time and stay synchronized. 

 

In the following example, I've moved the load cell into the main loop.  I have it collect 10 data points at a time, then average these into one data point per loop and send these out as the Y-array.  I'm not sure this will solve all of your problems, but it's a step in the right direction.

Message 3 of 10
(3,873 Views)

Great!  I did have a problem of having them all in the same loop before since it would cause the linear actuator to run slower than normal.  The averaging of several points fixes that one.

 

You mentioned right clicking to enable indexing?  But I'm not sure you mentioned what I need to right click...

 

It's still only collecting one point of data, so maybe that indexing will fix that.

 

EDIT: Ahh I see what you meant.. it seems that it's already enabled in the VI you wrote... I guess that isn't the complete solution.  I'm not quite understanding why even when I run it in highlight execution, nothing seems to come out of the while loop...

0 Kudos
Message 4 of 10
(3,869 Views)

Now I'm guessing that it has something to do with the fact that the second counter is collecting so much which is causing a mismatch in the amount of data... can anyone let me know if I'm right here?

 

The problem is that I don't have any way of figuring out what the current displacement is in the linear actuator without using time elapsed.  And in my case, time elapsed is providing too many numbers which go into the "distance from origin" calculation.  What should I use to make that line up with the amount coming out of the average voltage reading?

 

 

 

0 Kudos
Message 5 of 10
(3,864 Views)

Right-click the tunnel where the number leaves the loop.  If it's a solid color, that means only one value (the most recent) moves out.  If it's bracketed, with a white center, it means that it collects one value for each time the loop runs... and all values leave as an array.

0 Kudos
Message 6 of 10
(3,863 Views)
Solution
Accepted by topic author jpturne

You need to figure out why the While Loop is coming to an end.  The way you have it set up, it will run until an error is encountered.

 

If it's stopping by itself, it means you're getting an error from somewhere in your DAQ sequence.  You should put an indicator on those VIs to figure out who is giving the error and why.

 

Once you figure that out, it should run forevever without giving an error.  That means it will run forever without stopping the loop, so you'll never get any data out.  You need a better way to stop the loop.  My suggestion would be a STOP button wired to the While Loop stop condition.

 

Message 7 of 10
(3,848 Views)

Awesome!  Ok, so I did what you suggested and it works fine.  There is a stop button for the while loop that plots the data when the button is pressed.

 

My next "issue" is that I'd like this data to plot in real time.  Does this require a complicated overhaul?  What's the best way to go about having it plot the data in real time, and is that even possible with this configuration?

0 Kudos
Message 8 of 10
(3,830 Views)

To get it to update while running, just move the graph indicator inside the loop.  That way, it gets updated with every loop instead of just when the loop completes.

 

can you post your vi?

0 Kudos
Message 9 of 10
(3,826 Views)

Certainly.. it's just the one you posted with some minor adjustments.

 

I've got it figured out, though.  I just did what you suggested and it works so far.

 

Thanks for the help LandBelenky

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