A typical control loop acquires one point, processes it, and generates an output. You can easily implement a true real-time control loop in LabVIEW by directing the scan clock to the update clock or vice versa, so that both analog input (AI) and analog output (AO) share a clock, ensuring that AI and AO occur exactly at the same time. The disadvantage to this method is that each update (analog output) actually depends on the scan (analog input) that occurred one loop iteration ago. However, because it is impossible to scan, process, and update the data at the same time, you need to introduce a delay between the scan and update to process the scan and update accordingly. Because both clocks share the same clock source and therefore are tightly connected, this delay is known (usually one clock cycle) and therefor you can take care for it in your control algorithm. Assuming that you use continous control algorithms, this one cycle delay is no problem as long as your desired looprate is approx. 5-10 times faster than the fastest dynamic of the process that should get controlled.
Optimized Hardware-Timed PID Loop
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3E93B56A4E034080020E74861&p_node=174823&p_source=external
The timing and triggering functionality of the RTSI bus on our DAQ HW is used to internally route the analog input scan clock to the analog output update clock. As a result, the analog input scan clock serves as the “master” that determines loop cycle time and provides sleep.
During the first iteration of the control loop, the scan clock initiates the analog input value to be sampled. The data is brought into software where a PID calculation is performed and the analog output value is written to the board. At the next rising edge of the scan clock, the analog output channel is updated with the value from the previous iteration and a new analog input value is read.
This example uses analog input and analog output on the same board; however, the same technique can be used with RTSI and PXI to synchronize input and output events on multiple boards.
Loop cycle time with this implementation can be specified in terms of microseconds. As long as your control code (including the time it takes to talk to the IO) can be executed within the amount of time, specified by your desired looprate, your external process just sees the HW Jitter of the IO HW clock which is in the range of nanoseconds.
Depending on your control algorithm, 1/8000 sec shouldn't be a problem with your HW. We achieve up to 1/40000 sec for one PID with this HW (single input /single output).
Regards
Stephan A.
System Engineer Control & Simulation
National Instruments