Issue in Reading serial data from the Arduino Uno in Simulink using Serial receive block
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm using an Arduino Uno with Simulink and trying to read serial data using the Serial Receive block. The Arduino is printing voltage values from an analog sensor as follows:
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.println(voltage);
However, I'm facing a conflict because the Serial Receive block and External Mode are trying to use Serial Port 0, which is the only hardware serial port available on the Arduino Uno.
My Setup:
- Hardware: Arduino Uno
- Simulink Blocks:
- Serial Receive block to capture the data sent from Arduino
- Mode: I attempted to use both Connected I/O and External mode (Run on board), but as the simulation doesn't allow to change the the serial port from 0 in either mode, nor can I change the pin number in the Serial Receive block.
Problem:
When I run the model, I receive the following errors:
Run with I/O
Caused by: Serial Port 0 used by the Serial Receive block, is also used for Connected I/O. Change the port number used by the block in your model.
Run on baord
Serial Port 0 used by the Serial Receive block is also used for External mode. Change the port number used by the block.
However, the Arduino Uno only has one hardware serial port, and there's no option to change the serial port in the Serial Receive block or in the hardware setting in the Simulink.
How can I resolve this conflict and successfully read serial data from the Arduino Uno in Simulink?
5 Kommentare
Monalisha
am 27 Aug. 2024
Using Serial Receive Block with port 0 and External Mode at Port 0 is not possible.
External mode by deafuolts works on Serial 0.
Another workaround that you can try is using Build deploy anmd Start workflow, to flash your model in the Target Hardware. Post that you can use putty or Arduino IDE to open serial at the same port 0.
This limitation is there as Arduino Uno just has one single Serial Port available.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Modeling finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!