10-19-2011 06:59 PM - edited 10-19-2011 07:00 PM
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:
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.
10-19-2011 07:41 PM
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
10-19-2011 08:06 PM
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
10-19-2011 10:49 PM
10-20-2011 10:39 AM - edited 10-20-2011 10:40 AM
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.
10-20-2011 12:02 PM
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".