PCSGU250: Can´t read DataBuffer with the first try

Hi there,

I developed a small program for the PCSGU250 that shows me the waves I set in the generator. Problem is that if I tell the sub chbRun_Checkchanged to show me the wave it doesn´t work with the first try. Although it activates the button in the PC2000Lab.exe, it doesn´t seem to get the data out of the buffer. The second time I start the Sub it works just fine.

[code]Private Sub chbRun_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chbRun.CheckedChanged

    Dim s, t, u As New Series
    Dim i As Double

    s.Name = "Ch1"
    t.Name = "Ch2"
    u.Name = "Kennlinie"

    If chbRun.Checked = True Then
        RunOn(1)

        'delete chart and declare new Data Series
        chrOszi.Series.Clear()
        chr3.Series.Clear()
        chrOszi.ResetAutoValues()
        chr3.ResetAutoValues()

        'read Datapoints out of databuffer
        ReadCh1(DataBuffer1(0))
        ReadCh2(DataBuffer2(0))

        'read out the data of buffer1 and buffer2
        For i = 0 To 4095

             'add points of data to series
             s.Points.AddXY(i, CDbl(DataBuffer1(i + 3)))
             t.Points.AddXY(i, CDbl(DataBuffer2(i + 3)))
             u.Points.AddXY(CDbl(DataBuffer2(i + 3)), CDbl(DataBuffer1(i + 3)))
        Next
        s.ChartType = SeriesChartType.Line
        t.ChartType = SeriesChartType.Line
        u.ChartType = SeriesChartType.Line

        'Adds the DataSeries to chart
        chrOszi.Series.Add(s)
        chrOszi.Series.Add(t)
        chr3.Series.Add(u)
    Else
        RunOn(0)
    End If
End Sub[/code]

I´m using MS Visual Basic Express 2010, if that´s of any relevance.
Well thanks for reading so far, and hopefully I shared enough information with you to solve this problem.

with kind regards
Jan

The DLL function RunOn(1) just starts the data acquisition process.
It doesn’t wait until the data acquisition is complete and the new data is ready to read from the oscilloscope.

You can use the function DataReady() to check when the new data is available from the oscilloscope.

You may add this wait loop to your code just after the RunOn(1):

Do Loop Until DataReady()

If the trigger is on and no triggering event occurs, your software may “hang” for long period.
Your original solution is more “safe”. The only drawback is that you need first to click the button twice.
First click starts the acquisition and the second click reads the data and starts new acquisition.

Thank you for the quick answer. As usual your service in this forum is very good.

The loop is doing just fine and it doesn´t takes that long. I just have to figure out if that answers the purpose of my program.
I´ll be back if any further questions come up.