LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LQR controller with NI-6211 trying to speed up "while" loop

I'm trying to implement LQR and LQG controllers on a NI-6211 board.  Using the DAQ Assitant wasn't giving me the speeds I need (I'm looking for at least 200Hz) so I tried implementing the read and write operations from scratch (the DAQmx function blocks).  I've still only been able to reach ~100Hz  and the first second or two only processes at ~60Hz.  I haven't even implemented any of the matricies or Kalman Filter.  Is there any way to speed up the while loop?  Here's what I have at the moment.

 

 

 

FastAIAO.JPG

 

While I'm at it, I also SOMETIMES get somekind of buffer error when I stop and the output file occasionally has repeated times in the time column (I assume that latter is from the clock not updating, but I was wondering if there's a way to fix it).

0 Kudos
Message 1 of 2
(2,643 Views)

Hi aeson25,

 

One way to speed up your While loop is to replace Write to Measurement File VI with basic file I/O functions.Have a look at the following examples on how this can be accomplished:

 

Read/Write into Text File

 

Read/Write From/To Binary/Text File

 

The key in those examples is that you open a file refence outside your While loop, then you write to file in your While loop and then you close the file reference once you exit the While loop. Also how are you measuring that the speed of your processes is ~100Hz. You might want to insert a simple performance benchmark in your code or a timestamp for the samples logged in your measurement file to get a more accurate measure of performance.

Also, currently your code uses software timing, that is you rely on your OS clock for timing. You might want to consider using hardware timing to get more control over sampling operation. Here is a brief explanation of key differences between software and hardware timing:

 

Software timing: Measurement is done in the way, that you use a function in the software to read/write.Then the command is sent to the DAQ board, and then operation is performed - board starts AD/DA conversion. It is usefull for slower applications, when you don't need precise timing.
 
Hardware timing: DAQ board is timed by internal HW clock. It means, that all AD/DA conversions run based on hardware clock (very precise compared to software). Measurement is then put directly to the buffer.

 

Mikhail
RF Toolkits, Product Support Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,609 Views)