A method for inputting values in real-time according to fixed steps.

1 次查看(过去 30 天)
I want to calculate values in real-time based on fixed steps within a MATLAB Function block and pass them as inputs to the prismatic joint. Currently, the calculations are being made inside the MATLAB Function block, but the values are not being transmitted in real-time, and only the final calculated value is being input. If anyone knows how to pass the calculated input values in real-time, I would appreciate your help.

回答(2 个)

Angelo Yeo
Angelo Yeo 2024-9-19
However, since the term "Speedgoat" is not mentioned in the question, I will assume it is basically a desktop real-time environment. The default behavior of the MATLAB Function block is to operate at the sample time of the input signal. (Both Stateflow Chart blocks and MATLAB Function blocks have their Update method set to Inherited by default.)
For reference, Simulink Desktop real-time runs in soft real-time, so depending on the algorithm, it might not run strictly in real-time. On the other hand, simulations using Simulink Real-Time with Speedgoat equipment guarantee real-time performance.
Please take a look at the sample model for Simulink Desktop Real-Time simulation as attached.

Rishav
Rishav 2024-9-19
编辑:Rishav 2024-9-19
Hi 석준,
You can follow the below mentioned steps to pass calculated input values in real-time from a MATLAB Function block to a prismatic joint in Simulink:
  • Set the Sample Time - Ensure the MATLAB Function block is set to inherit its sample time from the Simulink model by specifying -1 as the sample time. This ensures it executes at every simulation step.
  • Output the Calculated Values - Inside the MATLAB Function block, perform your calculations and directly assign the result to the output variable. Ensure this variable is connected to the input of the prismatic joint.
  • Connect the MATLAB Function Block to the Prismatic Joint - Drag a line from the output of the MATLAB Function block to the input of the prismatic joint.
  • Use a Fixed-Step Solver - In the Simulink model configuration parameters, choose a fixed-step solver to ensure consistent time steps, which is crucial for real-time applications.'
Please refer to the following documentation on Prismatic joint:
  1 个评论
Angelo Yeo
Angelo Yeo 2024-9-19
No. Native Simulink simulations do not guarantee Real-Time simulation (neither soft real time nor hard real time). If you are using Generative AI to make up answers, please be responsible and leave a note about it.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Model Preparation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by