03-16-2006 03:01 PM
I am trying to control a piezoelectric motor using an analog +/- 10V command signal and a PID controller implemented in LabView 8. The program is essentially a timing loop set to run at a specific frequency using one of the hardware clocks on an NI PCI-6221. I set the frequency to 1 kHz. The actual loop execution time (as determined by comparing subsequent values of the 'Global End Time' from the timed loop) is 4-5 ms for two consecutive iterations, followed by a third which takes 11-12 ms. I understand that the loop will not actually execute at 1 kHz, since the amount of computation within the loop will give it a finite execution time. However, I'm uncertain why every third iteration has a much longer execution time. This long time step is leading to some pretty serious stability problems, particularly when I try to move to higher frequency oscillations. I've invested a considerable amount of time and all available funds into getting this thing to work. I'd hate to have to shell out more money that I don't really have to purchase a hardware controller (e.g. Galil), in addition to putting in the time required to learn the relevant language. Any help in getting the timing consistent would be greatly appreciated.
Thanks
Matt Reilly
03-17-2006 01:49 PM
03-17-2006 02:37 PM
03-17-2006 03:20 PM
03-17-2006 03:41 PM
03-17-2006 03:56 PM
03-17-2006 04:02 PM
03-20-2006 09:01 AM
03-20-2006 09:43 AM
I'd recommend using a Timed Loop for your main control loop. Timed Loops are set to run with a particularly high execution priority, higher than the parallel loop you'll set up to accumulate and perhaps save your data. Even a timed loop won't give you perfectly consistent 1 msec loop intervals, but the deviations are a bit more likely to be smaller and less frequent.
Another add-on thought is to use the data acq sampling clock as a Timing Source for the Timed Loop. I don't think it improves determinism, but it might give you a more precise measure of your actual loop interval times. Perhaps knowledge of the actual loop time can be taken into account for your control algorithm? That should make you a bit less prone to instability in your control algorithm.
I would have suggested that the main Timed Loop write data directly to a Queue but johnsold's idea may well be faster. It sounds like it would be.
-Kevin P.
03-20-2006 06:44 PM
Thanks for the suggestions guys. I had previously been using the "Write to spreadsheet" VI. By using the VI profiling tool, I saw that this VI actually opens, writes to, then closes the file every time through and this was slowing things down considerably. I picked the parts that I needed out of this VI and trimmed things down. Now it's recording my data every time the loop executes and still runs at very close to 1 ms per loop iteration.
Thanks for the help everyone. I can post my program here if anyone is interested.
Thanks
Matt