Hi, I had spent some time on this issue. Want to ask if anyone would help?
I have a robot running on an Arduino Mega controlled by a Simulink model. Both internal and external mode works fine. The model controls the motors, reads the quadrature encoders, receives data from an IMU sensor, etc. All are OK.
I want to send some parameters to the robot over serial interface which is basicly an xbee pair, but have a fundamental problem with it.
Here is the basic block diagram of the system:
USB-to-Serial0 connection is just for monitoring the signals and uploading the model. It's not needed when the model was deployed to the robot.
I have prepared two example models to clarify the problem. Here is the model to send 4 numbers each are 4 byte single values over /dev/ttyUSB0 (Xbee connected to computer)
This model works fine and sends all 4 numbers in a 4-bytes data type.
Then, on the Arduino side, I want to recreate those 4 numbers using the bytes received. Here is the Arduino-side model:
I have a big problem with what I receive in this side. I cannot recreate the numbers back. There is a very good explanation in this page. But I couldn't make it possible in my case. The xbee part would seem making things more complicated. If so, you can just assume the serial port was directly connected to arduino serial port 3.
Long story short, I couldn't receive multiple 4-byte numeric values over serial port and recreate them on arduino using Simulink. I will appreciate it if someone helps. Thanks.