I am currently working through the manual and have reached chapter 3.7 Designing a Motor Control System. I have created the Simulink and now I want to run it. As described in the manual I should select under Target hardware resources > External mode > Communication interface Serial, but this does not work, there is only the choice XCP on Serial and XCP on Wifi (see picture).
I found a solution - or to be specific, I did some stuff and now serial shows up on my Simulink.
I'm not sure 100% which step gave me access to serial, so I will list them all, and maybe someone with more expertise can comment.
I reverted to MATLAB 2021b
1a. When installing versions I added everything in the photo of the instructions, not just the list they spell out. This includes Navigation Toolbox, ROS Toolbox, Robotics System Toolbox.
1b. I then installed the specified hardware packets for MATLAB and Simulink.
I reran arduinosetup in the MATLAB Command Window. I selected:
I2C, MotorCarrier, SPI, Serial, Servo (I need to investigate what Serial actually contains)
2a. After running and testing connection I launched the Arduino Explorer App then closed it.
After these changes when I go into Simulink > model settings > hardware implementation > target hardware resources > external mode > communication interface I have 4 options:
XCP on Serial
XCP on WiFi
Serial
WiFi
I hope this helps.
Long story short, I believe the error is due either to a missing toolbox / add on, initializing a program, or version update.
I have the same problem. Working on the Arduino Engineering Kit, chapter 3.7. My license doesn't seem to allow me to switch to an earlier version of MatLab, so if there is any other solution, please let me know!. I have also put in a ticket/service request in Matlab support, let's see if that helps
Here's my solution that worked just via trial & error:
Matlab R2023a Update 4 with a Nano 33 IOT, Windows 11
In Simulink, after you click on the gear for "Model Settings" and select the Arduino go to the Target Hardware Resources dropdown and first select Host-board Connection. On that page change the Set host COM port drop-down to "Manually Specify"
Then change nothing except to set the Host COM port AND Bootloader COM port to 3 (or whatever COM port your Arduino used for setup when you uploaded the libraries). Then the XCP on Serial option should work.
I had the same issue on Matlab R2023a Update 5 with a Nano 33 IOT, Windows 10
In my case Host COM port AND Bootloader COM port were different numbers.
I did not find the Bootloader COM port number in the Device Manager in the beginning (only the Host COM port). The solution is to press the reset-button of the Nano twice and observe the dropdown menu Ports (COM & LPT) in the Device Manager.
I have very similar problem: Issue with Simulink and Arduino Nano 33 IoT. I encountered while working with Simulink and Arduino Nano 33 IoT.
I have 8 AEK rev.2 boards, and as a teacher, I began working with one of them. While everything appears to be in order, I am facing difficulties running models on the board in Simulink IO mode. Specifically, the example provided at [Sync Models by Using Arduino Connected I/O Board - MATLAB & Simulink works on my UNO but encounters an error on Nano 33 IoT. The error from Simulink is as follows:
Error: MATLAB System block 'sldrtex_arduino/Digital Output' error occurred when invoking 'setupImpl' method of 'codertarget.arduinobase.blocks.DigitalWrite'. The error was thrown from 'C:\ProgramData\MATLAB\SupportPackages\R2023b\toolbox\target\shared\devicedrivers+matlabshared+devicedrivers+blocks\DigitalIO.p' at line 0
...
Caused by: Configuring Pin 13 as Digital Input/Output failed. Pin 13 is not a valid Digital Input/Output pin. Reconnect the hardware, provide a valid Digital Input/Output pin number for your hardware and try again.
However, deploying and Start code for DC motors, servos, or Lion Battery monitoring has been successful. Additionally, the Monitor and Tune Simulink mode works well on Nano 33 IoT.
I would appreciate any recommendations on how to set up Matlab/Simulink to address this issue.
One problem solved and other very similar is back: MATLAB System block 'IMU_1/BNO055 IMU Sensor/Base sensor block' error occurred when invoking 'setupImpl' method of 'codertarget.arduinobase.internal.arduinoBNO055'. Caused by:
Error writing IOServerBlock. Running the dc motor via IO mode in simulink after setup Host com port and different bootloader port is seamless, bur same guideline for BNO055 IMU is not working. Any ideas?
Think I figured it out, you can use the host board connection. Under application download set host com port: Manually specify. Host COM set to the port the arduino is set to (you can check this in devices and printers on windows). The tricky part is the bootloader COM port, its different than the host COM and I think the board switches to this when the code is being loaded and then switches back to the original COM port. See this guide to determine how to find the bootloader port Configure Host and Bootloader COM Port Manually - MATLAB & Simulink.
What happened with mine is when the Simulink went to load the code on the board the board switched to COM5 from COM4 and stayed there so I guessed that COM4 was the host and COM5 was the bootloader, that worked for me and I have gotten it to run consistently. Always make sure there are no arduino objects in your workspace as that will also cause issues. SImulink generates an object when you run the code and it does not delete itself from the workspace after you stop the simulation so be sure to delete that after you are done with simulink if you are going to be using the arduino again.
I'm using MATLAB 2023b.
I have the same issue, I think I have tried everything up to selecting the host and bootloader COM-ports nothing seems to work.
In desperation I tried to return to an older version of AEK-Rev-1Hardware-Support package (2018b) resulting in the missing of the MKRmotorshield when trying arduinosetup. (I'm now using the 2019a+ version)
When running a Simulink-file on the board it starts my DC-motor on a constand speed and doesn't responde at all. Time in the bottom left corner doesn't seem to increase and the stop button in simmulink doesn't change the state of either simulink or the board.
Any tips?
Going to a different older MATLAB version is not an option sadly enough.