08-06-2009 01:12 PM
Hello all,
I am attempting to develop a routine that rapidly computes the exponential decay constant of a given waveform. I am using two different techniques involving the computation of DFTs and another using corrected successive integration (LRS). Both generally give the correct time constant for the input waveform even with a significant amount of noise. The LRS solution is significantly less susceptible to noise (highly desirable) but considerably slower (the DFT computations run on the order of 10s of microseconds for a 1000 pt waveform while the LRS, as coded in Labview, runs at about 1.5 ms). The LRS technique was developed by researchers at George Fox University in Oregon and they claim they were able to achieve computation times on the order of 200 us for both techniques. I have been unable to achieve this time with the LRS technique (obviously) and have attempted to code this in C and use a Call Library node to call a compiled dll. However, at best, I get a factor of 2 increase in speed. In addition, additional computations using the dll seem to be additive - i.e. for four similar computations running in the same structure with no dependency on each other, the total computation time is approximately 4x that of one. For my purposes, this is insufficient as I will be attempting to make these calculations 8x at 1kH.
Looking through the discussions, I have been unable to ascertain whether I should expect a performance boost for well written C over well written Labview (most seem to ask why would you want to do anything external). Anyway, I have attached the code so you can be the judge as to whether it is well written or if there can be any improvement in performance. The main function is Test Analysis Methods.vi which generates an exponential waveform with scale, offset and noise and then the decay constant tau is calculated using the VI Get Tau.vi. In addition, I have attached the C code as well as the dll for solving the LRS equations. These were coded in Labview 8.6 and the C was coded using the latest version of Microsof's Visual C++ Express Edition. Themain VI uses the FPGA module VI 'Tick Count' to determine the computation rate in microseconds, so if you don't have this module you will need to remove this code.
Any thoughts are appreciated. Thanks, Matt
Solved! Go to Solution.
08-06-2009 02:04 PM
08-06-2009 02:43 PM
08-06-2009 03:16 PM
I came up with exactly the same improvement as GerdW. The LRS with the speeded summation was slightly slower than the DFTs. I also tried the Exponential Fit.vi. It takes much longer than the LRS or DFT code by about a factor of 10.
It is usually better to do the timing with all controls and indicators outside the frame. Maybe it does not matter on the FPGA module, which I do not have.
Lynn
08-06-2009 04:39 PM