using c code with main loop -凯发k8网页登录

26 次查看(过去 30 天)
mantas dabrovolskas
mantas dabrovolskasabout 18 hours 前
,about 2 hours 前
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 个)

about 2 hours 前
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

类别

find more on general applications in and

产品


    版本

    r2022b

    community treasure hunt

    find the treasures in matlab central and discover how the community can help you!

    start hunting!

    translated by

    网站地图