Is it necessary to discretize control blocks before Run from Coder or Generating Code for CCS on C2000 Launchpad?

Dear Plexim Community,

I have simulated a half-bridge LLC converter model with continuous control implementation, successfully reaching my requirements.

Now, I would like to run the control law in the F280039C Launchpad, and I was wondering if I need to discretize all continuous elements in my PLECS model before I either Run from Coder or generate code from the model to be imported into CCS? I ask because since it will be running from a MCU, I assume it is a digital control method (?).

Amonsgt the “TI C2000 Target Support Demos > Power Supplies” examples, I have found controller models which included both continuous and discrete elements, such as PI(D) and Delay blocks, so this further confused me.

Other than that, I found this fixed post explaining the workflow for digital controller design and mentioning that configuration 4 is the one used for MCU project. Does that mean that if I want to build and program my controller into such LaunchPad platforms, ideally it would be design just as the configuration 4 example from the file in the mentioned post?

I have also found this call/invite post to a kind of webinar/session (Embedded Office Hours) on the topic of digital controller design. Is there any chance I can have access to the video of that session?

In the end, what is not clear to me and I would appreaciate to hear from the more experienced members is if there is any guideline for the model build-up in order to make it more “migration-friendly/compatible” to the MCU/Launchpad framework?

Thank you in advance and best regards!

Hi gutovsk,

Hope you are doing well. Please see my comments below:

Now, I would like to run the control law in the … digital control method (?).

Code generation automatically handles the discretization of your continuous-time controller, so you do not need to maintain separate models for offline simulation and code generation. With the PLECS Target Support Packages (TSP), you can use a single model to both configure the MCU peripherals and run offline simulations.

The TSP includes peripheral models that accurately and efficiently represent peripheral behavior. This allows you to validate expected performance through offline simulation before generating code from the same model to program your MCU.

Other than that, I found this fixed post explaining […] example from the file in the mentioned post?

As described in the post, SIL can take two forms depending on the project requirements. For projects that plan to use code generation, the same model can be used for both offline simulation and MCU code generation, as mentioned above.

For projects that rely on hand-coded implementations, the post describes a method for integrating the manually developed algorithm into a PLECS simulation. If you are using code generation, you do not need to follow the steps described in the “SIL via C-Script” section.

I hope this helps clarify any confusion from the article.

In the end, what is not clear […] to the MCU/Launchpad framework?

With PLECS Code generation you can easily maintain your controller design in the continuous domain and let the tools handle the discretization for your. Additionally, with you can:

  • inspect the code that has been generated
  • run your offline simulation using the generated code
  • see this youtube playlist to get started with code generation

Finally, I would recommend going through our tutorials to quickly get up and running with code generation.

1 Like