So I am using the Modelica device driver (MDD) library to read and write data from an arduino via the serial port. As a toy example, I am serial writing a sine wave from OpenModelica to the arduino and sending it back to OpenModelica. However, at points, the value read comes to be 0, leading to distorted plots. I have provided the simple firmware I am using for this test, and in the images, the model and the output. As you will see in the code, I have provided a delay of 5 ms. If I lower the delay, the plot distortions get denser. Ideally, I am looking for a way to do away w/ the delays.
Also, when the input is taken from a function generator connected to the arduino, no distortion is seen. This leads me to believe that the problem is w/ the serial writing from OM.