- Make sure the Simulink Serial Receive block is set to the correct data type, such as ‘uint8’, to match the ASCII data you are sending.
- Verify that the baud rate and other serial settings are the same for your USB-to-TTL adapter, Arduino Mega, and Simulink model to ensure proper communication.
- Perform a loopback test by connecting the TX1 pin to the RX1 pin on your Arduino Mega to verify that data is being transmitted and received correctly.
- Use a Serial Monitor to observe the raw data being sent and received. This can help confirm whether the data is being transmitted correctly before it reaches Simulink.
Issue with Serial Receive (Arduino Hardware) SIMULINK interfacing with Arduino Mega. "255"
9 views (last 30 days)
Show older comments
Hey Everyone,
Im basically trying to interface a control system with my rotator controller.
The step im currently at is to read user inputs from a Serial Port which then gets processed within SIMULINK.
Currently I have a USB to TTL which is acting as a communcation port, where I send numbers through serial which connects to my ardunio mega.
The information recieved is connected to my Arduino Mega's RX1, which is called throug hthe serial recieve block.
The problem I've been having is, no matter what data type, with what ever number i put into serial, it comes back at 252 to 255.
What im suspecting is that number reperesnts the size of the 8 total bits, so its only counting the amount of bits (I Beleive), rather than decoding it to its integer value.
Im 90% sure the data sent through my Serial monitor is ASCII, in uint8,. Which is why I'm confused of why im only getting "255" as a value even after I convert it.
I assure you that the hardware is wired up correctly, and the the baud rates are consistent across all boards.
When having the communciation straight from the USB to TTL and the Arduino Mega, it is able to serial read and write fine.
So i was just wondering if anyone has encournted this 255 issue, and how do I convert it to numbers?
0 Comments
Answers (1)
MULI
on 7 Oct 2024
Hi John,
I understand that you are sending data from a computer to an Arduino Mega using a USB-to-TTL adapter. The data should be numbers, but in Simulink, you are seeing values like 252 to 255.
You can follow these steps to troubleshoot and resolve the issue:
For more information on setting up and configuring your system, you can refer to the Simulink example on sending and receiving serial data with Arduino hardware.
0 Comments
See Also
Categories
Find more on Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!