Simulink & Arduino I/O & I2C

Hello,

I am looking for information about how simulink connects to Arduino using the Arduino I/O library. I havent found any source code of these blocks, that provide communication from simulink to Arduino (I mean, I would like to see, what is inside of those blocks - that is my MAIN question - What do these blocks look like from inside).

My motivation is to create a simulink block, that could communicate in I2C. From the hardware side, Arduino Uno supports I2C communication, from the programming side, I2C is realy simple kind of communication.

I am a little bit afraid of what the frequency could be. I have found out, that switching digital ports, to imitate I2C is not a good idea, because simulink cant handle more than cca 10 kHz (e.g. block Digital Write caused problems with sample time above 1/10 000 sec).

P.S. - more detailed description of what I have in mind
A block, that has a single input and 2 outputs (SDA and SCL). The input would be a string, the output would be I2C. The block is executed during simulink step (lets say, that is a fixed step - 0,1 sec), during this step the input string is converted to bits/bytes and sent.

P.S. 2 - I KNOW there is simulink librabry Arduino Target, but that does not support real time control by simulink, anyway I would like to see those blocks from inside too.

Any suggestions, source codes and even possible trouble-causing-hurdles are welcomed, just let me know, I am not the only thinking about this.

I am looking for information about how simulink connects to Arduino using the Arduino I/O library.

You should provide a link to define what you are talking about. What is simulink? What Arduino I/O library?

My motivation is to create a simulink block, that could communicate in I2C.

That may, or may not, be possible. It all depends on what a "simulink block" is.

martin336:
I am looking for information about how simulink connects to Arduino using the Arduino I/O library

That seems to be a question about simulink (whatever that is) rather than Arduino. In that case it would be better to ask your question on a forum that is about simulink.

Well, Matlab & Simulink .... http://www.mathworks.com/ .... (math) simulation program using graphic interface. If there is any place, where this topic would fit, please move it there

If there is any place, where this topic would fit, please move it there

The bit bucket, maybe.

How do you propose to have a software construct communicate with hardware using the interchip communication bus? It simply isn't possible.

There is a new post on the MathWorks File Exchange about a package including a guide that explains how to develop device driver blocks (blocks that perform target-specific functions when executed on a target platform).

More general content about use of MATLAB and Simulink with Arduino may be found at Arduino Programming with MATLAB and Simulink - MATLAB & Simulink

Thanks for the link, I have already seen the step by step manual. It explains a lot, but it doesnt say anything about the way, that simulink blocks communicate with target hardware (in my case - arduino). It explains the way the block are transfered to target hardware in C code - may be this is also the way, but for now, it doesnt explain the process of communication between Simulink and Arduino (i mean in real time).

martin336:
If there is any place, where this topic would fit, please move it there

I don't think there is anywhere within the Arduino forum that is suitable for this, because it is not a question about Arduino.

I have not know that there are Arduino models in MATLAB/Simulink.
That's interesting.

I am looking for information about how simulink connects to Arduino using the Arduino I/O library.

Why not use serial port devices?

Serial Communication between Arduino and MATLAB
http://home.iitb.ac.in/~rahul./ITSP/serial_comm_matlab.pdf

Hi Martin,

I am looking for information about how simulink connects to Arduino using the Arduino I/O library.

the connection happens via serial port over usb

I havent found any source code of these blocks, that provide communication from simulink to Arduino

The source code is there as s-function in the "simulink" folder (you can do "look under mask").
All that the block do is calling the methods for an arduino object.

A block, that has a single input and 2 outputs (SDA and SCL). The input would be a string, the output would be I2C.
The block is executed during simulink step (lets say, that is a fixed step - 0,1 sec), during this step the input string
is converted to bits/bytes and sent.

If you want everything to be executed (in real time) on the board, so that, for example you can disconnect it from the computer, then you have to use the Simulink support package (see the link above from Eric), and you need to create a device driver block.

if you want a block that is executed on your computer when you run a simulation, and every time the block is executed it tells the arduino (via serial port) to perform an I2C communication, then you need to customize both the adio.pde and arduino.m files. The function "roundtrip" was provided as a starting point for such customizations.

Hope that helps.

You can refer to the following link. an I2C add-on block for ArduinoIO package that run on Simulink