Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-DAQmx Counter Frequency Measurement

I need to measure the number of pulses obtained within a time period (3 secs).
So if i use channel 0 to generate a gate pulse for channel 1 how can i do other other things while waiting for my 3 seconds to be up ?
Has anyone got any VB6 code to do it. At the moment i have a task in Max to generate the pulse train with two leading edges every 3 secs.
I use this output to gate the second counter channel. I then have a task created in VB to count edges. Then i would like
DAQmxReadCounterU32 to NOT hold up execution while reading two samples.
 
something like......
 
 
while waiting for two samples
   
loop
 
 
0 Kudos
Message 1 of 11
(5,830 Views)

Hi Mattyd,

The command is going to take the 3s to execute regardless of how you try to work around it, because it is waiting for an operation to complete.  That means that if you want to run something else at the same time then you will need to create a separate thread and have that running in parallel to the DAQmx code. 

If you were using LabVIEW I could show you in a heartbeat; unfortunately, I'm not as familiar with multithreading in VB.

0 Kudos
Message 2 of 11
(5,806 Views)

Hi Otis,

      surely there is a way to check for data in the buffer without holding up a thread.

I cant belive the lack of support for VB.

Personally i dont use VB but on this job i have to. I get the same response from NI in Australia.

I wish they did not provide what they cannot support. 

Whats the deal with Starting & Stopping tasks anyway.

If i wnat to read an analogue value from a DAQ card why cant i just get the damn value without

the overhead of starting and stopping tasks ?

Anyway ive probably done myself out of an answer in flaming NI.

thanks for your response.

 

Message Edited by MAttyd on 02-09-2006 06:25 PM

Message Edited by MAttyd on 02-09-2006 06:25 PM

0 Kudos
Message 3 of 11
(5,810 Views)

Hi Otis,

      is there

0 Kudos
Message 4 of 11
(5,803 Views)

Hi Otis,

      is there not

0 Kudos
Message 5 of 11
(5,803 Views)

Hi Otis,

      is there not a way

0 Kudos
Message 6 of 11
(5,803 Views)

Hi Otis,

      is there not a way to set the

0 Kudos
Message 7 of 11
(5,803 Views)
the tab key is killing me here. Sorry for all the posts.Smiley Wink
Message 8 of 11
(5,797 Views)

Assuming you're doing buiffered event counting, you can monitor the status of the buffer without blocking by using the Read Properties.  I don't know the exact VB syntax, put the equivalent C funtion you need is:

DAQmxGetReadAvailSampPerChan(TaskHandle taskHandle, uInt32 *data)

You can use this function to poll within a loop and then call read only after a certain number of samples are available.  You can also continue to use the Read function but pass in a timeout of 0 or pass -1 for the number of samples to read.  Passing -1 will tell the driver to read all samples that are currently available and then return.  Depending on the method, you'll either have to handle timeout errors or check the actual number of samples read to see if you actually read anything, but neither method will block until samples become available.  You could also register a callback funtion for the Every N Samples Acquired Into Buffer Event and perform your read in that callback.  I hope this helps.

0 Kudos
Message 9 of 11
(5,785 Views)

Thanks for the response reddog.

i cant find a reference to the function "DAQmxGetReadAvailSampPerChan" in the help files i have for version 8.

 

any ideas ?

0 Kudos
Message 10 of 11
(5,779 Views)