- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Problems with Modelica DeviceDriver...
Problems with Modelica DeviceDriver (MDD) serial write
Problems with Modelica DeviceDriver (MDD) serial write
So I am using the 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.
Code:
int Output;
void setup()
{
Serial.begin(115200);
//pinMode(A5, INPUT);
}
void loop()
{
Output=Serial.read();
Serial.write(Output);
delay(5);
// Serial.write(((int)Output>>8)&0xFF);
// delay(5);
}
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Problems with Modelica DeviceDriver...