Generate C Code from a PLECS Model
The PLECS Coder generates generic ANSI-C code from a PLECS Blockset or PLECS Standalone model. The code can be compiled to execute on the simulation host or a separate target, such as an embedded control platform or a real-time digital simulator. The model to be translated into code may be a physical system or control logic.
A typical application is hardware-in-the-loop (HIL) simulation, where real control hardware is connected to a virtual plant model simulated on a real-time simulator. This approach allows easy verification and validation of the control hardware and software without an expensive power stage.
Support of Simulink Coder
If you generate code for a Simulink model, the PLECS Coder works hand in hand with the Simulink Coder® (formerly Real-Time Workshop). When the build process is started, PLECS automatically generates code for the circuit block and inserts it in the appropriate locations. In this mode, PLECS can generate code for the Rapid Simulation target (or RSim target) and the Real-Time target. By default, PLECS automatically selects the correct target depending on the target settings of the Simulink Coder.
Code Ready for Deployment
The PLECS Coder can produce code for a specific hardware target. Target support packages allow customizing the code generated for virtually any CPU/MCU-based platform. A simple association between signals in a PLECS model and the physical input and output pins on a target is made directly in the schematic via I/O blocks.
RT Box Target The RT Box Target Support Package for PLECS directly targets the PLECS RT Box. The PLECS RT Box component library contains blocks for configuring general analog and digital inputs and outputs to and from the unit. Specialized blocks are included for capturing PWM signals from an external source and generating quadrature encoder signals directed to a controller. Below is an example of an offline PLECS model schematic of a three-phase solar inverter system where real-time capable code for the plant, incoming PWM signals, and outgoing current and voltage measurement signals can be generated using the PLECS Coder.
The External Mode allows the user to connect an offline PLECS model with a real-time model running on the RT Box to tune parameter values on the target and display captured online data in a PLECS Scope.
Microcontroller Targets The PLECS embedded control platform targets each supported code generation and External Mode operation for off-the-shelf microcontrollers (MCUs) from different manufacturers. Each target contains a unique component library, including blocks to model and programs the MCU peripherals for sensing and actuation. The embedded control logic can be implemented using standard PLECS library components. Multi-tasking code generation is possible, unlocking processing power for controls regulating multiple system outputs with dynamics on various time scales.
There are two primary methods to deploy generated embedded code onto the MCU. You can directly program the target device from the PLECS application or generate embedded C code for the specified target into a template integrated development environment (IDE) project specific to the manufacturer. Once the generated code is deployed on the target device, you can connect via the External Mode to inspect real-time signals and adjust controller set points and parameters.
TI C2000 Target The PLECS Texas Instruments (TI) C2000 Target Support Package supports the TI 2806x, TI 2833x, TI 2837x, and TI 28004x MCU families. In addition to directly programming the target device from PLECS, you can build into a template Coder Composer Studio (CCS) project.
ST STM32 Target The STMicroelectronics (ST) STM32 Target Support Package supports the STM32G431, STM32G474, STM32F303, and STM32F334 MCUs. You can directly program the target device from PLECS via Open OCD (or J-Link) or generate embedded C code into a template STM32CubeIDE project.
Imperix Target (third party) The PLECS Target Support Package developed by Imperix can directly interface with their controller prototyping platforms, including the B-Box RCP unit and the B-Board PRO. Watch an introductory video or to learn more information and download the TSP, visit Imperix's website: https://imperix.com/software/acg-sdk/plecs/
For more details, please refer to this link:
コメント