Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Other programs interfere measurements

Hello,

 

I try to measure analog voltage using NI DAQ 6211. In the same time, I generate pulses and count them. All operations are done using Continuous mode. Each time counter counts predefined number of pulses (in this case two pulses), DAQ should read all available samples on the appropriate analog in channel.

 

Generally it works fine, and I get about 8000 samples between two readings. But, if I start some other program (for example Outlook Express) while measurement is in progress, I get more readings (10000) in the moment of starting this program, which means that I read the samples too long, or in other words, the next reading is too late.

 

I tried this on couple of different computers with different operating systems (Win7, and Win XP) and same thing happens, so the computer performances are not the problem.

 

Can anyone tell me what am I doing wrong, or suggest some other approach with better results?

 

Thank you.

0 Kudos
Message 1 of 4
(2,921 Views)

Hi Nenad1526,

 

The way you have implemented this in your posted VI does the following:

 

    1.  Reads back the count whenever it is incremented.

 

    2.  Checks if the count is a multiple of your desired interval (i.e. sample every 2 counts in your case)

 

    3.  If the count is in fact a multiple of your desired interval, it reads back all available data on the AI channel.

 

 

The problem is that your OS does not have deterministic thread scheduling.  That is, if you decide to open another program (in your case, Outlook Express), the CPU might not get back to your data acquisition task for some time.  So, a non-negligible amount of time could pass between step 1 and step 3.  In addition, since you're on USB all of the transfers are CPU dependant, so it's not just your software that is at the mercy of your OS's non-deterministic scheduling but also the data transfers themselves.  USB also has inherently high latency (compared to other busses like PCI and PCIe) which can further add to the discrepancy.

 

 

So, what it sounds like you actually want to do is group the AI data with respsect to the counter incrementing.  That is, all AI data that was acquired when the counter was 0 or 1 should be returned in a single grouping.  All AI data acquired when the counter is 2 or 3 should be returned in another grouping.  You can achieve this behavior by correlating the counter measurement to your AI data.  Sample the counter off of the AI Sample Clock, then you have a 1 to 1 mapping of counter and AI samples that is determined by hardware.  You can thus tell exactly which samples occurred at a specific value of the count register without having to rely on non-deterministic software calls.

 

 

Best Regards,

John Passiak
0 Kudos
Message 2 of 4
(2,909 Views)

 


@John P wrote:

Hi Nenad1526,

 

The way you have implemented this in your posted VI does the following:

 

    1.  Reads back the count whenever it is incremented.

 

    2.  Checks if the count is a multiple of your desired interval (i.e. sample every 2 counts in your case)

 

    3.  If the count is in fact a multiple of your desired interval, it reads back all available data on the AI channel.

 

 

The problem is that your OS does not have deterministic thread scheduling.  That is, if you decide to open another program (in your case, Outlook Express), the CPU might not get back to your data acquisition task for some time.  So, a non-negligible amount of time could pass between step 1 and step 3.  In addition, since you're on USB all of the transfers are CPU dependant, so it's not just your software that is at the mercy of your OS's non-deterministic scheduling but also the data transfers themselves.  USB also has inherently high latency (compared to other busses like PCI and PCIe) which can further add to the discrepancy.

 

 

So, what it sounds like you actually want to do is group the AI data with respsect to the counter incrementing.  That is, all AI data that was acquired when the counter was 0 or 1 should be returned in a single grouping.  All AI data acquired when the counter is 2 or 3 should be returned in another grouping.  You can achieve this behavior by correlating the counter measurement to your AI data.  Sample the counter off of the AI Sample Clock, then you have a 1 to 1 mapping of counter and AI samples that is determined by hardware.  You can thus tell exactly which samples occurred at a specific value of the count register without having to rely on non-deterministic software calls.

 

 

Best Regards,


 

Thank you very much for your answer.

 

But, I must say I do not completely understand what I suppose to do. Could you, please, give me a small sample code, or change my code according to your solution?

 

Thank you in advance.

0 Kudos
Message 3 of 4
(2,888 Views)

Hi Nenad1526,

 

Well it's a little more complicated than a simple example, but I've attached a vi that should do what you need in a deterministic manner:

 

        2011-04-13_110039.png

 

 

The first sample interval is about half the duration of the others since the initial delay is set to 0 (i.e. count 1 occurs at time = ~0).

 

 

 

John Passiak
0 Kudos
Message 4 of 4
(2,869 Views)