10-28-2015 08:33 PM
Hey everyone
I’m trying to do a 5 by 5 matrix inverse in labview FPGA. However I can’t find a existing function or library can do the job. I wonder if anyone has some experience on this kind of program? Or if NI has some already build library for this.
Thank you
Regards
Jia
10-29-2015 10:33 AM
Good idea to move this topic to it's own thread. Let me do the same with my reply. . .
Primarily, I recommend that you take a look at reformulating the problem mathematically to eliminate the need for matrix inversion altogether (i.e. using a direct form solver). Matrix inversion can be numerically problematic.
If inversion is required, I recommend you perform the matrix inverse on the real-time processor and pass the inverted matrix to LabVIEW FPGA. Matrix inversions, even for a relatively small matrix like a 5x5, can be problematic in single-precision math because a single coefficient is multiplied by other coefficients many times resulting in accumulation of numerical error. Therefore, double precision math is strongly recommended for matrix inversions.
Here is a screenshot showing an example (from the open source Multisim circuit netlist to LabVIEW FPGA real-time SMPS circuit simulator project.) You can find the Inverse Matrix VI in LabVIEW RT/Windows by right-clicking on the block diagram and going to the Mathematics>Linear Algebra palette.
If you do have to perform the matrix inversion at FPGA speeds, the most likely way to implement it would be to do the 5x5 matrix inverse symbollically (using a computer algebra system such as Mathematica) and then implement the equations graphically in LabVIEW FPGA (using non-reentrant subVIs from the floating point algorithm engineering toolkit to share resources). Use IP Builder (a high level synthesis tool that's included with LabVIEW FPGA) to create an efficient FPGA implementation that meets your latency constraints. (See my post here for IP Builder examples by Brian_K.) Even then, you'll need to validate each solution against a double-precision floating point version executed on Windows or RT.
I hope this is helpful! Please keep us posted on your developments.
10-29-2015 03:02 PM
Thank you
Another question is I have a piece of VHDL code which can do 5 by 5 matrix inverse. Is there a way that I can bring that piece of code in to labview to create some kind of VI so I can use it in labview?
regards
jia
10-30-2015 02:57 PM
You bet. Yes, you can absolutely incorporate VHDL and Verilog code. See here for tutorials: