Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

generate c code for pwm switches

0 votes
93 views
a simple model is attached.

when I coder the model without datatype block, it happens "Error during signal evaluation in component 1/FET1: This switch must be controlled with a Boolean signal.  If the control signal comes from a PWM Capture, consider replacing this switch with a suitable Power Module in "Sub-cycle average" mode."

why?

Is there other ways that make it work expect using datatype?

thanks
asked Aug 16 by fire (56 points)

1 Answer

0 votes
 
Best answer
Signals are by default floating point in the generated code. PLECS will generate an error during code generation whenever a non-boolean signal is fed into a switching element. This is to urge users to use the appropriate components from the "Power Modules" section of the PLECS library which are significantly better suited for code generation and high fidelity real-time simulation.

In some cases there may not be an appropriate power module or the switch is a simple disconnect.  In those cases you can eliminate the error by explicitly converting the signal's data type to a boolean, as you have done.

In addition to using the Data Type block, in some cases you can also change the "Output data type" parameter of the component supplying to the gate input (the Pulse Generator in your model).  This has the same net effect.
answered Aug 18 by Bryan Lieblick (1,291 points)
edited Aug 19 by Bryan Lieblick
...