Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

real time plot and vb.net

Hi,
I am using mesurement studio 7.0 and vb.net. I am trying to plot data with real time on x-axis.
I have used
XAxis1.Range = New Range(DateTime.Now, TimeSpan.FromSeconds(60))
XAxis1.MajorDivisions.LabelFormat = New FormatString(FormatStringMode.DateTime, "hh:mm:ss") in the form load. I am updating the graph data every second by using a timer. The time is changing on x-axis. But every time the application starts, its starting with 12:00:00 instead of current time. Can anyone send me an example on how to plot real time in vb.

Thanks for you help.
0 Kudos
Message 1 of 8
(14,981 Views)
I'm guessing what's happening is that the X axis is configured to auto scale and then you're plotting data that's out of the range that you configured, so the axis labels are adjusting accordingly. Are you using ScatterGraph or WaveformGraph? Also, could you post a snippet that demonstrates how you're plotting the data? Thanks.

- Elton
0 Kudos
Message 2 of 8
(14,977 Views)
I am using WaveformGraph. The mode I am using on
x-axis is AutoScaleExact and to plot data on y-axis I am using WaveformPlot.PlotYAppend(doubleValue). How do you plot current time on x-axis? I didn't change the default values for the WaveformGraph other than changing the mode for x-axis.

Thanks.
0 Kudos
Message 3 of 8
(14,975 Views)
The default start value of the plot is 0. Change this to reflect the currect time so that the axis will not change back to 12:00 everytime you start plotting.

Try adding this to the initilization section

WaveformPlot1.DefaultStart = CType(DataConverter.Convert(DateTime.Now, GetType(Double)), Double)

waveformplot1 is the name of your plot that exists on the graph. Its usually the default plot thats exists when you drop the graph on the form

Refer to the documentaion for DefaultStart for more information.

Hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 4 of 8
(14,975 Views)
It looks like the problem is that you're calling PlotYAppend(double) and you're not specifying the starting point, so the plot uses the value of the WaveformPlot.DefaultStart property for the start, which by default is 0.

You can resolve this by setting the WaveformPlot.DefaultStart and WaveformPlot.DefaultIncrement properties before you call PlotYAppend. The tricky part, though, is that those properties are double and you want to specify them as DateTime and TimeSpan respectively. The DateTime/double conversion factor that the Measurement Studio graphs use is a double value of 0.0 is equivalent to DateTime.MinValue and a double interval of 1.0 is equivalent to 1 second. The NationalInstruments.DataConverter class will convert from/to doub
le and DateTime and TimeSpan with this conversion factor. It looks like you're using VB.NET, so here's a VB.NET example that demonstrates this:

Dim start As DateTime = DateTime.Now
Dim increment As TimeSpan = TimeSpan.FromSeconds(60)

XAxis1.Range = New Range(start, increment)
XAxis1.MajorDivisions.LabelFormat = New FormatString(FormatStringMode.DateTime, "hh:mm:ss")

WaveformPlot1.DefaultStart = DirectCast(DataConverter.Convert(start, GetType(Double)), Double)
WaveformPlot1.DefaultIncrement = DirectCast(DataConverter.Convert(increment, GetType(Double)), Double)

Now when you call WaveformPlot.PlotYAppend, you should see the expected results.

- Elton
0 Kudos
Message 5 of 8
(14,977 Views)
Hi ,


I am using Measurement Studio - Version 7.1.0.306 in C#.I wanted to change the default increment value which could be done at design time , using Plot->Default Increment property. But, I wanted to achieve the same in run time.

I couldn't find WaveformPlot1.DefaultIncrement property in this version of Measurement Studio. As it appears from the previous reply of Elton, this was there in version 7.0

Any idea, how could i achieve this in version 7.1? There doesn't seem to be any property like WaveformPlot1.DefaultIncrement.

Best regards,
Manna

Message Edited by Manna on 06-15-2005 10:43 PM

K K Manna
Software Engineer,
Serba Dinamik Advance Engineering
0 Kudos
Message 6 of 8
(14,789 Views)
WaveformPlot does have a DefaultIncrement property in Measurement Studio 7.1. How are you determining that the property isn't there? Did you try to use it and then got a compiler error? Did you not see it in IntelliSense or the Measurement Studio reference?

- Elton
0 Kudos
Message 7 of 8
(14,772 Views)
Real-time plot? For VB or any other RAD / IDE / compiler for MS Windows?
Wisit h**p://www.oscilloscope-lib.com

Salute!

Message Edited by Michael_B_other on 01-27-2007 01:16 PM

0 Kudos
Message 8 of 8
(13,765 Views)