Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying sample times #50

Closed
bemilio opened this issue Dec 20, 2019 · 6 comments
Closed

Specifying sample times #50

bemilio opened this issue Dec 20, 2019 · 6 comments

Comments

@bemilio
Copy link

bemilio commented Dec 20, 2019

I was wondering if and how it is possible to specify the sample time at which a blockfactory Simulink block is executed

@diegoferigo @traversaro

@bemilio
Copy link
Author

bemilio commented Dec 20, 2019

APparently it was pretty simple - I just had to put the rateTransition blocks before and after the block with the given sampling time. I don't know if there is a parameter (or if there would make sense to have one) to specify it directly in the block.

@diegoferigo
Copy link
Member

@bemilio Currently blockfactory allows implementing unit blocks that provide an instantaneous output (if needed, with an internal memory). Under this assumption, the sample time of the simulation is not passed to the blocks, and there isn't yet an unified way to distribute this information. There's a specific issue that tracks specifically this requirement #8.

There are cases where we need to know the sample time (e.g. the real-time synchronizer block). In that case we pass the sampling time as a mask parameter. It goes under the assumption that blockfactory only support models simulated with a fixed step.

Apparently it was pretty simple - I just had to put the rateTransition blocks before and after the block with the given sampling time.

Your solution is not very clear to me, can you argument it a bit more in detail?

@bemilio
Copy link
Author

bemilio commented Dec 20, 2019

Your solution is not very clear to me, can you argument it a bit more in detail?

here are two screenshots of the setup (one is just a zoom). Blocks and signals have different colors depending on the sample time at which they run.

The yellow blocks are the rate transition Simulink blocks. Given a specific output sample rate, they propagate that sample rate and manage the signal sampling frequency transition.

image
image

@diegoferigo
Copy link
Member

@bemilio I think you are among the first ones to use different sampling rate within the same model (maybe with @CarlottaSartore). I was not aware of the existence of those blocks for the transition.

As far as I knew, an alternative solution is to put all the blocks with a different sampling rate in another subsystem, and then configure the subsystem's step size. Probably in this way you don't need any additional blocks. Though, I'm not sure what is their actual effect.

@bemilio
Copy link
Author

bemilio commented Jan 3, 2020

@bemilio I think you are among the first ones to use different sampling rate within the same model (maybe with @CarlottaSartore). I was not aware of the existence of those blocks for the transition.

As far as I knew, an alternative solution is to put all the blocks with a different sampling rate in another subsystem, and then configure the subsystem's step size. Probably in this way you don't need any additional blocks. Though, I'm not sure what is their actual effect.

Adding to that, I noticed that Simulink has some problems setting the dimensionality of the signals when using these rateTransition blocks. I suggest setting the initial condition parameter of these blocks to a value with a coherent dimension if you have trouble compiling.

@bemilio
Copy link
Author

bemilio commented Jan 3, 2020

I think I can close this, the solution seems to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants