Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Two edge separation, PCI-6602, Measurement Studio 8.0

Hi,
      I am trying to familiarize myself with the Measurement Studio NET classes. I will eventually be doing a two edge separation measurement from the output of two lasers to calculate velocity. For now I am simulating the start and stop with other counters. Ctr0 & Ctr1 are configured to generate a single pulse from a trigger on PFI33. Ctr0 has an initial delay of .0005 and Ctr1 an initial delay of .001. I am using the scb-68. I have two twisted pairs of wires :
start: (+ pin5 to pin66  ground pin39 to pin33)
stop: (+ pin9 to pin 67 ground pin42 to pin 68)
 
I have confirmed the two (50 microsecond) pulses with an oscilloscope.
 
Both the example code and the DAQ wizard indicate I only need the following commands

myTask3.CIChannels.CreateTwoEdgeSeparationChannel("Dev1/Ctr2", "", 0.0000001, 0.83886075, CITwoEdgeSeparationFirstEdge.Rising, CITwoEdgeSeparationSecondEdge.Rising, CITwoEdgeSeparationUnits.Seconds)

counterInReader =

New CounterReader(myTask3.Stream)

myTask3.Start()

However I am not getting my 500 microscond count. I have tried using other counters and get the same result. I have used CTR2 as pulse generator successfully. I have used two different SCB boards.

Any help would be appreciated,

Thanks Diane

 

 
 
0 Kudos
Message 1 of 5
(3,308 Views)
Diane,

It really looks like you are doing everything correctly here. What period are you actually measuring between the pulses? Are you able to successfully read other, perhaps slower, pulses? Just to make sure, you are creating rising edge pulses on your output counters, correct? What is the idle state of these counters? Are they left high by another operation, perchance? Please let me know.

Regards,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments
0 Kudos
Message 2 of 5
(3,288 Views)

Hi Ryan,

I

0 Kudos
Message 3 of 5
(3,279 Views)

Trying again.

Hi Ryan,

I just found my problem. I set up my two-edge detection task as threaded like I had seen in the pulse generation example code:

'Wait for the task to complete in another thread so the UI does not freeze

ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf WaitForTask))

When I commented this out and moved the CounterRead Statement from the WaitForTask subroutine to directly under MyTask.Start() everything worked fine.

Can some types of tasks be threaded but not others?

 

Thanks,Diane

 

0 Kudos
Message 4 of 5
(3,277 Views)

Me again.

I've got the threading working. I did not need the WaitUntilDone.

Thanks for answering my post

Diane

Private Sub WaitForTask(ByVal obj As Object)

Try

'myTask.WaitUntilDone(-1)

tinc = counterInReader.ReadSingleSampleDouble()

aquisitionDataTextBox.Text = tinc.ToString()

myTask2.Dispose()

Catch exception As DaqException

MessageBox.Show(exception.Message)

End Try

End Sub

 

0 Kudos
Message 5 of 5
(3,274 Views)