LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Are there different kinds of references to VIs? Does this example need to be so complicated?

Solved!
Go to solution

"Constrained Nonlinear Curve Fit.vi" requires some other VI implements the form of the model that is to be fit, and needs a reference to that VI as one of its inputs.

 

It seems like there are multiple kinds of references to VIs - why? What are they and how do you know which to use?

 

I've attached a vi that does curve fitting with the above mentioned vi, and it also sets up the reference to the other vi which contains the model, also attached. Per the comments, I thought some simple reference pointing at the model vi would be all it needs, but it seems to need a dynamic reference to that which has been modified by typecasting to another type of vi reference. At least, if I understand this right.

 

Can anybody shine the light on this or aim me at someplace helpful? Notice I have already seen some context help for creating references to vis.
That's where I got my instructions.

0 Kudos
Message 1 of 8
(3,488 Views)
Oops. Here they are.
Download All
0 Kudos
Message 2 of 8
(3,485 Views)
Oops again. Misplaced a name change, sorry. It's a wonder any of these do anything right.
0 Kudos
Message 3 of 8
(3,477 Views)
Solution
Accepted by topic author cebailey

cebailey,

 

If you right click your Static VI Reference and select "Strictly Typed VI Reference", then you will be able to wire it into the Constrained Nonlinear Curve Fit VI.  The Curve Fit VI uses a Call by Reference Node, which only accepts strictly type references (specific to a particular connector pane).

 

Here is some more information from the LabVIEW Help about Static VI References:

http://zone.ni.com/reference/en-XX/help/371361E-01/glang/static_vi_ref/ 

 

Chris M

Message 4 of 8
(3,473 Views)

Seems you got your answer already. 🙂

 

As an additional comment you would save yourself a lot of work leaving optional terminals disconnected. Connecting diagram constants with default values just clutters the diagram unless you plan to change them later. Also, your model does not even need a FOR loop and you don't need to wire the indices of "index array" if you want them in order starting with zero.

 

Here's how the model could look like:

 

Message Edited by altenbach on 03-11-2009 11:27 AM
Message 5 of 8
(3,452 Views)
Ah, that does it. Thanks for the link, too.
0 Kudos
Message 6 of 8
(3,425 Views)

About the for loop - I tried it your way and saw it work. But the template they suggested to work from has the for loop. I don't know why. Using a for loop is an easy way to create arrays to feed the curve fitting vi at X and Y, like I did with the bit pasted on the left.

 

It makes more sense, if the model doesn't have the for loop. I wonder if I gave the curve fitter 6 points or 36? Must look.

 

Hey, thanks for pointing out that index array doesn't need indices to go 1, 2, 3.... I have to confess to converting arrays to clusters and using unbundle to get the opposite of Build Array, when nobody is looking. You just saved me a lot of foolish work!

0 Kudos
Message 7 of 8
(3,422 Views)

cebailey wrote:

Hey, thanks for pointing out that index array doesn't need indices to go 1, 2, 3....


Careful now! Unwired it will go 0,1,2,3 .... The first element is #0. (This is not e.g. matlab where the first element is #1)

If you want to go 1,2,3,4 for example, all you need is wiret a "1" to the first index and the rest will increment. Basically any unwired index will be one higher than the terminal above it.

 

For example, the following code would give you elements 2, 3, 4, 5, 10, 11, 12

Message Edited by altenbach on 03-11-2009 04:03 PM
Message 8 of 8
(3,409 Views)