Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Problems with OM-Arduino interface

Problems with OM-Arduino interface

Hey, so I recently started using OM, and I have been tasked with developing a real-time hardware in loop system, using an arduino as the hardware controller. I have an interface library for OM-Arduino, but I find myself unable to generate interrupts from OMEdit. Is there an existing mechanism for generating serial interrupts using OM?

Re: Problems with OM-Arduino interface

I'm a bit unsure exactly what you want to accomplish, but you could certainly setup an interrupt handler using external "C" in Modelica; as far as I know the DeviceDrivers library does not expose interrupts to the user.

Re: Problems with OM-Arduino interface

I am trying to, for the sake of this question, achieve a real-time system with OM and arduino.

On using a C interrupt handler, like what's used  in https://stackoverflow.com/questions/151 … n-in-linux, what I understood was that the code being activated during the interrupt would have to be placed in the C function itself. Which, owing to my lack of C experience, I wasn't able to traverse through.

Re: Problems with OM-Arduino interface

So you want a simulation using OMEdit to send some data to the Arduino? If you just send data on the serial port, you would trigger the interrupt on the Arduino and the other way around...

Re: Problems with OM-Arduino interface

I want to send data to the arduino, and receive some output from it as well. Using the aforementioned code as an external function, could that be achieved?

Re: Problems with OM-Arduino interface

https://build.openmodelica.org/Document … ceive.html and
https://build.openmodelica.org/Document … tSend.html might be easier to use, but as far as I remember, they require sending data packets of the same size all the time and just keep the last received packet in the buffer (or some other odd behavior).

Re: Problems with OM-Arduino interface

So I tried using it, but I have been unable to get clean data from the arduino. Often as I try to read data from the serial port, large portions of it are garbled. Would you have a clue as to what might be happening?

I am using an analog function generator connected to the arduino, and using the serial receive and unpack int to read it. The firmware involves a Serial.write(analogRead(A5)) in the loop with a delay and that's it.

Thanks.

There are 0 guests and 0 other users also viewing this topic
You are here: