Connection via TCP/IP with Arduino nano 33iot and Simulink

4 次查看(过去 30 天)
Hello everyone, I am doing a project that aims to create wireless communication between the Arduino nano 33 iot and the Simulink program. To do this, I have made use of the TCP/IP blocks offered by simulink. I have made two programs in Simulink, one is the one that I have loaded on the Arduino and another is to control with Dashboard elements. The arduino connects to the WIFI connection, but the data that I send from the control program is not transferred. I have tried everything, checking my laptop's firewall in case it had any restrictions, updating the drivers and checking if the network speed is adequate. Could it be that two simulink programs cannot be run at the same time? Also when making the connection I get this error and I don't know why it is:
An error occurred while running the simulation and the simulation was terminated
Caused by:
MATLAB System block 'setup_Wifi_conTCP_Simulink/TCP//IP Receive' error occurred when invoking 'stepImpl' method of 'instrument.system.TCPIPReceive'. The error was thrown from '
'C:\Program Files\MATLAB\R2022b\toolbox\instrument\instrumentblks\+instrument\+system\TCPIPReceive.m' at line 388'.
Error receiving data from the remote server.
Additional Information: Operation timed out before requested data was received.
Component:Simulink | Category:Block error

回答(2 个)

colordepth
colordepth 2024-12-20
编辑:colordepth 2024-12-20
The error you experienced suggests that the already running simulation disconnects from the Arduino when you attempt to establish a different connection. In my experience, the server uploaded to the Arduino during the setup process can only handle one Wi-Fi connection from MATLAB at a time, as I have encountered issues when trying to create multiple connections.
I suggest merging your logic into a single model. This should help prevent potential conflicts by ensuring that only a single connection to the Arduino is used.
If you still experience data transfer problems, you might find these troubleshooting resources helpful:
  1. For issues related to Arduino connection failures: https://www.mathworks.com/help/matlab/supportpkg/arduino-connection-failure.html
  2. For problems with lost connections and data transfer: https://www.mathworks.com/help/matlab/supportpkg/connection-and-communication-issues.html

Angela
Angela 2024-12-20
Hello, thank you for the answer. So you recommend doing one simulink programm instead of two? How to differentiate the program that goes to the Arduino and which one to do the control?
  1 个评论
colordepth
colordepth 2024-12-24
It would be helpful if you could share the models so I can review how they might be merged. In the meantime, here is another workaround you can try. Please note that I cannot verify this on my end as I do not currently have access to an Arduino.
Try running the program to be loaded on the Arduino in "External mode," followed by running your controller program in "Connected IO mode." My understanding is that "Connected IO mode" does not require the currently simulating model to be the same one deployed on the Arduino, since code generation is not involved (see: https://www.mathworks.com/help/simulink/supportpkg/arduino_ug/connected-io.html).

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by