12-01-2008 01:55 PM
I need help with optimizing my code for speed. I'm running my code in labview 8.5 with an NI PCI 6259 M series card and BNC 2120. I'm reading one analog channel, and writing two (one constant enable voltage, and the other from a closed loop PD controller I'm running). On a fast computer, I can only run at about 400Hz. I'm monitoring loop time, and it goes up as I try to run at 500Hz and up. Removing a few waveform charts from the front panel helped a lot, but this is still too slow.
Maciek
12-01-2008 02:53 PM
You should use 'Continous' acquisition instead of 'Hardware timed single point'.
That should do the trick.
Ton
12-01-2008 05:13 PM
Sorry, I am not a "hardware guy", so you should listen to Ton. 🙂
Programming wise, you do a couple of things very inefficiently, for example you retain a history by building an array then trimming it back to the original length using "array subset". Use a fixed size array and do things "in place". You can keep the number of "valid" elements in another shift register for the average calculation.
Have you also looked at the PID toolkit? Are you running this on an RT system or under windows? For really fast control, FPGA can easily go into the MHz.