Quantcast
Channel: Counter/Timer topics
Viewing all articles
Browse latest Browse all 1271

synchronizing AI task with counter task

$
0
0

I have written a standalone script to try troubleshooting why I can't get a counter synchronized with an analog input task. After searching NI discussion boards and white papers I can't find much discussion on this, which is surprising.

 

So, how do I get a counter input synchronized in a general way to an analog input task? I say "in a general way" because it seems like many of the other discussion board posts are very specific to some hardware or measurement application and they usually are able to get by with some way of doing it that's specific to their setup. I want a labview/daqmx algorithm/implementation that I can utilize across multiple hardware systems, cdaq chassis with modules, PXI chassis, PXIe. We have a general purpose data acquisition script that will ^we want^ to run with all of the above technologies. So before I try to tackle a more general case, I just want to understand a specific case of Cdaq-9178 with 9402, 9234 cards.

 

I have two Daqmx tasks that will run in MAX fine, an analog input task with 1 voltage on the 9234 card. A 1 counter input measurement frequency on the 9402 digital card setup for implicitly sampled.

 

My frequency measurement could be slower than the sampling rate of the analog input or faster than the AI sample rate. It may be measuring anything from 10 Hz up to 50 kHz. I don't want to average out the speed either, I want to catch every incoming pulse. So, more or less, I cannot use sample clock based setup for the counter. I have to use an implicitly timed counter input.

 

This seems to indicate that if I use a trigger pulse to the start trigger of the AI task and the same trigger to the armed start trigger of the Counter task then they are in sync? Maybe I'm not understanding the hardware right but they are not sync'd up when I record data.

 

I test this out by connecting a frequency generator square wave to the 9234 AI task and the same square wave to the 9402 counter task. I then say (in labview) that the AI start trigger is cdaq PFI0 and the armed start trigger of the counter task is PFI0 as well (I’ve also used ai/start trigger as the terminal too). I start both tasks and both tasks work as expected; they don't begin acquiring data until I connect the start trigger to the PFI0 line, but when I plot the data the two tasks are not synchronized. The frequency channel is always delayed by different times, but .3 seconds seems to come up a lot as the delay on the frequency channel measurement. I change the frequency on the generator while recording data so the counter frequency channel should match up to when the pulses change on the voltage channel. See my attached diagram from Diadem showing what I get.

 

I plot the data in Diadem. The AI voltage is a waveform so has built in timestamps. I compute the time stamps for each sample of the frequency by timestamp = sum(1/freq samples). When I plot, they just aren't in sync.

Is the triggering not working the way I expect? Am I not thinking about the plotting the right way?

 

I can't imagine someone hasn't tried this before. This just seems like a common thing that test engineers would want to do - synchronize frequency data with AI data. I see this commonly done on other data acquisition systems from other manufacturers.

 

Thanks for any help. 

Adam

Cummins Inc.


Viewing all articles
Browse latest Browse all 1271

Trending Articles