From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fixed number of points into an XY graph

Solved!
Go to solution

Hi!

 

I'm communicating remotely to a platform (via wifi) to receive its inclication delivered by an on-board inclinometer.

I cannot fully manage interval between 2 samples for various reasons that I can't change.

I was then thinking of using a timestamp at the moment I'm requested the info and then to plot the results in an XYgraph.

 

Problem is that I want mygraph to be sweeping smoothly like with a chart, the the XYgraph is displaying "one full array" at a time.

 

The solution I came with is the following

XYSmoothGraph.png

 

It work fine, I have almost the result I want except that it is a bit epileptic ... The graph doesn't move point by point but section by section, making it difficult to read in real time...

The points are being updated smoothly, but the first point to appear on the graph doesn't "stick" to the side of the graph, so the curve moves forward, suddenly slides to the left leaveag the right side empty, and then fill in the right side again.

VinnyLaTaupe_0-1597851262922.png

 

Do you have any idea how I can solve that ?

 

PS: Instead of using the array solution where I mage its lenght by myself, I tried using a lossy engueue element, but then the question came on "how to put that element in an array ..." so in the end the problem was the same.

 

 

Thanks in advance for your help.

Vinny.

 

 

0 Kudos
Message 1 of 16
(2,082 Views)

You'll probably want to stop using the Auto Scale functionality of the graph.  If you right-click it on the front panel and look through the menus, there should be a checked entry for Auto Scale X to turn off.

 

Then, right-click the graph, and create a property node.  You'll find a section for X scale range min and max.  Set those to the min and max you want actually visible at any given time.

0 Kudos
Message 2 of 16
(2,048 Views)

Auto scale should be fine.

But you will want to go to the Y-scale properties in the right-click menu and uncheck "Loose Fit".

 

One thing that concerns me is you are trying to update the graph in a loop with a 1 msec wait.  That means LabVIEW is trying for 1000 updates per second.  You can't even see that.  I would try updating about 20 samples at a time before sending to the graph would would make it a palatable 50 Hz update rate.

 

 

0 Kudos
Message 3 of 16
(2,041 Views)

@Kyle97330 wrote:

You'll probably want to stop using the Auto Scale functionality of the graph.  If you right-click it on the front panel and look through the menus, there should be a checked entry for Auto Scale X to turn off.

 

Then, right-click the graph, and create a property node.  You'll find a section for X scale range min and max.  Set those to the min and max you want actually visible at any given time.


Hmmm if I uncheck that, my curve goes away given that my X axis is the absolute time.

0 Kudos
Message 4 of 16
(2,007 Views)

@RavensFan wrote:

Auto scale should be fine.

But you will want to go to the Y-scale properties in the right-click menu and uncheck "Loose Fit".

 

One thing that concerns me is you are trying to update the graph in a loop with a 1 msec wait.  That means LabVIEW is trying for 1000 updates per second.  You can't even see that.  I would try updating about 20 samples at a time before sending to the graph would would make it a palatable 50 Hz update rate.

 

 


What does "Loose Fit" do ?

 

So for the 1ms I was just playing around, actually as the sine function gets the iteration as input, it changes my frequency.

If I understand what you mean:

--> Get 20 samples

--> add them to the array in a lossy way (if the array has a size of 1000 and already has 990 samples in it, it will loose 10 samples "below")

--> display the array

 

Is that it?

0 Kudos
Message 5 of 16
(2,005 Views)

Loose Fit off means your X-scale and Y-scale are set so the max and min range are set to your max and min values.

With Loose Fit on, it takes your Max and Min values, but rounds them to something a little nicer.  That can help prevent from having constantly jumping scales, and also give you a nice round number for the origin.

 

But if you have loose fit on for an x-scale you want to continuously scroll, what happens is the x-scale minimum won't change on every point as data gets discarded, but whenever LabVIEW decides that the minimum x value should round to a new number.

 


 

