07-28-2010 09:54 AM
Here's my problem:
I have a PXI-6115 i/o card and I'm observing a waveform on ai0. When the waveform reaches a threshold, I want to generate a waveform on ao0. I tried looking at the example, "Cont Gen Voltage Wfm-Int Clk-Analog Start.vi," using ai0 as the trigger source but I get error 200265 (using an invalid trigger source). I realized that the channel should be in the task if I want to use it as a trigger, but I can't add an AI channel to an AO task, so I'm kind of stuck.
I've attached part of the code that I'm trying to use. Any advice would be greatly appreciated!
07-28-2010 11:21 AM
sjwelch,
I believe you can us PFI0 as an analog trigger source on this device. Can you wire the same signal that you are measuring on AI0 to PFI0? If you do this, I think you should be able to do what you described by using PFI0 as the analog trigger source for you AO task.
Hope that helps,
Dan
07-28-2010 12:25 PM
Thanks for the advice! That will indeed work, but I forgot to mention that I will also need to use other ai channels (specifically ai1 and ai2) as a trigger source in other parts of the code. I could use an external switch to connect them all to PFI0, but I'd like to keep it as simple as possible. So, is it possible to use these AI channels as a trigger source?
07-28-2010 01:22 PM
Unfortunately, PFI0 is the only terminal that can be programmed as a analog trigger source for an AO task. However, it is worth noting that that there is a single analog trigger on your device, meaning that regardless of whether it is used for AI or AO, it's the same circuitry. Depending on how you need to configure your AI tasks, it may be possible to set up the trigger with AI, then to use its output for AO. For instance, if you were doing a finite AI acquisition, it might be possible to switch to using a referenced triggered task, with an analog reference trigger. Once the AI task has set up the appropriate trigger, you could then configure your AO task to use a digital start trigger, and make it source be /DevX/analogComparisonEvent.
Whether or not such a solution is feasible will depend on whether or not you can find some acceptable way to use an analog trigger with your AI tasks. Aside from this, I can't really think of a great way to accomplish what you need outside of an external switch.
Hope that helps,
Dan
07-28-2010 02:01 PM
If your timing between Analog In and Analog Out is not critical, you could just use software triggering. Get your AO setup with Start Trigger set to None. Don't run it yet. Get your AI setup to read 1 sample. In a loop, put the AI read function. Each loop iteration should return one reading. When the reading goes below the threshold, call the AO Write function to send an output.
The trick is to not continuously call the AO write whenever the AI input is below the threshold, or it will be called on each loop iteration as long as the AI reading is below the threshold. You can use a shift register to hold a boolean flag. Drag down the shift register on the left side to create a previous state terminal. Send the threshold compare output to the shift register. On the left, you read both shift registers. Trigger the AO when the top terminal is True and the bottom terminal is False (using AND and NOT). This will trigger only once because on the next iteration, both will be True. The threshold compare will have to go to False and then True again before the next trigger will occur.