Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Why do I have a rate-independent delay in my PID Loop?

I am preparing to use an ETS Realtime target to do some fast PID loops. I have a 3 GHz P4 machine with a PCI-6259 DAQ card, ruuning LabVIEW 7.1RT with NI-DAQ 7.3 for the PCI-6259 board. For starters I decided to just do some speed tests, with the AO putting out exactly the value measured by the AI, with no PID calculations. I would expect the output to be an exact duplicate of the input, but jagged and with a small delay of approximately 1 loop time. What I see on the scope is that there is a fixed 0.1 msec delay between the input and output that is independent of the loop rate. I can run the loop up to 100 kHz rate. With this fast loop rate the output is a faithful replication of the input, but shifted by 0.1 msec. This delay will cause big problems in a real PID loop, since this is several sample periods. At first I thought that there was a buffer that was delaying the samples, but if that were the case the delay would be proportional to the sampling time and not independent of it. The delay is not in the loop itself, which can operate up to 10 times faster than the observed delay. I have attached the vi and configuration sub-vis. Please tell me what I am overlooking here.

Thanks,
Rich
0 Kudos
Message 1 of 7
(4,564 Views)
Richard,

I haven't tested your VI, but I think the acquisition mode is at the root of the issue. NI-DAQmx 7.2 and later has an acquisition mode that is meant specifically for control applications called Hardware Timed Single Point. I suggest that you use this instead of Continuous Samples, which is meant for a buffered type of acquisition. Take a look at the example located at C:\Program Files\National Instruments\LabVIEW 7.1\examples\DAQmx\Control\Control.llb\PID Control-Advanced.vi.

Let us know how it turns out,

Gerardo
0 Kudos
Message 2 of 7
(4,544 Views)
Gerardo,
That seems to have fixed my problem. For some reason the "DAQmx Timing" vi that I had been using did not have the "Hardware-Timed Single Point" choice in its constant. I deleted the vi and added it again and now that choice is there, so I must have had some hangover from an old version of LV or NI-DAQ.

Thanks,
Rich
0 Kudos
Message 3 of 7
(4,536 Views)
I am looking to run a very similar application with the same card, a similar computer, and do PID control. I'm amazed you were able to get a loop rate of 100 kHz even if it wasn't doing anything real! NI quotes 1 kHz max loop rates in most of its documentation, though I suspect most of it is quite old. I'm interested in what rate you were finally able to achieve with the PID control. I would also be interested in seeing the PID/DAQ communication part of your could if you are able/willing to share it. I was hoping to get 4-5 kHz with at least one channel and hopefully more.

Thanks,
Aaron
0 Kudos
Message 4 of 7
(4,375 Views)
I eventually got a PID loop rate of 22 kHz for 4 channels! I have attached a zip file with the vis. "Dual RF Feedback.vi" is the one that runs on the ETS target, and it calls "RT Quad PID Loop.vi" The host runs "Remote Gain Control.vi" to set the PID gains via a TCP connection to the ETS target.

Rich
Message 5 of 7
(4,373 Views)
Wow!!! I'm really impressed with the result you got. My only comment beyond that is you didn't get the zip file attached. Just out of curiosity, did NI suggest this solution or did you decide to try it on your own? NI has been suggesting a dual servo card and DAQ card setup, but you've demonstrated that I don't need that. Thanks. You've saved me some money and gave me a good target to shoot for.

Aaron
0 Kudos
Message 6 of 7
(4,362 Views)
Here's another try to attach the files.

Rich
0 Kudos
Message 7 of 7
(4,358 Views)