Message Boards Message Boards

Control Arduino using System Modeler and ModelPlug - own functions

Posted 8 years ago

Hello,

I would like to control Arduino using System Modeler and ModelPlug. But I do not want to be tied by ModelPlug and Firmata. I do not want to be only possible to turn on / off specific pin but I want to run own function on Arduino. For example it would be sufficient if ModelPlug can send to Arduino (to serial port) specified character and on Arduino there should be short program that describes what Arduino do when it receives this character (something like custom Firmata). I have few ideas how to do this but I think that they are quite complicated. Is it possible to do own component to ModelPlug that only send / receive "control" characters? Or do you have different idea?

Thank you very much!

POSTED BY: Tibor Doma

Hello Tibor,

The nice thing about ModelPlug is that it provides all the communication between SystemModeler and Arduino so you don't have to write any code. In your case you need to write some custom code. You have a two alternatives:

  1. Modify the Firmata code so you reuse all the communication layer. For example, every time you receive an AnalogOutput signal, instead of writing to a PWM, pass that value to your custom function. If you take a look at the Firmata code you can find where to put your code.
  2. Create your own library to send serial characters to the Arduino using the ModelPlug code as reference. The code of ModelPlug is included with the library.

Leonardo

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract