LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sine-fit algorithm

Try this quick draft. (sorry, I did not triple check for units, etc.)

 

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 11 of 17
(2,008 Views)

Thanks,

 

I correct my mistake and use your example and the sine-fitting works. The algorithm works fine (good convergence) but it's long (6 seconds to find the solution). It exist solutions or options to speed up the algorithm (and maybe lost in precision) ?

 

Regards,

 

Benjamin

 

Remarks : just a little mistake in "Test sine-fittingMOD2 Folder.zip". It calculate 1/Fsample instead of Fsample, so the value of frequency found by the FFT analysis doesn't works (but in my sample data, Fsample = 1, so there is no difference ! ).

0 Kudos
Message 12 of 17
(1,983 Views)

@benj wrote:

I correct my mistake and use your example and the sine-fitting works. The algorithm works fine (good convergence) but it's long (6 seconds to find the solution). It exist solutions or options to speed up the algorithm (and maybe lost in precision) ?


It executes pretty fast on my computer, but you hopefully noticed that the initial estimates from the "detect single tone" would be equally good for all practical purpose. Use those and forget about the nonlinear fitting. It does not add any real value in this case.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 13 of 17
(1,978 Views)

Hi,

 

I don't want only an estimation of the frequency but I need to fit my data in order to have information about residual rms error between observation-data and fit-data to calculate ENOB (effective number of bits). So, it'is possible to speed-up the fitting alogritm ?

 

Regards,

 

Benjamin

0 Kudos
Message 14 of 17
(1,961 Views)

In my demo I already show how to calculate the function from the outputs of extract single tone (using call by reference node).

 

Now use this as the best fit and you can calculate your RMS error (and anyting else) by comparing to the raw data.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 15 of 17
(1,958 Views)

@altenbach wrote:

Try this quick draft. (sorry, I did not triple check for units, etc.)

 

 


A bit old post, but anyway, dear @altenbach, thanks for posting this example. On my laptop with i7-6700 and LV2019 the function "Extract Single Tone Information VI" executes for about 2ms for 16k input samples. This is more than 2 orders of magnitude faster than non-linear curve fit (~260ms). For 1.6k data length I get less than 1ms. This is exactly what I need, I will try this on cRIO NI-9035 and hopefully it work for my real-time application.

0 Kudos
Message 16 of 17
(240 Views)

Of course extract single tone would be much faster than any iterative fitting procedure, especially if export mode=none (you can look inside to see what it does!). Depending on the needs, a simple FFT followed by R(max), might be sufficient and even faster. 😄

 

Fitting to a sine function is not the same as extracting a single tone. Giving reasonable initial guesses, fitting will continue to work even if the data consists of only a partial period, so the use case is very different.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 17 of 17
(233 Views)