Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Scattergraoh stops after some time

Solved!
Go to solution

Hi,

I am using scatter graph in my VB .NET program. I am collecting data from 3 channels on a PCI 6120 and then data is plotted on a waveformgraph or a scattergraph, depending upon the users choice. My problem is that when I use scattergraph, data is plotted a few times but then it stops after a few aqcuisitons. Please see the attached image for the error. I am not sure why does this happen. However, waveformgraph works fine for unlimited time.

 Do I need to change some property of the scattergraph?

 

Thank you in anticipation.

 

Regards

Vijay

0 Kudos
Message 1 of 14
(5,916 Views)

Hi Vijay,

 

According to MSDN, this exception occurs due to:

 

A StackOverflowException exception is thrown when the execution stack overflows by having too many nested method calls.


From the code snippet, I do not see where you could have an infinite loop.  Could you provide a bit more information about your application?  How fast are you sampling and bringing in data from the PCI-6120?  A code snippet with comments could be helpful as well.  I'd especially be interested in seeing the code where you are bringing in data to the waveformgraph, and comparing with how you bring the data to the scattergraph.  Did you change any of the default properties of the scattergraph?  Also, do you absolutely require the functionality of a scattergraph over the standard waveformgraph?

Rod T.
0 Kudos
Message 2 of 14
(5,883 Views)

Hello Rod,

Thank you for your reply. I am using the scattergraph or waveformgraph while I am not saving data from the acquisiton card. I need to look at the form the signal before I can start saving the it. And thus I need scattergraph. Here is my code. grp1Dgraph refers to the groupBox containing waveformgraphs while grp2Dgraphs refers to the scattergraphs. I din't change any property in teh scattergraphs (except their names). Earlier I had the evaluation version for MStudio 8.5 and I upgraded to the full paid version 8.6 a few days back. I never had same problem with evaluation version. 

 

Please have a look at my code, and let me know what could be done about the problem.

 

Thank you in anticipation.

 

Regards

Vijay

 

P.S. I am using VB .NET 2008 express edition, MStudio 8.8 and Ni DAQmx 8.8.

 

 Public Sub IdleGraphSet(ByVal idFreq As Integer, ByVal idSampNum As Integer)
        Try
            IdleFreq = 1000000
            Idle2Show = 10000
            If IdleRunningTask Is Nothing Then
                Try
                    IdleTask = New Task()
                    IdleTask.AIChannels.CreateVoltageChannel("Dev2/ai1", "Channel1", CType(-1, AITerminalConfiguration), -10, 10, AIVoltageUnits.Volts)
                    IdleTask.AIChannels.CreateVoltageChannel("Dev2/ai2", "Channel2", CType(-1, AITerminalConfiguration), -10, 10, AIVoltageUnits.Volts)
                    IdleTask.AIChannels.CreateVoltageChannel("Dev2/ai3", "Channel3", CType(-1, AITerminalConfiguration), -10, 10, AIVoltageUnits.Volts)
                    IdleTask.Timing.ConfigureSampleClock("", IdleFreq, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, Idle2Show)
                    IdleTask.Control(TaskAction.Verify)
                    IdleRunningTask = IdleTask

                    IdleInReader = New AnalogMultiChannelReader(IdleTask.Stream)
                    IdleInReader.SynchronizeCallbacks = True
                    IdleCallBack = New AsyncCallback(AddressOf IdleInCallback)
                    IdleTask.Stream.ReadOverwriteMode = ReadOverwriteMode.OverwriteUnreadSamples
                    IdleTask.Stream.ReadRelativeTo = ReadRelativeTo.MostRecentSample
                    IdleInReader.BeginReadMultiSample(Idle2Show, IdleCallBack, IdleTask)
                Catch ex As Exception
                    MessageBox.Show("Error Graph: " & ex.Message)
                    IdleRunningTask = Nothing
                    IdleTask.Dispose()
                End Try
            End If
        Catch ex As Exception

        End Try
    End Sub


    Private Sub IdleInCallback(ByVal ar As IAsyncResult)
        Try
            If IdleRunningTask Is ar.AsyncState Then
                Dim data As Double(,) = IdleInReader.EndReadMultiSample(ar)
                Dim data2graph1(UBound(data, 2)) As Double
                Dim data2graph2(UBound(data, 2)) As Double
                Dim data2graph3(UBound(data, 2)) As Double
                Dim i As Integer
                For i = LBound(data, 2) To UBound(data, 2)
                    data2graph1(i) = data(0, i)
                    data2graph2(i) = data(1, i)
                    data2graph3(i) = data(2, i)
                Next
                If grp1Dgraphs.Enabled Then
                    Graph1.PlotY(data2graph1)
                    Graph2.PlotY(data2graph2)
                    Graph3.PlotY(data2graph3)
                ElseIf grp2Dgraphs.Enabled Then
                    GraphXY_1.PlotXY(data2graph1, data2graph2)
                    GraphXZ_1.PlotXY(data2graph1, data2graph3)
                    GraphYZ_1.PlotXY(data2graph2, data2graph3)
                End If
                IdleInReader.BeginReadMultiSample(Idle2Show, IdleCallBack, IdleTask)
                Application.DoEvents()
            End If
        Catch ex As Exception
            MessageBox.Show("Error Graph Plot: " & ex.Message)
            IdleRunningTask = Nothing
            IdleTask.Dispose()
        End Try
    End Sub
 

