09-30-2021 06:39 AM
The 1kHz AI signal (2 channels) can be sampled continuously (without trigger).
The reason to make sure you trigger AI from the first pulse is because then you know to keep the *first* 22 msec out of every 100 msec. If AI were just free-running, you won't be able to unambiguously identify the sample corresponding to the beginning of your pulse time.
-Kevin P
09-30-2021 10:41 AM
If you really don't like triggers, you can sample the first pulse train as another AI channel and use that to determine when the trigger started... but the trigger method is much better.
10-01-2021 02:19 AM
@BertMcMahan wrote:
I think he can use a continuous AI task and remove the data from the time he doesn't care about later on. That may be simpler than retriggering, but there are certainly several ways to skin this cat.
That said, I realized I may be confused on your timing. You said "both should be active for 10 ms, one after the other with a 2ms delay". I assumed you meant that TTL1 starts at t=0, and TTL2 starts at t=0.002. If you meant that TTL1 starts at t=0 and ends at t=0.01, then TTL2 starts at t=0.012 and ends at t=0.022, then the table will be different from what I originally said. It'd then be:
TTTTTTTTTTFFFFFFFFFFFFFFF...
FFFFFFFFFFFFTTTTTTTTTTFFF...
Your AI data will return with 100 samples but you can use Array Subset to just get the first 22 samples.
Hi BertMcMahan,
I took up your idea with the T / F array and wrote a small test program (quick & dirty). The triggering of the laser works great. Also flexible with different trigger frequencies, duration of the trigger and delay between trigger 1 and trigger 2. The VI Create TTL Array.vi can certainly be programmed even better, but it works.
It is still unclear to me how the AI signal should be triggered with this DO pattern in order to only grip the portions of the AI signal for which the trigger signals are true.
Pete
10-01-2021 08:07 AM
What you've got looks pretty good overall, but with several small changes it'll be even better.
1. Configure your DO to use a hardware timing and buffered output instead of single on-demand samples with software timing. You just need to add a call to DAQmx Timing, much like you do for AI. The difference is that the 'source' input should be a terminal with a name like "/Dev1/ai/SampleClock".
2. Once you configure the clock and buffer with that call, you'll *also* then need to write your data to the task buffer *before* you start the task. The nice thing about this is that you can just write the whole buffer full of data 1 time all at once and the hardware & driver will do all the generation in the background. You don't need to service the task in your main loop any more (though it's common to make some kind of occasional task query just for the sake of having a mechanism to receive and respond to any error).
3. Because the AI task is sharing its sample clock with the DO task, it'll now further be important that you start the DO task first.
...oh dangit! I was about to start talking about triggering when I realized this wasn't gonna work out so cleanly after all. I was about to set you up for an impossible circular dependency. The DO task depends on gettting a sample clock from the AI task, which wouldn't occur because the AI task wouldn't start sampling until it received a trigger from the DO task. Both would just sit there, stuck, doing nothing forever.
All this is solveable if you configure a counter to generate a pulse train at your desired sample rate and then have both AI and DO use that output as their sample clocks.
4. Then the other (final? I think so...) thing to do is physically wire from the earlier pulse DO line to a PFI line that the AI task can designate as its trigger.
FWIW, if you were to decide to generate pulses with counter tasks, those already get output to PFI lines so you wouldn't need to do any physical wiring to trigger AI from a counter output.
-Kevin P
10-01-2021 09:37 AM
You should be able to just share the AI clock with the DO task, then start the AI task. No need to trigger start anything.
10-01-2021 09:52 AM
@BertMcMahan wrote:
You should be able to just share the AI clock with the DO task, then start the AI task. No need to trigger start anything.
Of course! Absolutely right! Thanks for correcting my misdirection! (Just still be sure to start the DO task first.)
-Kevin P
10-01-2021 10:34 AM
Well, crap. I was wrong. I got an example VI written up and ran it with a simulated 6215, then got an error when I tried to configure timing for the DO channel.
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000kHNdSAM&l=en-US
Looks like M series devices, in general, will work with correlated digital IO (meaning you can share a clock to the digital system and get hardware timed digital outputs). However, the 621x series does not support correlated digital IO:
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000kHNdSAM&l=en-US
Sorry OP. The digital trick won't work with your specific card, and you'll need to do counter outputs. It's not a giant deal but it's not as easy as the digital option I mentioned earlier.
You'll need to make two counter output channels like Kevin said originally. You can synchronize their start with AI\StartTrigger to make sure they start at the same time, or you can use the output of the earlier TTL output as your analog start trigger.