I’m a newbie in Arduino programming, and now I am facing an issue.
I am making a Hardware In Loop Simulation (HILS) using Arduino and Simulink, so the communication is happened between them. The arduino read the data from MPU6050 and send it to Simulink through serial communication. The data is obtained using MPU6050 DMP, so I just extract the specific data that I want to send to Simulink which are yaw pitch roll and real gravity. In the Simulink side, I use the Serial Receive block.
In the Arduino side, I use serial.write() end send it in form of byte. I use “o” (ASCII 111) as header and “\r” (ASCII 13) as terminator, and it is also already defined in the Serial Receive block in the Simulink. And when it is running, there is a phenomenon like byte skip, it is like a bit delayed.
In the video that can be seen here: http://youtu.be/e3lUQEE0uZc you can see that the animation skipped a bit when it actually moved smoothly. I don’t know what happen, and can anyone know what’s wrong?
You can also see the phenomenon in the picture I attached. In the byte skip 1.jpg, you can see that there are some huge jumps from a value that is usually around -60 and 60 to a huge value like 10^34. And in the byte skip 2.jpg, you can also see that the data is not smooth at all.
I also attached the Simulink file and the Arduino file to be observed if necessary.
Your answer will help me a lot as it is actually a part of my thesis, so I need it to be finished as soon as I can. Thanks
MPUDMPSimu_nosend.ino (2.53 KB)