It is possible to upload a Simulink function to the C2000 controller using the C2000 Microcontroller Blockset tool

5 views (last 30 days)
Hello everyone, and thank you for your help. I have a PI control system in Matlab, which I understand can be loaded onto the C2000 controller using blocks. However, in my case, the control system's reference signal comes from a Simulink function. This function describes a mathematical model and is solved using the Newton-Raphson method. Is it possible, with these blocks, to generate C code for this type of Simulink function, or does this only work for specifically control system applications? Thank you very much

Accepted Answer

Vasco Lenzi
Vasco Lenzi on 24 Nov 2023
Hi Tania
Is possible to generate code which goes on the C2000 from the vast majority of Simulink blocks (and MATLAB functions, included in a MATLAB Function block in Simulink). This is the beauty of Simulink: you are not locked in in specific blocks and then only those blocks works for C code generation or targeting specific microcontroller. You can create your own algorithm from scratch in Simulink, simualte to make sure it works, generate code and test it on the real hardware. My recommendations would be:
  • If possible, take part of the Simulink Fundamentals + Embedded Coder Training. It will help tremendously. You can find them on our training page. This is paid training, so I don't know if this is an option for you but for sure would be the first step. I think if you are in university, you should most probably have the Simulink Fundamentals online version included.
  • Structure your algorithm in a single Simulink model and perform the Simulink Model Advisor for Simulink Coder and Embeddd Coder. This will help you make sure you are using best practices for code generation and identify incompatible blocks&functions: https://www.mathworks.com/help/simulink/ug/select-and-run-model-advisor-checks.html
  • Purchase a C2000 development board such as TMS320F28379D, in case you don't already have a C2000 board. The closer the microcontroller CPU is to your actual target the better: so you can measure perfromance on a CPU with similar computational power
  • Learn about deployment on C2000 by performing some of the shipping examples such as: https://www.mathworks.com/help/ti-c2000/getting-started-with-c2b.html
  • Test the computational needs of your algorithm on target using Processor-in-the-Loop: https://www.mathworks.com/help/ti-c2000/ug/code-verification-validation-with-pil.html
  • This will tell you exactly how many microseconds your algorithms need, in order to compute each step
  • If there are performance problems and your C2000 board has CLA (dedicate CPU for math intense task), try to move some mathematically intensive operation in a dedicate Simulink subsystem targeting CLA: https://www.mathworks.com/help/ti-c2000/ug/CLA-Task-Subsystem.html
Hope this helps!
Vasco

More Answers (0)

Communities

More Answers in the  Power Electronics Control

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!