VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Inputs versus Parameters in models

Hi, 

 

I have a very simple model that can do three things as defined by a ModelAction control: it either have the input directly fed through the ouput, or adds noise, or multiplies the input by 0.5 and substract noise.

model.jpg

 

If I defined ModelAction, Signal Input, and Noise Level (&) as Required in the connector pane, all three appear as  Model Inputs in the VS System Def. file.

ModelAction would be user-defined, same for the noise level. For the signal input it could either be a user-defined, or an actual AI channel.

 

This is where I am getting somewhat confused. Shouldn't model inputs always be linked to hardware channels? And parameters to user controls?

From the VS Workspace, I can drop controls linked to all 3 :  ModelAction, Signal Input, and Noise Level (&) and run the model.

 

In the LV API though, one can only access model parameters. 

model palette.jpg

 

So I presume I would have to use the Workspace API to Set a Channel instead if it was defined as a Required/Model Input.which may be counter intuitive...

 

 

So  in short: should Model inputs only used for hardware inputs only? 

 

and also: Is it possible to dynamically, assign a channel (hardware or otherwise) to a model input?  

 

Thx.

L. 

0 Kudos
Message 1 of 17
(6,572 Views)
Channels can be mapped to/from anything... So they don't have to be mapped to anything either. They could go no where... To another model... To a custom device... To hardware... Etc. They must also be set with the set/get channel API as you saw.

Parameters are a little different and you can only set/get them with the model manager API and the workspace calibration controls. They also have limitations on mappings. So basically yes, these are you 'option' inputs to your model.

You cannot change mappings at run-time. However you can do a trick with a model that basically just acts like a big switch. Lots of inputs and outputs and it passes things through differently based upon a setting
Stephen B
0 Kudos
Message 2 of 17
(6,558 Views)

Following up on this, where you say that Parameters can be set from the Calibration controls:  I have one parameter defined in a LV Model.

The parameter appears in the VS system explorer tree as a parameter. So all good. 

 

On the VS workspace though, the Model Calibration Control pops up a windows with "Available Calibration", but it is empty. I was expecting seeing my parameters in there. What am I missing ?

 

Thx

L.

0 Kudos
Message 3 of 17
(6,512 Views)

You might have to be running to see the list of available parameters. Not sure.

 

Also, make sure you have "added" the parameter to the system definition. Clicking parameters in the tree and seeing it as available in the right pane is not enough. you must then click it and say add.

Stephen B
Message 4 of 17
(6,507 Views)

Ah yes, you are right... It works, sort of, as I have one of the parameters that does not seem to have its changes taken into account, only the one that is only supposed to be used a t0, this being built-in the LV model... 

 

Generally speaking, are parameters only taken into account when the model initialized / Start ? 

 

...It may be easier for what I do to just treat all LV model controls as Inputs...

 

L.

0 Kudos
Message 5 of 17
(6,503 Views)

Parameters can be changed when your model is running.  If it's not working correctly, I expect it's probably how you are using this value in your LabVIEW code.  For example, if this value is being used to set the initial value of a feedback node, it will only actually have an effect on the first iteration of your model, and changing it at run-time won't affect anything.

0 Kudos
Message 6 of 17
(6,500 Views)

I suspect something possibly wrong at the level you describe.

 

However that very same parameter was previously used as an input, and accessed via a control on VS workspace and it worked fine.  Nothing has been changed on the LV code, except making the "Required"  - "Recommended" change in the connecting pane to change my controls from "Input" to "Parameter" respectively.

 

At every iteration the parameter should be read and acts on the model output. Here is what the model looks like:

modelcode.jpg

 

CurrentIn_A (Inputs)  and CurrentAccumulationCoeff (Parameter) should be changeable on the fly. VoltageIn_t0 is the second paramter that is taken into account only once.

 

 

Laurent

0 Kudos
Message 7 of 17
(6,498 Views)

You don't need the while loop since you're not using shift registers. Would make your code cleaner and potentially better performing without it.

 

Note that you cannot select parameters from numeric controls, only from model calibration controls. Also, check to see if the parameter is in the list inside tools -> model parameter manager.

 

Can you post your VI?

Stephen B
0 Kudos
Message 8 of 17
(6,489 Views)

Actually, I didn't read enough of the thread. Sorry.

 

Devin is correct, the only reason your parameter is only read once is because it is going into the initial value of the feedback node. You probably don't want to be doing that. Just remove the feedback node for that and the whole while loop.

Stephen B
0 Kudos
Message 9 of 17
(6,486 Views)

ah... yes the while loop is useless now.

 

My initial post is missing one sentence... I agree with you on why this paramter is read once. The ones that did not make sense though  - and that is what was missing from the previous post -  is the CurrentAccumulationCoeff (Parameter).

 

L.

 

0 Kudos
Message 10 of 17
(6,481 Views)