VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling the simulation time to align with system time

Solved!
Go to solution

Okay so this may be blindingly obvious or just a ridiculous question but here goes:

 

I'm running a dll I've produced from a .mdl file. My aim (amongst other things!) is to get the model's dynamic response accurate to 'real world' timing (system time). The tuning for the control aspect of this model has been based on simulation time when produced in simulink and so it's desirable for me to set simulation time to run at system time.


The problem I'm having, if you open the workspace and produce a model control, the simulation time shown is much faster than system time.

 

For example, one iteration of the model takes a fraction of second. What I imagine is happening is that it is imediately restarting (and progressing a time step). I suppose I want the model to wait until it is in sync with system time before iterating again.

 

Is there a way to fix this, and does anybody know if this problem will be solved in Simulink or Veristand 2009.

Any information would be appeciated, my trawl of NI help files haven't really answered the questions yet though

 

Thanks,
James

 

0 Kudos
Message 1 of 3
(6,692 Views)
Solution
Accepted by topic author bradf0rd

The models are running in a synchronized fashion with the rest of the system. Unless you specify a decimation factor for your model other than 1, for every tick of the Primary Control Loop your model will tick once, too. The difference between the Model Time and System Time you are seeing is due to the fact that the model time is based on its compiled Delta T time step, not any wall-clock time. Every time the model ticks, it adds its own Delta T to its running time channel.

 

The System Time channel is based off of the Delta T of the Primary Control Loop. So it corresponds with the rate you specified the system to run at. If these Delta Ts are the same, the times should be aligned. If you want the model's time to correspond with an actual wall clock time, you can either adjust the loop rate of the Primary Control Loop to match that Delta T, or adjust the decimation factor of the Model so that it only gets ticked once for every N iterations of the Primary Control Loop.

Jarrod S.
National Instruments
0 Kudos
Message 2 of 3
(6,691 Views)

Ah brilliant, thanks for the response.

 

I don't know off the top of my head how I would change the decimation or primary control loop rate, I'll have a tinker and let you know how it goes.

 

Thanks,
James

0 Kudos
Message 3 of 3
(6,688 Views)