Cancel
Showing results for 
Search instead for 
Did you mean: 

How to store the value from a time history in and use it in a different part of the model

Creator
Creator

Hi,

I have a model with a cam-follower running at a certain rpm and compressing a spring attached to the follower. I want to grab the value of the force exerted on the spring at time t=20s, and use it as an input to a function block for a different component elsewhere in the same model.

I am trying to using a 'dynamic controlled write' (SIGWRITE1) to trigger a write command to an output file ('force_at_t20.data') when the simulation time equals 20s and read this file to provide the input to my function block.

When I run my model, I see that the trigger to write the data to a file occurs at the desired time (t=20s) but I do not see any data stored in 'force_at_t20.data'.

Any suggestion/advice on how to go about this?

Is there a better way to implement this? Some way to store the value into a variable and use it in the simulation instead of writing to a file and reading it elsewhere?

 

Thanks in advance!

 

4 REPLIES

Re: How to store the value from a time history in and use it in a different part of the model

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi ameswimmer,

if you just want the value at 20 sec you could try using a sampler with a variable sample rate. When the simulation time is lower than 20 seconds (+something small) you sample at 20 sec and after that you don't sample.
If you want to have the continuous force after 20 sec you just use a f(x,y) block taking the time into account, it will look like this:
amesim_sampling.jpg

Re: How to store the value from a time history in and use it in a different part of the model

Creator
Creator
Thanks Emmanuel_D! That is exactly what I was looking for.

Re: How to store the value from a time history in and use it in a different part of the model

Siemens Phenom Siemens Phenom
Siemens Phenom

Great.

Actually there is a simpler solution. You could also multiply your sensor signal by a step signal which will switch from 0 to 1 at time 20 sec...

amesim_step.png

Re: How to store the value from a time history in and use it in a different part of the model

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

hi ameswimmer,

 

In any case, do not use data files to communicate data between 2 submodels that are part of the

same model.

At the beginning of the simulation, the submodel reading the file will open an empty (or obsolete)

version of the data file. In other words, the file will be opened and read before containing the relevant

data.

 

Using a sensor and a sampler is the correct way to do it.

 

BR