LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Lev-Mar non-linear curve fit ignores model input

Solved!
Go to solution

I am using the Lev-Mar non-linear fit to fit two curves of data in the same VI.  However, the second time I call the Lev-Mar VI, it ignores the model and continues to use the first model.  When I run Lev-Mar outside of my VI, it can fit both sets of data correctly using the two different models.  How can I get the VI to use the correct model the second time I call it in my VI?

 

  I am using Labview 8.0 on windows XP.

0 Kudos
Message 1 of 9
(3,793 Views)

glor12 wrote:

I am using the Lev-Mar non-linear fit to fit two curves of data in the same VI.  However, the second time I call the Lev-Mar VI, it ignores the model and continues to use the first model.  When I run Lev-Mar outside of my VI, it can fit both sets of data correctly using the two different models.  How can I get the VI to use the correct model the second time I call it in my VI?

 

  I am using Labview 8.0 on windows XP.


Lev-Mar non-linear fit is NECESSARILY re-entrant.  Play with the "Pre-alocate clones" option to get the desired action.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 9
(3,783 Views)

The LabVIEW 8.0 version of the nonlinear curve fit (formul string model) has a bug in that the formula is parsed only on "first run?"!

 

This was fixed in LabVIEW 8.2.

 

If you cannot upgrade and you are adventurous, you can fix it yourself. Just make a copy of the VI and save it elsewhere.

I would not modify the VI.lib version. Basically, you need to re-parse the model whenever the model changes instead of only on "first run?".

Message Edited by altenbach on 12-03-2009 07:27 PM
Message 3 of 9
(3,775 Views)

altenbach wrote:

The LabVIEW 8.0 version of the nonlinear curve fit (formul string model) has a bug in that the formula is parsed only on "first run?"!


Here's a quick comparison of the 8.0 and 8.2 version of "LM formula string function.vi".

 

The 8.0 version uses the "first run?" primitive, and thus parses the formula only once per session and then never again, even if the function changes it keeps using the originally cached model.

 

As you can see, the 8.2 correctly parses the formula whenever the "function parameters" variant changes.

 

(Briefly, the function is compared with an uninitialized shift register and if the values differ, the model is re-parsed. The new function parameters are fed into the shift register on the left, for comparison at the next call. Typically, the comparison inputs are equal (not equal=false) and the cached formula is used.)

 

 

 

Message Edited by altenbach on 12-03-2009 07:37 PM
Message 4 of 9
(3,772 Views)

A quick fix would be to replace the "first run?" primitive with a feedback node, e.g. as follows:

 

 

 

From a historical perspective, I identified that problem back in mid 2006. 😄

 

See the original discussion and a link to download a corrected version.

 

(CAR# 3XHB2IQO)

Message Edited by altenbach on 12-03-2009 07:51 PM
Message 5 of 9
(3,766 Views)

Every once in a while I can post faster than Christian Smiley Happy

 

I should learn Smiley Sad

 

Thanks for the DETAILED info !


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 9
(3,730 Views)

Jeff Bohrer wrote:

Every once in a while I can post faster than Christian Smiley Happy


Except the problem had nothing to do with any reentrancy settings. 😮 😄

0 Kudos
Message 7 of 9
(3,723 Views)

Thanks for all the help!

 

One more question, how do I save a version of the LM non-linear fit so I can add the repairs?  It asks for a password, and I saw that you asked for a work-around in 2006.  Has one been found?

0 Kudos
Message 8 of 9
(3,719 Views)
Solution
Accepted by topic author glor12

The VI itself is not passworded, but it is part of a passworded library, indirectly blocking the operation. 

 

You can always select all the code and copy it into a new VI, the hook up all the connectors.

 

You can also browse to the VI using explorer and copy it out. Give the copy a new name, open it, and disconnect from library (file menu) to fix the broken arrow.

 

I think you can also edit the original in place and hit "save". This does not need a password and will overwrite the existing VI. Make no mistakes here!

Message Edited by altenbach on 12-04-2009 08:56 AM
Message 9 of 9
(3,709 Views)