MATLAB: Is possible uses PLC Code Generation with MPC (Model Predictive Control)

codegenerationlogix5000Model Predictive Control ToolboxmpcplcrockwellSimulink PLC Coder

Hello Guys, I am working in my final proyect of my career. My goal is implement a Predictive Control in a PAC
The PAC is of Rockwell Automation, Logix5000 Models.
I found the tool of matlab for converter a simulink model to PLC Code, its name is PLC Code Generation. I was make some examples with simple controllers and PID in discrete time. I found a MPC Block, and i was tunning this controller for my plant. I was run a simulation and this is rigth. Now I will want generate the PLC Code.
I converted the MPC Block of simulink in a Subsystem and set the solver type for Fixed-step, i dont change de Solver, now i use ODE3
Then, i activeted Treat as atomic unit. but when Check Subsystem Compatibility, appears some errors
The first error is: Variable-size arrays are currently disable for code generation. Consider selecting the support varable-size signals option on the configuration parameters > code generation > interface page.
And i try enable this option in the options, but this option no appear for any place.
You can helpme, Thanks you and sorry for my bad english

Best Answer

At the time this question was asked MPC Controller block did not support structured text generation with Simulink PLC Coder. This support has been since added starting with R2014a, so this will work now.
Here is an example illustrating the workflow.
Related Question