Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

10-06-2016 01:50 PM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

The funny thing and is the main reason I'm not satisfied with this equations is that If I substitute a value above 50 (degrees), the

calculated resistance its not even close to the real one (from thermistor table). So I'll try the equations you generate and see what happens.

Even thought I'm still figuring out how to use the NONLINEAR VI.... For example I have the next Steinhart-Hart equation:

1/T = A+B*Ln(R) + C*Ln(R)^3

I've calculated parameters A, B, C:

A=1.126249 e-3

B=2.345631 e-4

C=0.862140 e-7

I have my X and Y and initial parameters ready. But how do I use this function... Haven't figure it out where to specify the model I'm a bit confused at the moment...

Solution

Accepted by JLuna

altenbach

Knight of NI

10-06-2016 01:52 PM - edited 10-06-2016 01:53 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

The curve looks much nicer if you take the log of the Y data (and transform back later). Now a 3rd order polynomial is plenty (Just a slight "banana") and you don't get these negative values towards the end.

Download All

Virus scan in progress. Please wait to download attachments.

altenbach

Knight of NI

10-06-2016 01:58 PM - edited 10-06-2016 01:59 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

The nonlinear equation is basically a third order polynomial using the log(y) and setting the quadratic term to zero. There is no need to complicate things and use levenberg marquardt.

@JLuna wrote:

I have my X and Y and initial parameters ready. But how do I use this function... Haven't figure it out where to specify the model I'm a bit confused at the moment...

There are two flavors of the nonlinear curve fit, one using VI model (preferred) and one using a formula. There are plenty of examples that ship with LabVIEW, just look at them!

10-06-2016 02:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

I just want to know which gives me the most accurate equation...

Many thanks btw 😄

altenbach

Knight of NI

10-06-2016 02:28 PM - edited 10-06-2016 02:52 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

@JLuna wrote:I just want to know which gives me the most accurate equation...\

How accurate are the table values? They have an error too!

Both methods will be similar. the third order polynomial to log(y) is easier to use. The Steinhart-Hart equation inverts the formula buts omits the quadratic term and you need to first rewrite it to solve for R(t).

You simply need to test it. For example if you do my log polynomial and change the order to 5, the maximum difference is below 100 while the values are hundreds of thousands! This is well below your 2% specification (0.04%). Even the third order as suggested earlier gives a max deviation below 0.4%, good enough!

Here's an example for the 5th order (use the right y axis for the scale of the difference between data and fit)

And here's the difference **in percent** of the reading:

Download All

Virus scan in progress. Please wait to download attachments.

10-06-2016 04:26 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

I'm analizing the VI you shared, with log and power of 10 functions. Can you explain why did you choose to do that: first go for

LOG10 then after using the Polynomial Fit, you introduced data to the POWER10 function.

1 Question came up to mind. You have the POWER10 function affecting ONLY the output "Best polynomial Fit" and you did this

to be able to see the entire graph correctly... right? Because without it, the Polynomial Fit throws small values due to the previous

Log10 function. So the thing that confuses me is:

Why is the POWER10 not affecting the Coefficient values output...??

Solution

Accepted by JLuna

altenbach

Knight of NI

10-06-2016 05:26 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

We are fitting the log of the data to a polynomial, thus we need to reverse that to get it into the original mapping. The log is safe because we (hopefully!) never have a negative resistance.

The polynomial coefficients will be correct for the log of the data, so you also need to do 10^x after polynomial evaluation when calculating interpolated data.

10-07-2016 09:19 AM - edited 10-07-2016 09:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Good day altenback,

I'm still a bit confused or more like I haven't quite understand 100% (more like a 80%...) how did it ocurred to you that using a log10 (the power of 10 comes obvious, to get back to the original mapping) would work like a charm. The next is what I understand from this LOG10 method:

- Because the resistance values are so big (almost taking values of 800kohms) if we try to fit this values into a Polynomial equation, when we get to smaller values (for example: 2kohms) the polynomial fit tends to give us possibly negative values. So

the purpose of the LOG10 method is to work only with positive and small values, so this way the Polynomial FIT analysis tends to give out more accurate POLYNOMIAL COEFFICIENTS... This polynomial coefficients are the "small answer" due to the LOG10; in order to get the real values we have to POWERTO10 the previous values...

So I'm a right, did I get the big picture? I just want to fully understand your explanation. To know when and where apply logarithms, succesfully, pretty awesome way to go \m/.

Thanks for your support I really appreciated @altenbach,

Regards,

altenbach

Knight of NI

10-08-2016 01:49 AM - edited 10-09-2016 12:06 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Yes, the original Y data covers about three orders of magnitude. If you change the mapping of the y axis to logarithmic, it immediately looks much more tame, basically a line with a slight curvature. Obvously, this is much easier to describe with a low oder polynomial. (If it were a pure single exponential, it would be a straight line in the log mapping).

A polynomial is typically a descriptive tool and the coefficients often don't have a direct scientific meaning. So if taking the log makes the curve more suitable for polynomial fitting there is no reason not to use it. Note that you can use the natural log (base e) or log10 (or any other base), it does not matter as long as you undo it the corresponding way later.

Note that you probably want to convert from resistance to temperature (and not the other way around), so just swap the x and y inputs and take the log of the resistance.

Attached is a simple draft for one of your datasets.. when you run it(and whenever the order is changed), it calculates the polynomial of the desired order, then you can select any resistance and read the corresponding interpolated (or extrapolated) temperature. Modify as needed.

(also note that if you don't take the log, the polynomial fit will probably fail.)

altenbach

Knight of NI

10-08-2016 11:58 AM - edited 10-08-2016 01:17 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Of course with a bit more effort you can implement a nonlinear fit to the Steinhart-Hart equation. Now you get much better than 0.02 degrees difference with only three parameters. (The disadvantage is that you need to create a model VI and have reasonable parameter guesses for the fit.)

Download All

Virus scan in progress. Please wait to download attachments.