LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting the required Time Axis correctly

Hello,

I am making a PID Control based program on LabVIEW. I want to obtain graph like the one attached here under the name "PID Graph" i.e. I want the initial time to be fixed at 0 and the graph to keep moving ahead in seconds and also remain on the same frame fully.

I tried all three forms - Sweep, Strip and Scope and also tried to change settings of X Axis, but I'm unable to get what I require.

In my case I'm loosing the previous values and graph is moving ahead.

As it moves ahead in time, I want it to shrink the previous values on x axis, adjust the graph, but remain in the same frame. Please refer to the images below.

Any suggestions would be highly appreciated.

Download All
0 Kudos
Message 1 of 7
(826 Views)

We can give more specific advice if you attach your VI.

 

  • Your PID graph has no x-axis.
  • You can change the marker style in the properties and t0 and dt for the x axis.
  • A chart has a limited history buffer (1k by default), so if you run out, the oldest values get discarded.
  • To see all points, you should enable autoscaling for the x-axis.
  • Maybe a graph would be more suitable than a chart. Do you know the difference?
0 Kudos
Message 2 of 7
(819 Views)

Hi divb,

 


@divb wrote:

I want to obtain graph like the one attached here under the name "PID Graph"

 

I tried all three forms - Sweep, Strip and Scope and also tried to change settings of X Axis, but I'm unable to get what I require.


It seems you make something wrong - but you don't attach any code so we cannot suggest improvements for your code!

Another problem: even though you talk about "graphs" it seems you use a chart (sweep/stripe/scope) instead. Possible suggestions also depend on this specific element in your code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 7
(817 Views)

Thank you for your suggestions. Please find attached below my code and help me set the settings of chart such that:

1) My x axis initial value is fixed at 0 (One suggestion was autoscaling, but in that initial value is getting lost)

2) The chart should move forward with time but by being on the same frame always, so that I can see all plotted y coordinates from starting(at t=0) till the end(till I stop the VI), at once. (by saying graph I meant the graphical line that gets plotted, apologies for the confusion)

 

I want to achieve the typical PID graph which is like the one attached below. Any help would be highly appreciated.

Thank You.

Download All
0 Kudos
Message 4 of 7
(747 Views)

The initial value is getting lost once you acquire more than 1024 points (the current chart history size). Do you know how many points total you will acquire?

While you could just increase the history size, it still does not seem right to use a chart.

 

A simple solution would be to use a graph and collect the data in an array. As has been mentioned long ago, use a graph, not a chart! Now you also have full access to the data in case you e.g. want to save or process it.

 

Here's a very simple draft how to accumulate two scalars in a 2D array for graphing. (Of course you need a bit more code, e.g. a state to clear the data, etc. If you know the exact final number of points before the code starts, more efficient code is possible).

 

 

altenbach_0-1691337963517.png

 

0 Kudos
Message 5 of 7
(734 Views)

Got it, thank you for your suggestion.

0 Kudos
Message 6 of 7
(678 Views)

Do you understand the difference between a Chart and a Graph?  A Chart has a fixed-length internal "buffer" which holds the "last N points" you gave it, and can be set to plot a contiguous subset of these points.  So if you are acquiring one point per second, for the first 10 seconds you can plot points 0 .. 9 across the whole Chart, then when point 10 comes in, you can plot 0 .. 19 (so the plot "autoshrinks" and keeps growing from the right end).  This process can continue until N points have been added, at which point the buffer is full, so the chart simply keeps plotting the last N points (and the plot moves slowly to the left after "growing to the right" previously).

 

A Graph, on the other hand, is always plotted "all at once" (instead of "one, or a few, points at a time").  This means that all of the plotted data needs to be in memory, and it all gets plotted (unless you write code that says, say, "plot every other point").  Your choice of a Graph or a Chart depends on the (time) bounds of the data you want to plot -- if it is a "finite response" (such as an impulse response), a Chart might be the best.  If it is a time-limited response where you want to specify a variable "start" and "end" time for the plot, especially if this involves several thousand (or more!) samples, a Graph may be the answer (but you'll need access to all the data when you make the Graph).

 

Which scenario best fits what you are trying to accomplish?

 

Bob Schor 

0 Kudos
Message 7 of 7
(668 Views)