LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exponential Fit.vi Does Not Fit Well

Solved!
Go to solution

Attached is an attempt to use the "Exponential Fit.vi" to find the time constant the settling times so the PID loop parameters can be calculated from this open loop data. The orange line is the data I am trying to fit. The blue lines is the fitted data output from "Exponential Fit.vi". This data is the temperature difference across a thermoelectric cooler element in response to a step change in current. I know the response will not be exactly exponential because this response is actually the sum of many exponentials as the heat finds different paths. But all I need is a rough idea of the time constant of the dominant rise, and that will be good enough.

 

There are four fits that begin when each step response begins. The result of each fit is way off. The fit does not start at the same temperature the step response does. And the curvature is the reverse of the fitted data. What could be wrong here? Is there a better vi to use to get this exponential time constant?

 

I am using default settings for all inputs to "Exponential Fit.vi".

 

0 Kudos
Message 1 of 10
(5,470 Views)

From my experience I have had pretty good results from using the exponential fit VIs. And with the relative clean data that you are getting I would have expected you to be getting very good results.

 

That said however, there is not really a lot of help that can be provided from looking at just the plot of your results. If you could provide the VI that you are using to fit the curves to your data and some example data then you would be more likely to get valuable help from the community.

 

Failing that you should just be able to threshold the waveform at the target level (assuming you know the previous and end level, what your target percentage [63%] is) to find your time constant.

0 Kudos
Message 2 of 10
(5,443 Views)

Hi Artst,

 

What could be wrong here?

Wrong: You did not attach your VI!

How should we debug your VI by using just an image of the frontpanel?

 

That being said: For exponential fits you need to adjust the "initial guess", especially the offset. THe offset is set to zero by default, but in your case you need to allow a range of ±10…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 10
(5,420 Views)

You need to understand some things about fitting curves to data before you simply "plug in" data to a curve-fitting routine!  Here are some suggestions:

  • Learn what a (decaying) exponential looks like.  In particular, learn what the asymptote means (a "pure decaying expontial", a*e^(-t/tau), will asymptote to 0).
  • Learn how to turn a decaying exponential into a rising exponential.
  • Think about what to do with data that appears consist of several exponentials over different time segments.
  • Think how to get (good) estimates for a and tau from an exponential.  (Hint -- why is tau called "the Time Constant"?).

Before starting to code, think about the nature of the problem and see if there are "big steps" that you might want to take before tackling "some of the details".  My suggestion would be that a "Big Step" would be to isolate a section of your data that contains data consistent with a single exponential, while the "detail" would be fitting that data with an exponential.  Something to think about -- if your data starts at t0 and runs until t1, what do you have to do with the data to fit the "standard Exponential Model" to it?  Hint -- at what time does the Model start?

 

I hope you see that the problem consists of multiple steps, big ones and smaller ones, and I hope this suggests some LabVIEW structures (loops?  sub-VIs?) that match the Problem Structure.

 

We do need to see your code in order to help you, but you might consider "helping yourself" by trying to organize your thoughts and methods first.

 

Bob Schor

0 Kudos
Message 4 of 10
(5,388 Views)

I have created and attached an abreviated VI that demonstrates the problem.

 

The data to be fitted to has a mostly positive derivative, and it starts at zero where it rises in the positive direction. So I expected the damping to have a negative value, the amplitude to have a negative value, and the offset to be positive and nearly equal to the absolute value of the amplitude. But this is not the result.

 

0 Kudos
Message 5 of 10
(5,375 Views)

Sigh.  The "standard" Exponential Model, a*e^(-t/tau), I called a "Falling Exponential".  Consider (and draw for yourself, so you will understand) the function a*(1-e^(-t/tau)), and come up with a name for this variant on the Falling Exponential.  See if that gives you a clue.  You really need to understand functions and math better before you start thinking about fitting.

 

Bob Schor

0 Kudos
Message 6 of 10
(5,359 Views)

Can you save VI for 2011 version? 

Your parameter expectations are correct (for the first segment of the graph), I wonder if you have set the limitations wrong.

0 Kudos
Message 7 of 10
(5,351 Views)
Solution
Accepted by topic author Artst

Your data has a big offset, so you need to make sure that the offset is not fixed (by default, it is fixed at zero!). Change the bounds of the third parameter to [-inf..+inf] and the rest will fall into place.

 

 

 

 

Download All
Message 8 of 10
(5,345 Views)

Hi, I have a similar but more complex problem. In one word, can I fit my data with a function of "A1*exp(B1*x)+A2*exp(B2*x)+C" using the provided VI in labview? All I need is the same setting as standard Exp fit Vi: x-y data input and all parameters (A1,B1,A2,B2,C,fitted curve etc) output. 

 

By the way, I already tried the CurveFit.Vi. It does not help a lot.

 

Thanks, 

0 Kudos
Message 9 of 10
(2,446 Views)

Please start a new thread for a new problem instead of appending to an ancient thread that is already marked as solved.

 

If you want more than one exponential, you need to use nonlinear curve fit and write your own model. Not difficult. (start reading here)

 

If you want more specific help, attach your VI and some typical data.

 

Be aware that the problem can become poorly defined, e.g. if B1 and B2 become virtually identical, A1 and A2 will become highly correlated, etc. You always get at least second solution by swapping the two As and the two Bs.

0 Kudos
Message 10 of 10
(2,441 Views)