LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rapid computation of exponential decay constants

Solved!
Go to solution

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

0 Kudos
Message 1 of 5
(4,122 Views)
Thanks for posting the VIs and references, looks quite interesting. I've been calculating decay constants of very slow geophysical processes using other software and will see if I can try these instead. Unfortunately I personally don't have anywhere near the LabVIEW experience to help you with your particular inquiry.
0 Kudos
Message 2 of 5
(4,110 Views)
Solution
Accepted by topic author cirrusio

Hi Matt,

 

after changing the summation loop in your LRS calculation the routine runs as fast (or faster) as the DFT variants... Anyway: check the results to be sure it's still correct!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 5
(4,105 Views)

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  

0 Kudos
Message 4 of 5
(4,092 Views)
Thanks to both GerdW and Lynn; Lynn, I'd give ya kudos, but you were scooped Smiley Wink.  Ya, I realize that the timing would be more precise without all of the controls and indicators, but, at the speeds I am looking for, their impact is pretty minimal.  And as far as the built in exponential fit routine goes, the relative performance is expected given the fact that the solution is iterative.  Right now, on my dual core I am getting computation times of about 200 us for the LRS and 150 for the DFT-5.  For those interested, I will probably post the final solution in the AIRS group.  Cheers, Matt
0 Kudos
Message 5 of 5
(4,072 Views)