LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simultaneous triggered analog and digital acquisition

I am trying to acquire analog and digital data simultaneously but I want to use triggers to both start and stop the acquistion. For analog acquisition, I am using Start Trigger and Reference Trigger which works great. For digital acquisition, I can use Change Detection on the trigger line but I'm not clear on how to implement the stop trigger. I am using PCI 6259 so there is no built-in way (reference trigger doesn't work).

Currently I am doing analog and digital acquisition in separate loops. If the analog task is done, I'm stop the digital acquisition loop or completely stopping the digital acquisition task. This method is very buggy and gives me errors about the task not being started, etc. On top of that, it the stop trigger will be jittry for digital acquistion so I need to include some code to make sure analog acquisition time is exactly same digital acquisition time.

 

I just want to get a general idea of how you would go about implementing this. I don't necessarily need the code.

One more thing: I am acquiring the digital signals at different sampling rate than analog signals, however I'm acquiring the same number of samples per read (unless it's after the stop trigger in which case I'm acquiring whatever number of samples are available). Also, I am doing acquisition for multiple triggers. So after first start-stop trigger (one block of acquisition), I am restarting both tasks to they wait for the next start trigger. It goes on forever until the user presses the stop button.

0 Kudos
Message 1 of 8
(3,905 Views)

HI Abdel2,

 

First of all, I am curious what sample clock you are using for your Digital Input task. My thought about how you could achieve this will require you to oversample one of the two acquisitions if they are running at different rates. If you set up your task so that you use your AI Sample Clock for the sample clock of your digital acquisition as well, the start and reference triggers that you set up for the AI task will affect the start and stop of the AI sample clock which will, in turn, start and stop your DI task as well, because your DI task cannot take an input if it is not recieving that AI sample clock tick. I hope this makes sense. My suggestion would be to take a look at the example in the NI Example Finder called Multi-Function-Synch AI-Read Dig Chan.vi. All you would really have to do is to add the triggering VIs in the AI task and make sure you change it to run continuously waiting for more of these triggers for another acquisition.

 

Chris W
0 Kudos
Message 2 of 8
(3,872 Views)

I'm a little confused now. How does the AI sample clock really work? Does it generate pulses at the provided sampling rate at the start of the analog task or it has a fixed rate (eg: 1 Mhz)? Right now I'm getting analog and digital data at different sampling rates, for a certain duration, and it seems to work. Now I'm not that sure. I used the example you mentioned and used the sample clock for the analog task to drive the digital task.

0 Kudos
Message 3 of 8
(3,856 Views)

What was the result of using that example program? Did that work the way that I explained for you? 

 

The AI sample clock is a pulse train clock of the frequency that you specify that is generated from the onboard timebase. This clock starts either when you call the DAQmx Start.vi or when the task is triggered to start by a start trigger. It's possible that you can get AI and DI data at different rates but you must be using a different clock for your DI. What clock are you using to generate your Digital Input? 

 

Another way that you could do this is to have your AI task as it is with a start and reference trigger and then create a dummy counter pulse generation task that will generate pulses at the rate you would like your DI to acquire and use this CtrXInternalOutput signal as the sample clock for your DI task. On your Counter task you can configure a start trigger and a pause trigger and make this task re-triggerable. You can then use the same trigger to start both acquisitions and the same trigger to "stop" both acquisitions but the trigger signal that is used as the reference trigger for AI and the pause trigger for the ctr task would have to stay high or stay low until the next start trigger is received, otherwise the ctr task would continue generating pulses that would be used by the DI task as the sample clock. 

 

This is kind of a shotty workaround, but that is really your only option unless you want to use the method I described in my previous post and then do some post processing (possibly simultaneous processing with a producer/consumer configuration) to decimate some of the data you acquire from your slower acquisition. If the process I described sounds like you might be able to get it working, take a look at the example in the example finder called "Multi-Function-Ctr Retrigg Pulse Train Generation for AI Sample Clock.vi."

 

Chris W

0 Kudos
Message 4 of 8
(3,833 Views)

I just re-evaluated my requirements and I am getting rid of the pause trigger for digital I/O. I only need to start the digital acquisition at the same time as analog acquisition. Both of them will stop after a certain amount of time (I can do this by simply reading in the number of samples that have been acquired up to that time and stop if it reaches a limit).

 

Before, I was using analog sample clock as the clock source for digital I/O, and I was getting good results but now that you mentioned, I am probably sampling the digital data at the same sampling rate as analog DAQ. I need much faster sampling rate (~25kHz compared to 1kHz for analog). I can't use the counter outputs as external clock source because both of them are in use by the stimulus module. I will look into the frequency generator to see if it works. Is it a good idea?

 

0 Kudos
Message 5 of 8
(3,817 Views)

I think that using the frequency generator is certainly a viable option. The M series user manual has some good info on that. Coding it is simple, just like creating a counter output.

 

Chris W

0 Kudos
Message 6 of 8
(3,808 Views)
I just tried using the frequency generator and it doesn't seem to support triggered start (counters do). I need to start both analog and digital acquisition after a trigger. I guess the only other way to do acheive this is by sampling everything at maximum rate and decimating. But later on I am gong to implement serial communication which will also need to started based on a trigger. I'm trying to find a method that will work for all 3.
0 Kudos
Message 7 of 8
(3,777 Views)
When you implement serial communication, how many lines are you going to need to use there? I think that since you are limited by the restrictions of your trigger, you will have to run your DI and AI off the same AI sample clock. Once you decide to implement the serial communication, you will have to use a Dummy AO task so that you can use the AO Sample clock as the sample clock for your DI and DO for the serial task. If you have an open counter you can use that instead of the AO sample clock too, but I thought that I recalled you saying you were using them. 
0 Kudos
Message 8 of 8
(3,756 Views)