フィルターのクリア

How to interface Ardiuno with external application on host machine using Simulink

4 ビュー (過去 30 日間)
I am trying to create a Simulink model in which I read information from some external application on my host computer using UDP and then send information to a piece of hardware via an Arduino. My external application is an driving simulation and the hardware I am controlling with the Arduino is an engine test rig. See the diagram below for basic setup:
The model I am trying to run in external mode looks like the following, with the UDP Receive block from the Instrument Control Toolbox reading from an external application and the SPI writing data from Arduino.
The issue is that when I try to run this model in external mode I get the following error:
ERROR: ### Build procedure for model: 'Arduino_test_UDP_edit' aborted due to an error.Level-2 MATLAB S-function 'sudprb' in 'Arduino_test_UDP_edit/UDP Receive' specifies 'SetSimViewingDevice(true)' , which prevents an output port from being created for the S-function.
What can I do?

採用された回答

MathWorks Support Team
MathWorks Support Team 2024 年 4 月 18 日
編集済み: MathWorks Support Team 2024 年 4 月 19 日
When you run in external mode Simulink generates code for the blocks in the model and runs them on the Arduino with some back end communication so that you can see signals and tune parameters. The issue with your model is that Simulink tries to generate code for the UDP Receive block from the Instrument Control Toolbox so it can be deployed on the Arduino, even though you want this block to run on the host computer. The UDP Receive block is not supported for code generation and thus the error you are receiving. Currently there is no way to tell Simulink that you want he UDP Receive block to run on the host computer.
Due to this I think you will have to change your modeling setup to one of the following configurations:
1. Run everything on the Arduino.
I am not sure what kind of logic you are trying to incorporate in your model but if it is simple enough to run on the Arduino then you can deploy your whole model to the Arduino and have the Arduino receive the UDP signal from your driving simulation. This may require an ethernet shield for the Arduino.  See a diagram of the setup below and find the attached model deplotToArduino.slx as an example.
2. Make Two models, run model 1 on host computer, and model 2 on Arduino. 
Split your model up so that there are now two models, one will read the data from the driving simulation using UDP Recieve and send information through a serial connection to the Arduino. The Arduino will read the serial connection (USB port) from Simulink and output information via SPI. This would be somewhat similar to the setup shown in the following documentation:
 
See the diagram below for the overall setup and see the attached examples "SendFromSimulink.slx" and "RecieveOnArduino.slx".

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeArduino Hardware についてさらに検索

タグ

タグが未入力です。

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by