필터 지우기
필터 지우기

Using C code with main loop

조회 수: 2 (최근 30일)
Mantas Dabrovolskas
Mantas Dabrovolskas 2023년 6월 7일
답변: N A POORNA CHANDRA 2023년 6월 8일
I have figured out how to use realtime C with Speedgoat - I use C/C++ Code Block.
But code inside of it is quite unusual - what are "main_Start_wrapper", "main_Outputs_wrapper", "main_Terminate_wrapper"?
Does it mean they are ran one after another? What if I need constant main() loop? I tried that but simulation just froze while running.

답변 (1개)

N A POORNA CHANDRA
N A POORNA CHANDRA 2023년 6월 8일
Hi mantas here is the explanation for those terms
  1. main_Start_wrapper: it is a function which is responsible for initializing the necessary resources and setting up the environment for your real-time application. It performs tasks such as initializing variables, setting up communication interfaces, and configuring the real-time target. It is called once at the start of the application.
  2. main_Outputs_wrapper: This function is the main computation loop of your real-time application. It is responsible for performing the calculations, control algorithms, or simulations in a real-time context. It is executed repeatedly, typically at a fixed frequency determined by your real-time target and system requirements. This function computes the outputs of your application based on the inputs and the current state of the system.
  3. main_Terminate_wrapper: This function is called at the end of the real-time application's execution. It is responsible for cleaning up resources, releasing memory, and shutting down any necessary components or interfaces. It allows for a proper termination of the real-time application.
yes this means they are run one after the another
If you need to have a constant main() loop that runs continuously without freezing the simulation, you may need to modify the generated code or use different mechanisms. Keep in mind that real-time simulation and HIL testing often require specific timing and synchronization with external systems or hardware, so a continuous loop might not be suitable for those scenarios.
here is the documentation for wrappers

카테고리

Help CenterFile Exchange에서 Simulink Real-Time에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by