Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Ideas on how to synchronize AI and external devices with cDAQ-9188

Hello,

 

We'd like to get ideas to synchronize an analog input with external hardware. Our chassis is cDAQ-9188 (Ethernet) with AI module NI-9205 and AO module NI-9215.

 

For our current project we need to acquire data on several channels at 15-20 kHz. Those should be precisely synchronized with an external hardware that delivers 16 samples at the same rate (15-20 kHz) every time we send it a trigger signal (with a minimum period of 4 ms).

 

Taking into account the available resources, up to now we've been trying different approaches, that I'll describe now:

 

-The first idea was to wire the trigger signal of the analog input (cDAQ1/ai/StartTrigger) to the PFI0 line, something like this:

 

DAQmxCfgDigEdgeStartTrig (AITaskHandle, "/cDAQ1/ai/StartTrigger", DAQmx_Val_Rising)

DAQmxExportSignal (AITaskHandle, ,DAQmx_Val_StartTrigger, "cDAQ1/PFI0")


And then start the analog task manually (configuring the task to read a finite amount of samples) in a loop. In that loop we expected to read and record therequired data, stop the task and start it again. Such approach was not successful for two reasons: first we weren't able to see the trigger signal on the PFIline, possibly because the configuration of the trigger was not correct (we tried several different strategies, like using DAQmxConnectTerms but none of themworked either). And second: after some trials we realized that starting the task in a loop we were nowhere close to 250 Hz (we got up to 5 Hz).

 

-So we took one more step and decided to use the analog output to generate a decent trigger signal. According to the specs of the NI-9215 it should be apiece of cake to come up with a square signal with a 4 ms period so we went on with that. Based on the SynchAI-AO.c example of the DAQmx ANSI Clibrary we tried to set both tasks as continuous and added the retrigger capability:

 

DAQmxSetStartTrigRetriggerable(AITaskHandle, 1)

 

That should allow us to acquire just the 16 samples we needed for every 4 ms period, but unfortunately cDAQ-9188 does not seem to support retriggering.

To be honest that was really annoying since retriggering is claimed to be supported by NI on the DAQmx Reference Help. It would be much appreciated ifsomebody at NI could explain the reasons for such a contadiction.

 

-At this stage we were a little bit tired of investing so much time on a such a trivial problem, so the overkilling started 😉 and we decided to use the analogoutput to feed the analog input clock's, taking advantage of our old friend PFI0. Although that seemed to work fine for low frequency (something close to2 Hz) it ended up in just another disappointment. We suspect that at higher rates the settling time of the DA converter started to play dirty tricks on us buttaking into account that we required a 16 sample clock for 15-20 kHz it didn't came as a surprise. Something to note here is that we used the AO bothas the clock for the AI and as the source for the trigger of the external device, where we had to discard 15 samples out of the 16 generated for the clock,but that was accomplished with little pain.

 

-Finally we decided to come back to the SynchAI-AO.c and keep both task running continuously with no trigger at all. For this procedure to work we need to grab more samples than we want (64 for instance) and discard them in the DAQmxRegisterEveryNSamplesEvent() call. I know it seems to be not an elegantsolution but it's the one it proved to work.

 

I'm sorry for such a long post, now it's your turn guys. We'd like to hear feedback from anyone that experienced similar problems. We are sure there are much better ways than ours, so please feel free to post back.

 

I'll take the opportunity to thank NI for maintaining these forums and all of you reading and writing for keeping them full of amazing stuff that helps us so much in our everyday work

 

Cheers, 

 

Marcos

 


 

 

0 Kudos
Message 1 of 1
(2,893 Views)