VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW-based model initial conditions

I am wondering of a good approach to initialzed models in VS2011 that were created with LV. So far I came up with the following scheme:

ModelInit.jpg

X_t0, Y_t0, and Z_t0 are the model initial conditions. They could be constant, but it is better to associate them with an input. In VS, these would be associated with a control in the Workspace, same thing in LV and VS-API.

 

X_ti, Y_ti, and Z_ti are the model inputs at time (i). They would typically be plugged from hw channels, or other models' outputs.

 

 

Do you think this is a viable approach? Thx.

 

L.

0 Kudos
Message 1 of 6
(5,971 Views)

Hmm...  That may not be the ideal approach.  The model is already deployed to the target and may already be running when the workspace makes its initial connection.  In that case, the default front panel values for X, Y, and Z_t0 would have already initialized the Feedback Node; and whatever workspace control you map to those LabVIEW model inports would have no effect since the LabVIEW model stays in memory between time steps.

 

You might get away with setting the initial model state to Paused in the system definition, establishing the connection to the workspace, setting the initial values, then starting the model from a workspace control.  Seems like a lot of work prone to user error.  What would you see at the model outports while the model is paused, and does that matter to you?   

 

In the System Storage API, you'll find a ChannelType object with a Default Value property.  The Model Initial Values custom device uses this property to ensure the model inports start executing with the default value you specify.  That's the approach I'd recommend for setting LV model initial conditions (assuming the custom device works on LabVIEW models, I've never tried).

 

Steve K

0 Kudos
Message 2 of 6
(5,968 Views)

 

Re: Model Initial State paused or running:

Yes I think I understand the caveat here. The models in our case are paused when they are deployed. So far, we did not noticed issues with the initial conditions, but we did not run extensive tests... 

 

Re:  Using System Storage API, and a ChannelType object with a Default Value property:  

I will have to try.

 

Other options:

 

- maybe adding a boolean in the model instead of the feedback node, the initialization can take place at any time within the model execution...?

 

This begs the question though: what does VS use as default value for a model's input? Does it matter if the controls used to define these inputs have default values in LV? Does VS is aware of them?

 

L

 

0 Kudos
Message 3 of 6
(5,964 Views)
If you're using NIVS 2011, you can actually just click on the model inport channels inside the system explorer and set their initial (default) values.

Then you don't need those feedback nodes or the custom device.
Stephen B
0 Kudos
Message 4 of 6
(5,959 Views)

ah... ok, forgot about this panel. right...  So I looked for setting the default from the API. No luck. Is this property public? or exist at all?

L.

0 Kudos
Message 5 of 6
(5,942 Views)

It's public, and certainly takes some digging.  In the Model Initial Value download, take a look at "Model Initial Values - Set Inport Channel Default.vi".

0 Kudos
Message 6 of 6
(5,933 Views)