05-12-2008 12:46 PM
05-13-2008 11:04 AM
05-14-2008 01:06 PM
Hello Godzilla,
In order to do synchronized digital input and output you will need to route your external trigger through a "dummy" analog input task. The reason for this is that the digital I/O tasks do not support start triggers. By using the analog input sample clock and starting the digital tasks before the analog input they will be started at the same time and thus be synchronized.
I would recommend starting with the Multi-Function-Synch AI-Read Dig Chan.vi example program. This example does everything you need to do for the digital input; the only thing you need to change to the source input of the DAQmx Timing VI for the analog input task. Right click the source input and create a constant, then choose the PFI line you want to route your external trigger in on.
At this point you'll have a program that uses your external sample clock and you have the ability to add a digital output task that will be synchronized with your input. To add this digital output task I would suggest the Cont Write Dig Port-Ext Clk-Non Regeneration.vi example. If you copy this example into the other one and merge the two while loops you'll only have a few modifications to make.
Here are some things you'll need to change:
1. Route the same analog input sample clock to the source terminal of the DAQmx Timing VI for the digital output task.
2. Buffer the output with the data you want by changing the data input to the DAQmx Write VI.
Non-regeneration keeps the digital output from looping previous data. This will allow you to know if you are buffering output data fast enough. If you have trouble running this loop with your analysis then I would recommend implementing data pipelining. For an overview of what pipelining is please see this article: http://zone.ni.com/devzone/cda/tut/p/id/6425
In general control loops are not recommended on Windows operating systems. However, depending on the analysis you're doing, your computer, and what loop rate you're looking to get it can be possible with good programming techniques. The fastest I would recommend trying to execute your loop on a Windows OS is on the order of 10ms (give or take depending on your computer and analysis). If you need to execute this control loop faster than 1ms I would recommend considering a Real-Time operating system. We have benchmarked PID control loops on Real-Time operating systems at more than 30 kHz.
I hope this helps get you started, and if you'd like to talk with someone at National Instruments about Real-Time control loops feel free to contact us directly using the information at www.ni.com/contact.
Have a great day!