MATLAB Answers

Reading Serial Data from Arduino using Simulink

19 views (last 30 days)
Bashhar Byrouthy
Bashhar Byrouthy on 6 Feb 2021
Complete newbie to Simulink and serial data here. I've been trying to get Simulink to read a very simple output made of a single 8 bit integer from an Arduino, but have been getting a bunch of huge readings on my display on Simulink. I know it's receiving the Arduino data because these gibberish readings change as the input from the Arduino changes, but I don't know what's causing them to be so misread. I've attached snapshots of both Arduino and Simulink codes here. First I thought it was a baud issue, so I made sure both were set at 9600. Then I made sure the number outputted is an 8 bit integer, since that's what Simulink is expecting. Still, to no avail. The block I'm using in Simulink is Serial Receive from the Instrument Control Toolbox.
I'd really appreciate any tips/advice/suggestions please. Thanks!

Answers (1)

Kiran Felix Robert
Kiran Felix Robert on 8 Feb 2021
Hi Bashhar,
Refer Use Serial Communications with Arduino Hardware documentation to learn more about Simulink Support packages for Arduino.
Refer the reference Tutorial, Send and Recieve Serial Data Using Arduino Hardware for an example for serial communication and Model settings.
Also check the COM port configurations to make sure that the values are same with respect to the model.

Community Treasure Hunt

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

Start Hunting!