C++ code generated from simulink and using the same in ARM Cortex processor

3 views (last 30 days)
I am trying to use 'generate C++' code feature in simulink model. I have connected a PID block with a negative feedback in my simulink model. There is no plant connected. I just want to get the PID c++. I am able to generate the code and it creates a folder named PIDO_ert_rtw having ert_main.c and other associated .c, .h and other files. Now I want to use the PID code in an embedded system project with an ARM cortex processor. I am able to add the .c and .h files in my embedded system project folder and compile it successfully. But I don't know which function to call in my main.c project file for using the PID function. In ert_main.c there is this main()
int_T main(int_T argc, const char_T argv[]); int_T main(int_T argc, const char_T *argv[]) { / Initialize model */ PID0_initialize();
/* Simulating the model step behavior (in non real-time) to
* simulate model behavior at stop time.
*/
while ((rtmGetErrorStatus(PID0_M) == (NULL)) && !rtmGetStopRequested(PID0_M))
{
rt_OneStep();
}
/* Disable rt_OneStep() here */
/* Terminate model */
PID0_terminate();
return 0;
}
should i call this function in my main file. Also how do i give my input error to this function.? I am attaching my simulink model also.

Answers (0)

Community Treasure Hunt

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

Start Hunting!