LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

programmatically changing chart history length

I'm creating a VI where the user can choose the data sample rate via the wait(ms) used in a while loop. However changing the sample rate effects the time length being displayed on the chart. This is dependent on the chart history length, originally I thought I could just change this programmatically, but the history length doesn't appear on the property node.

I've had a look at the advice in the ni support section:
http://digital.ni.com/public.nsf/allkb/E9784F413A2269E086256F3A0064C8BB

This method seems a bit messy (especially when I'll be doing this for a number of charts), although I couldn't open the example as its v7.1 and I have v7.0.

Is there anything I can do?

Help would be appreciated (deadlines approaching)
0 Kudos
Message 1 of 8
(6,836 Views)
Hi Chris,

take a look at the code (I attached the LV 7.0 version). It's not that messy at all.

Einstein
Message 2 of 8
(6,825 Views)
I'm hoping you know this, but just to make sure:
The main thing you'll need to change if change the update rate of the chart is the Multiplier property. Basically, it just determines the gap (in seconds) between each 2 points, so if your loop has a 100 ms wait (BTW, wait until next ms multiple is better for this), you should wire 0.1 as a multiplier for the X scale.

___________________
Try to take over the world!
0 Kudos
Message 3 of 8
(6,820 Views)
Thanks for the help and the version change.

I did know about the multiplier, that's how I'm setting the time axis. I've had a quick go at changing the example to be more like my problem.

I'm just a bit worried that doing this to all 30ish charts will slow the loop execution (in the real program acquired data is fed to a parallel loop, then to graphs via a queue). It would have been nice just to set a constant property outside to the loop rather than playing with lots of large arrays while the loop is running.

Sorry if I sound a bit pessimistic, but I thought this would be a nice quick job to do.

Any ideas (I know the trial I did doesn't quite work)
0 Kudos
Message 4 of 8
(6,815 Views)
sorry forgot the attachment
0 Kudos
Message 5 of 8
(6,814 Views)
I only realized what you want now - You want the amount of seconds (meaning number of points) displayed on the chart to change according to time. In that case, I don't think there's any other way to control this other than simulating a FIFO. Keeping a 30x100 array in a shift register shouldn't be a problem for LV. BTW, for something like this, you might prefer using an XY graph, because you can use an array instead of a property, which does cost you in performance. Also, you should move the multiplier property to a UI loop with an event structure. You should only call it when you change the value of the sample rate.

Message Edited by tst on 03-16-2005 03:39 PM


___________________
Try to take over the world!
0 Kudos
Message 6 of 8
(6,809 Views)
I'm not sure I quite understand all of that. I what the user to be able to select a sample rate, and also select visible graph time period e.g. 50 samples per second and 20 seconds, therefore the chart history length should be 1000. I would prefer not to change the format of the graph at this stage. I haven't manage to get my trial I posted to work, the waveform seems ok, but the time axis is fix from 0 to chart history length? Can this method work?
0 Kudos
Message 7 of 8
(6,792 Views)
The entire point of using a chart is that you update only the last value, so there is no point in writing the history data every loop. For that you can use a graph, which will allow you to do this without using a property node.
The history length is not supposed to control how much data is currently displayed on the screen, but how many points are kept in the buffer, so you can scroll back and see them. When you change the length of the history data array, the chart doesn't seem to like it. It starts acting a bit crazy. Also, keep in mind that there is no point in displaying 1000 points if your chart is 600 pixels wide.
There are problems with what you want to do, like if you add points, where do the extra points come from, or since a chart uses a constant multiplier, what happens to the old data when you change it and so on.
I've modified your example slightly, so that it doesn't write to the property every time and so it handles the enlarging the history buffer case, but it's still buggy and needs more work.
The main problem is that the History property doesn't change the chart length. If I understood you correctly, and you want to constantly display the last X seconds, I still think your only viable option is using a graph. The transition should be fairly simple and if you use a shift register it can handle it.

___________________
Try to take over the world!
0 Kudos
Message 8 of 8
(6,767 Views)