Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ Counters in Timed Loops

Hello,

 

I'm writing a program in Labview to control a counter input on the PCI-6251 series board and I'm getting inconsistent counts when I read the counter value every 100 ms (for example) in a timed loop.  I have a consistent pulse signal coming in from a function generator and I'm confident that it is stable.  I've tried alternative timing methods, for example using "wait for next ms multiple", but it has the same effect as when I use a timed loop with a period of 100 ms.  The values differ considerably, +/- 5% for 100 ms and decreasing for larger times, even though the loop never says it has missed its timing goal.  What is the best way to periodically read the value of a counter that is running in the background of a timed loop?

 

Thanks!

0 Kudos
Message 1 of 4
(4,317 Views)

Hello hendrix,

 

I understand that you are periodically reading the value of a counter on your PCI-6251 in LabVIEW, and you getting results that are off by +/- 5% for 100 ms and less for times greater than 100 ms.  You asked what's the best way to periodically read the value of a counter that is running in the background of a timed loop. I'd like to investigate how you are implementing the periodic reading of the counter in LabVIEW.  Is it possible for you to attach your code to a subsequent post, so that I can try to duplicate what you are seeing, and come up with some alternatives?

 

Regards,

Wallace F

National Instruments
Applications Engineer
0 Kudos
Message 2 of 4
(4,302 Views)

Hi Wallace,

 

Thanks for your message.  I uploaded an example of what I'm trying to do.  The sample program just has a timed loop that tries to read the value of a counter during each loop.  I ultimately want to perform some other things in this loop as well, but even with this simple enclosed example I see the counter collecting inconsistent data from a consistent input source.

 

Thanks for your help!

 

Scott

0 Kudos
Message 3 of 4
(4,299 Views)

Hello Scott,

 

I ran the VI that you posted, and I saw pretty much the same thing that you did.  I racked my brains trying to figure out why this is, and eventually had to talk to a more experienced DAQ guy before things made sense.  Let me ask you a question.  If you ran your VI with a signal source of different frequencies, would the results be the same?  Would the results be of by 5% if your signal source was 10 Hz?  My experience is that it takes a signal of about 100Hz or more before you start to see some errors?  This is because the DAQmx Read as it is used in your application just pulls the data out of the count register in the counter.  The DAQmx Read is not hardware timed as it is used in your application, so it doesn't read exactly at the same time.  The DAQmx Read as you are using it is supposed to occur every 100ms, but it doesn't occur at the same point near the beginning of that 100ms every time.

 

Best wishes,

Wallace F.

National Instruments
Applications Engineer
0 Kudos
Message 4 of 4
(4,282 Views)