Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple triggers in a time-critical problem

Solved!
Go to solution

Hello World!

 

I want to acquire the amplitude and the phase information of my analogue signal with a multiple triggering scheme (I hope the picture would help you understand my issue). I am using the X-series USB6363.

 

dcshin_0-1641977940059.png

 

I have two kinds of triggers: a cycle trigger and a main trigger.

 

Both trigger signals are square waves with different frequencies; 10 Hz for the cycle trigger and 10 kHz for the signal trigger. On the other hand, my analog signal, of which amplitude and phase will be extracted through a software lock-in amplifier, is a sinusoidal wave with a frequency of around 100 kHz (very noisy). 

 

I want to develop a LabView program like this.

(1) The cycle trigger starts a single cycle. The main triggers work for a given times, e.g. 500 times.

(2) When the main trigger is once triggered, the analog signal is recorded for 10 μs at a 2MS/s sampling rate (total 20 points).

(3) The acquired 20 points of 100 kHz analog signal are then analyzed through a software lock-in amp (I already developed a simple one and please suppose there is no time-critical issue). the amplitude and the phase are recorded in two arrays, respectively.

(4) This process is repeated to get every amplitude and phase for every main trigger. 

 

And, I want to repeat the above cycle over 1000 times and then average the amplitude and phase over time to reduce the noise of my analog signal.

 

I'm not requesting direct solutions for this problem but want to hear any recommendations of good tutorials or similar examples that I can learn about.

 

Thank your for your time

 

Best Regards,

D. Shin  

 

0 Kudos
Message 1 of 5
(1,122 Views)
Solution
Accepted by dcshin

1. Do you need to *create* or *react to* those 2 trigger signals?  If they are externally-generated signals you react to, what can you know ahead of time about their timing relationship and what will be unknown?

 

2. And what's the purpose of the "cycle" trigger?   It wasn't particularly clear in your description.   Is it just to break down all the "signal triggers" into groups of 500?

 

3. Capturing 20 samples at 2 MHz only gives you 1 nominal cycle of your expected 100 kHz noisy sine wave.  I would expect you to want a larger number of cycle per trigger.  Of course, you're necessarily limited to <10 before you go line-to-line with your trigger rate. 

   I haven't worked on lock-in related apps so maybe my intution is wrong here, but I'd expect you to get better analysis results with more sine cycles.  Offhand I might aim for 4 or 5.

 

4. Don't plan to process trigger worth of analog data 1 chunk at a time in your main acquisition loop.  That'd require a 10 kHz loop rate.

    Instead, plan on a producer-consumer scheme and possibly also after-the-fact batch processing.

 

5. Further along that same line of thinking, if you approach this directly as a retriggerable AI task, you'll *need* to keep up with a 10 kHz loop rate, so you'll therefore *need* to try to keep up using a producer-consumer pattern.  IMO, this is very unlikely to be workable with a USB device.  (Whereas with a PCIe device, I'd merely consider it "questionable".)

 

6. That's gonna lead you into my realm -- using stupid counter/timer tricks to accomplish the otherwise seemingly impossible.  💪

 

7. More specifically, you'll want to create a retriggerable finite pulse train with one of your counters.   It'll run at 2 MHz, trigger off the 10 kHz "main" trigger, and generate 20*N pulses (to correspond to N cycles of your sine wave).   

 

8. Then your AI task could be declared as a simple Finite Sampling task, capturing (20*N)*1000 samples.  You could just let your producer loop wait to retrieve them all at once (every 100 msec apparently), and pass them over to your consumer loop which will break them down into chunks of (20*N) for your further analysis.

 

Moral of the story: X-series MIO devices are pretty great!

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 5
(1,107 Views)

Late proofread edit:

 

Step 8 should have mentioned that the AI task needs to be configured to use the aforementioned counter output as its sample clock.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 3 of 5
(1,086 Views)

Thank you for your help Kevin_Price!

 

1. The two trigger signals are actually externally-generated signals in my experiments and not related to each other. So, I should react to them with an unknown timing relationship.

 

2. The analog signal previously depicted in my post is quite different from the real one, which might baffle the purpose of my cycles. I'm performing optical spectroscopy with a very low optical power from which the spectroscopic signals contain a lot of noise. To overcome this, I want to average the spectroscopic signals in time. Actually, the cycle trigger and the main trigger represent exact optical frequencies that are probed. It means that the n-th triggered signal by the main trigger after the cycle trigger is activated specify an exact optical frequency. After the acquisition, the amplitude and the phase of the analog signal in the time domain will be converted to the frequency domain. I hope the picture below would help understand it.

 

dcshin_0-1642123862206.png

 

3. Actually the lock-in process takes time. So I will optimize the acquisition time per the main trigger later.

 

4-8. Your description is really clear and very helpful! I will try to embed these things into my LabView file. Could you recommend any version of a retriggerable AI task or producer-consumer scheme that was discussed before in this community? I am a beginner of DAQmx so need to practice with a good example... If you don't mind.

 

I really appreciate your suggestions!

D. Shin

0 Kudos
Message 4 of 5
(1,070 Views)

The vi attached should help get you started.  It's a little bit modified from one I posted over in another thread.  (That thread might be helpful to read through.  The needs were a little more complicated, but a lot of it is fairly similar to your situation.)

 

It includes a minimal example of deferring the processing over to another loop that runs in parallel to the data acq loop.   This is what's meant by my reference to the "producer-consumer" pattern.  

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 5
(1,030 Views)