Is it possible to embed a python model made with simulink into arduino?

조회 수: 2 (최근 30일)
Cristian Napole
Cristian Napole 2024년 12월 1일
답변: Aravind 2024년 12월 16일
The situation is a follows:
  • I've got a model that I built up in python.
  • I'd like to use simulink to embed this model into an arduino.
I made a try with python importer wizard from matlab by using a simple square wave generator. When I click in monitor & tune with the arduino connected, I've got the following error:
Top model targets: Model Build Reason Status Build Duration ==================================================================================================================================== Pin13try Information cache folder or artifacts were missing. Failed to build. For more information, see build log. 0d 0 of 1 models built (0 models already up to date) Build duration: 0h 0m 16.517s
Error(s) encountered while building "Pin13try"
Component:Simulink | Category:Model error
Where pin13try is a python block function that was generated with the wizard. Therefore I'd like to know if it's possible to use python functions or models into arduino by means of simulink.
PS: I also had the following erros in the same log:
fatal error: Python.h: No such file or directory #include <Python.h>
The make command returned an error of 2

답변 (1개)

Aravind
Aravind 2024년 12월 16일
When deploying code from Simulink to Arduino or other hardware boards, the process relies on the code generation capabilities of Embedded Coder. However, certain functions, including Python modules, are not supported for code generation.
The "Python Importer" wizard creates a "MATLAB System Object" block that uses Python modules to implement functionality, but since Python modules are not supported for code generation, you cannot deploy a Python-based model to an Arduino via Simulink. For more details, you can check the official documentation here: https://www.mathworks.com/help/simulink/ug/overview-of-integrating-python-code-with-simulink.html.
As an alternative, consider re-implementing your Python model using native Simulink blocks that are compatible with code generation. This approach will allow you to deploy the model to an Arduino or other hardware boards.
I hope this clears up your question.

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by