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.

Fixpoint Controller Simulation

0 votes
1,063 views

We already have a working and well tested plecs standalone simulation model. As a next step we would like to transform the control logic from plecs model into VHDL code for hardware implementation. There is no floating point unit on the FPGA available - the final controller must be of fixedpoint form. Is there any way to simulate a fixed point control logic?


Our first idea:

  • Write some script that implements the controller. For example a python script relying on https://pypi.org/project/pyPhix/ for fixed point operations.
  • Run this python script using the "DLL" block that can be found under Library browser -> Control -> Functions & Tables.
    Unfortunately we did not get this DLL block to execute any python code at all. The manual only explains the inclusion of C/C++. We could not find a MWE in python so far.
  • Last step would be to transfer from python script to VHDL. This is fairly easy once all fixedpoint number format are known.
Any suggestions are warmly welcome!

 

asked Aug 11, 2019 by egglia (16 points)

1 Answer

+2 votes
 
Best answer
Hi,

Unfortunately only DLLs using C and C++ are officially supported in PLECS. Googling gives a few option that you could try, but again this is fully experimental and not officially supported/tested by the Plexim developers.

1. Implement the fixed-point control algorithm in C using the FixMath library (http://www.nongnu.org/fixmath/doc/index.html)
2. Embed python into C, see e.g. https://docs.python.org/2/extending/embedding.html or https://www6.software.ibm.com/developerworks/education/l-pythonscript/l-pythonscript-ltr.pdf
3. It might be possible to create a dll from Python using Cython (see https://cython.org/#about or https://docs.python.org/3/faq/windows.html#is-a-pyd-file-the-same-as-a-dll)

Best regards,
NF
answered Aug 16, 2019 by Niklaus Felderer (68 points)
selected Aug 27, 2019 by egglia
...