Plexim has announced that the PLECS power simulation platform is now able to automatically generate the C code necessary to run on the actual hardware. This development enables users to easily get code running on a controller or to evaluate different controllers.
Generate C code from a PLECS model
The PLECS Coder generates generic ANSI-C code, which can be compiled to execute on the simulation host or on a separate target, such as an embedded control platform or a real-time digital simulator. The model to be translated into code can be a physical system or control logic. The code can also be compiled and executed on the host in order to reduce the simulation time for complex models.
Support for Simulink
The PLECS Coder supports Simulink Coder®. 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 two different targets: the rapid simulation target (or RSim target) and the real-time target. By default, PLECS automatically selects the correct target based on the target settings of Simulink Coder.
Code ready for deployment
The PLECS Coder can produce code for a specific hardware target. Target support packages allow users to customise 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.
Support for RT Box
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 analogue and digital inputs and outputs to and from the unit. Specialised blocks are included for capturing PWM signals from an external source and generating quadrature encoder signals directed to a controller.
Offline PLECS model example – three-phase solar inverter system
Below is a schematic for an offline PLECS model for a three-phase solar inverter system. The real-time capable code for the plant, incoming PWM signals, and outgoing current and voltage measurement signals can be generated using the PLECS Coder.