12-28-2016 09:25 AM
Hi,
I am using a PCI-6602 card and I need to sample the card every 200 millisecond.
According to the "MeasDigFrequency_LowFreq1Ctr" example, I have implemented a code that samples the frequency continuously.
My problem is that if I set the variable SamplesPerChannel to be 1, when my frequency is 1 KHz, I receive many callbacks which is too much and affects the performance. If I set SamplesPerChannel to 20, and the actual frequency is 2Hz, I receive callbacks every 10 second which is not enough.
I try to use another method, according to the "CountDigEvents" example, I have implemented a code that read every 200 millisecond the numbers of event that occur in that period of time (which is supposed to be equal to the frequency). However, I cannot calculate exactly the frequency due to windows clock accuracy.
Thanks,
Simon.
12-29-2016 02:51 PM
Hello Simon,
To answer your first question, whether or not you can set the SamplesPerChannel dynamically is determined by the card you're using. I looked it up and the PCI-6602 card does not have this functionality enabled.
As far as your second question goes, I would institute a 200 millisecond wait in the while loop that is reading the data. Then, if you set number of samples per channel to -1, it will empty the buffer entirely every 200 milliseconds. I made some sample code in LabVIEW that you can see below.
Hope this helps answer your questions.
Zoe B.
01-04-2017 02:40 AM
Hello Zoe,
I don't know LabVIEW. I work in C#.
Could you please write the example in C#?
Thanks,
Simon.
01-04-2017 03:11 PM
Hi Simon,
I am not a fluent coder in C#, but the LabVIEW code I sent is actually just a shipping example that I modified slightly. As such, there's a corresponding C# shipping example you could use as a reference called Measure Digital Frequency - Low Frequency - 1 Counter.
A list of all the shipping examples and how to access them are found here.
Since the inputs/outputs of the functions are the same in LabVIEW as C#, you would change the corresponding number of samples per channel value to -1 and institute a wait within the while loop.
Zoe B.