Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set internal signal for period measurement with PCI-6601

Hi,

I'm trying to program (Visual Basic .NET) a semiperiod measurement with PCI-6601 to measure time.  Should I connect some terminal to some other explicitly to accomplish this task? Or what is wrong with my code?


MyTask = New Task()
MyCallBack = New AsyncCallback(AddressOf CounterInCallback)
MyTask.Stream.Timeout = 15

MyTask.CIChannels.CreateSemiPeriodChannel("Dev1/ctr0", "", 0.0001, 4.01, CISemiPeriodUnits.Seconds)
MyTask.Timing.ConfigureImplicit(SampleQuantityMode.FiniteSamples)

CTR = New CounterReader(MyTask.Stream)
CTR.BeginReadMultiSampleDouble(1, MyCallBack, Nothing)
'  I tried something like this;
' DaqSystem.Local.ConnectTerminals("/Dev1/Ctr1Out", "/Dev1/Ctr0Gate")

Private Sub CounterInCallback(ByVal ar As IAsyncResult)
        Try
            Dim d = DateAndTime.Timer
                While d + 4 > DateAndTime.Timer
         ‘ Odotetaan neljä sekuntia
            End While

                Dim values() As Double = CTR.EndReadMultiSampleDouble(ar)

        Catch exception As DaqException

            MyTask.Dispose()
                MessageBox.Show(exception.Message)

        End Try

End Sub

Running this code produces an error which says "Measurements: Some or all of the samples requested have not yet been acquired (and so on) “.

Any suggestions what might be the problem, if the terminal connections are not the case?

Thanks for listening,
 Teemu

0 Kudos
Message 1 of 2
(3,632 Views)
I noticed there's something strange in the example code, so here's a correction.


MyTask = New Task()
MyCallBack = New AsyncCallback(AddressOf CounterInCallback)
MyTask.Stream.Timeout = 15

MyTask.CIChannels.CreateSemiPeriodChannel("Dev1/ctr0", "", 0.0001, 4.01, CISemiPeriodUnits.Seconds)
MyTask.Timing.ConfigureImplicit(SampleQuantityMode.FiniteSamples)

'  Here I tried to connect some terminals:
' DaqSystem.Local.ConnectTerminals("/Dev1/Ctr1Out", "/Dev1/Ctr0Gate")

CTR = New CounterReader(MyTask.Stream)
CTR.BeginReadMultiSampleDouble(1, MyCallBack, Nothing)

Private Sub CounterInCallback(ByVal ar As IAsyncResult)
        Try
            Dim d = DateAndTime.Timer
                While d + 4 > DateAndTime.Timer
         ‘ This loop is for four seconds delay
            End While

                Dim values() As Double = CTR.EndReadMultiSampleDouble(ar)

        Catch exception As DaqException

            MyTask.Dispose()
                MessageBox.Show(exception.Message)

        End Try

End Sub


Thanks!
0 Kudos
Message 2 of 2
(3,618 Views)