0 Kudos
Message 3 of 14
(5,881 Views)

Vijay,

 

You said you did not see this error when using the evaluation version. Are you using the exact same code as you were before? Also, after you upgraded do you get the same error still only for the scattergraph and not the waveform? I do not believe any changes to the scattergraph were made between Measurement Studio 8.5 and 8.6.

0 Kudos
Message 4 of 14
(5,850 Views)

Hello  Corbin,

Yeah, I am using the same code. With the eval copy my code ran for about 5 mins and then stopped. But now with the full version, scatter graph works only for a minute or so and then stops. Initially also I was working at the rate of 1MHz, which is a must for our experiment. I never had any problem with the waveformgraph. I am not sure what went wrong with the scattergraph.

 

Regards

Vijay 

0 Kudos
Message 5 of 14
(5,848 Views)

Hello Vijay,

 

Do you experience the same behavior at rates below the 1 MHz floor for your experience?  That is, if you try a much slower rate, do you still generate the same exception?  Thanks in advance for this information!

0 Kudos
Message 6 of 14
(5,816 Views)

Matt,

Sorry for my delayed reply. I do not see these problems while working at frequency of 10^5 Hz. It only occurs when the rate is 10^6 and I am plotting a large number of points, Say 10^4 

 

Regards

Vijay 

0 Kudos
Message 7 of 14
(5,772 Views)

Hello again Vijay!

 

This is definitely strange behavior, since we should be able to handle this much data.  I am going to set up some hardware and try this out myself.  I know that you had mentioned you are acquiring from 3 channels.  I would be interested to see if you still get the exception when acquiring from only 1 channel.  Also, could you post back with your computer specifications? 

Rod T.
0 Kudos
Message 8 of 14
(5,743 Views)

Dear Rod T.,

 

Hello and wish you a very Happy New Year.

 

I don't see this problem with one channel for short intervals, but that does happen if I run my programm for a very long interval (about 1 hour). Here are the specifications of my machine: XP Windows with SP3, Intel Core 2 Duo, 2.40GHz Processor and 2GB RAM. And we are using a PCI 6120 card with the BNC 2100 board.

 

Regards

Vijay

0 Kudos
Message 9 of 14
(5,569 Views)

Hi vjuno,

Thank you for the New Year wishes!

 

I modified one of our DAQmx examples to plot 2 channels on a ScatterGraph, and was unable to reproduce the exception.  I used a 6132 acquiring at 1 MHz per channel, but the card shouldn't come into play here.  Take a look at the attached solution, and do a test run on your hardware. 

Rod T.
0 Kudos
Message 10 of 14
(5,511 Views)