From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

counter to measure frequency with multiple channels (Analog In/Out) in one vi

Hi,

I am using DAQ 6062E. I have multiple channels: an Analog In, Analog Out, Count Edges, and Count Frequencies. Without Count Frequency, the program works fine, I have defined a Sample Clock for each channel and then a common sampling rate. When I add Count frequency channel, I am not able anymore to use Sample Clock, since I get an error that Sample Clock can not be used, and if I change the Sample clock of the Count frequency to Implicit, then I can not connect different channels with a same sampling rate. In the attached file, if the Count Frequency is not connected to any Sample clock and sampling rate, the program works, but now I can not run the program for more than 5-10 Hz sampling rate, otherwise I get the error: 209802 “occurred at DAQmx wait for next sample clock, slow down the sample clock”. Does anybody know how to fix this problem?   

 

Thanks a lot,

Azadeh

0 Kudos
Message 1 of 6
(3,134 Views)

Hi Azadeh,

In your post you mentioned that you are trying to do Analog Input, Analog Output, and 2 Counter functions simultaneously with a DAQCard-6062E.  As you know this device uses the PCMCIA port of your laptop which will only allow you to use interrupts to get information to or from the DAQCard to the computer's memory.

Interrupts are a relatively slow method of communication that will bog down your processor.  And when looking at your code, it appears that you are doing single point operations which will even further degrade the potential performance and easily explains why you are getting rates as slow as you are seeing.  In the program's current format there is not much we can do to make this application run faster because of the PCMCIA bus limitations.

What we could do though is instead of doing single-point operations on the Analog Output and counters; you could try doing buffered operations.  That way you are still using interrupts, but with larger chunks of data the interrupts will be less frequent and will allow for more information total to be sent/received.  Keep in mind though that even at the maximum rate you can only get an analog output rate of up to 850kS/s with this DAQCard, and the more information going across the bus the slower the rates will go.

That said, simply moving to a DAQmx program where you are doing multiple points at a time instead of Hardware Timed Single Point operations should help you to greatly increase your sampling speed.

Regards,

 

 

0 Kudos
Message 2 of 6
(3,107 Views)

Hi Otis,

Thanks for replying back. I tried using Continous Samples instead of Hardware Timed Single Point as well. However, it didn't help and still I have the same problem. What puzles me is that when I have Analog In/Analog Out/Counting Edges in the vi, I can reach up to 150-200 Hz. But when I add the second counter (Counter for Frequency), then I am not able to run the program more than 10Hz. I need to use the second counter for frequency to calculate velocity from my quadrature encoder. Do you have any suggestion to speed up my loop when I use Counter for Frequency? Or is there any other way I can get a clean velocity data?  Thanks a lot,

Azadeh

 

  

 

0 Kudos
Message 3 of 6
(3,099 Views)

Hi Azadeh,

Could you do one more experiment for me?  Could you try just running the two counter functions simultaneously and see what your rates are?

I think what's happening here is that because of the very small FIFO size on the counters that you are running into issues of the data being transferred too quickly across the bus and it's really the counter that's the limiting factor and not the other operations.

The only way around this (if it truly is what the case happens to be) would be to use a Velocity sensor instead of a quadrature encoder, or to use our newer USB-6251.

Let me know if the rates go slow when using only the two counters so that we can try to figure out what the best solution is.

Regards,

 
0 Kudos
Message 4 of 6
(3,082 Views)

Hi Otis,

 

Thanks for looking at the problem. I ran just two counters in a same vi. I was not able to use the Sample Clock since I needed to define an external sample clock source. The vi is attached. I could run this vi fast (200Hz). So, I am not sure why when two counters are combined with AI/AO the rate is very slow. I have attached three vi(s). Just two counters, AI/AO/1 counter, and AI/AO/2 Counters vis. I am able to run the vis in 200 Hz except the vi with AI/AO/2 counters (maximum sampling rate 20Hz). I appreciate if you can look at it if I am missing something.

 

Thanks,

Azadeh

 

Download All
0 Kudos
Message 5 of 6
(3,056 Views)

Hi Azadeh,

I took a look at your code and everything seems to be alright. I noticed that you are performing a lot of analysis inside of your while loops. While this is ok, it will slow down your application some along with the fact that you have multiple operations ( i.e. analog input, analog output and counters) running in the same program.

If the rates that you are getting now are not acceptable, then it may be worth looking into the USB-6251 that Otis recommended.

Regards,
Hal L.

0 Kudos
Message 6 of 6
(3,028 Views)