So for the 1ms I was just playing around, actually as the sine function gets the iteration as input, it changes my frequency.

If I understand what you mean:

--> Get 20 samples

--> add them to the array in a lossy way (if the array has a size of 1000 and already has 990 samples in it, it will lose 10 samples "below")

--> display the array

 

Is that it?


Correct.  And next time around your array will have 1000, you will add 20 and discard the oldest 20.

With loose fit turned off, and the graph updating 50 times per second rather than 1000 times per second, it should look like a smooth scroll and won't be killing the user interface thread doing graphic updates that really can't be seen by the user.

Message 6 of 16
(1,993 Views)

Hi!

After a few days off, I'm back on this 🙂

 

Thanks to your advice I've figured out something that working smoothly, big thanks for that.

However, I'm still having troubles on something weird, I attach a snippet below for reference:

Basically I want to display a 10seconds graph. At first I thought it was working well, the graph is building itself and being displayed nicely. But after a few seconds when I hit the "Time to display" I want (e.g. 10 seconds), while the array size doesn't change, the time displayed keep growing... for some reasons the values seem to not be deleted as fast as they get in the array ...

 

Do you have any idea that could explain this ?

Thanks,

Vinny.

 

VinnyLaTaupe_0-1598341585853.png

 

 

XY Graph sweeping.png

0 Kudos
Message 7 of 16
(1,972 Views)

Hi Vinny,

 


@VinnyAstro wrote:

Basically I want to display a 10seconds graph. At first I thought it was working well, the graph is building itself and being displayed nicely. But after a few seconds when I hit the "Time to display" I want (e.g. 10 seconds), while the array size doesn't change, the time displayed keep growing...


Surely the "time displayed" keeps growing: you calculate that value by subtracting start time from current time. And that difference is used as X axis value of your XY graph!

What else do you expect?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 16
(1,966 Views)

@GerdW wrote:

Hi Vinny,

Surely the "time displayed" keeps growing: you calculate that value by subtracting start time from current time. And that difference is used as X axis value of your XY graph!

What else do you expect?


I don't think that's what I do actually 🤔

The variable "Time Displayed" is obtained by substracting the very last value of "Relative time" in the For loop with the first value in the built array over time. The latter is supposed to be deleted and replaced by the upper values in the table over time due to the True Case Structure (being true when the array is full)

This case does the following:

-Take the oversized array (in my example 1000 is the limit, and it just received 20points from previous measurement, so current size is 1020)

  Oldest value is index 0, newest is 1019

-Extract subarray from index "current-max size" = 19

-Place this sub-array in the previous array at position 0

-Delete the excess at the end of the array.

 

Then add the new values and display it.

So I'm not substracting Current time from start time, but current time from index 0 Value in my table.

Also in the screen shot of my front panel you can see that the first value in the X axis is 12,1516 which is not start time.

0 Kudos
Message 9 of 16
(1,961 Views)
Solution
Accepted by topic author VinnyAstro

Hi Vinny,

 

you are doing some Rube-Goldberg array operations in your code, like using InsertIntoArray when you should use BuildArray:

 


@VinnyAstro wrote:

This case does the following:

-Take the oversized array (in my example 1000 is the limit, and it just received 20points from previous measurement, so current size is 1020)

  Oldest value is index 0, newest is 1019

-Extract subarray from index "current-max size" = 19

-Place this sub-array in the previous array at position 0

-Delete the excess at the end of the array.

Then add the new values and display it.


Why do you need to shift the array data as you did? Simply use the "newest data" instead of shifting it inside the array and deleting "excess data"!

And then you don't "add" (aka "append") new data, but you did "insert" data at the end - just Rube-Goldberg!

 


@VinnyAstro wrote:
So I'm not substracting Current time from start time, but current time from index 0 Value in my table.

Also in the screen shot of my front panel you can see that the first value in the X axis is 12,1516 which is not start time.


You do subtract start time from current time in the FOR loop. This difference is used for X axis values…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 16
(1,957 Views)